|
@@ -9,6 +9,7 @@ import com.caimei365.order.model.dto.PaySecondDto;
|
|
|
import com.caimei365.order.model.dto.PayVipDto;
|
|
|
import com.caimei365.order.model.po.SplitAccountPo;
|
|
|
import com.caimei365.order.service.PayNonOrderService;
|
|
|
+import com.caimei365.order.utils.MathUtil;
|
|
|
import com.caimei365.order.utils.PayUtil;
|
|
|
import com.caimei365.order.utils.pay.RSAUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -42,6 +43,8 @@ public class PayNonOrderServiceImpl implements PayNonOrderService {
|
|
|
private WeChatService weChatService;
|
|
|
@Value("${pay.second-notify-url}")
|
|
|
private String secondHandUrl;
|
|
|
+ @Value("${pay.vip-notify-url}")
|
|
|
+ private String superVipUrl;
|
|
|
/**
|
|
|
* 二手发布微信线上支付
|
|
|
*
|
|
@@ -58,7 +61,7 @@ public class PayNonOrderServiceImpl implements PayNonOrderService {
|
|
|
PayParamBo tempParam = new PayParamBo();
|
|
|
// payDto -> payParam
|
|
|
BeanUtils.copyProperties(paySecondDto, tempParam);
|
|
|
- ResponseJson<PayParamBo> jsonParam = getJsonObjectResponseJson(tempParam, headers);
|
|
|
+ ResponseJson<PayParamBo> jsonParam = getWeChatResponseJson(tempParam, headers);
|
|
|
if (-1 == jsonParam.getCode()){
|
|
|
return ResponseJson.error(jsonParam.getMsg(), null);
|
|
|
}
|
|
@@ -77,7 +80,7 @@ public class PayNonOrderServiceImpl implements PayNonOrderService {
|
|
|
* @param headers HttpHeaders
|
|
|
* @return payParam获取微信支付信息
|
|
|
*/
|
|
|
- private ResponseJson<PayParamBo> getJsonObjectResponseJson(PayParamBo payParam, HttpHeaders headers) {
|
|
|
+ private ResponseJson<PayParamBo> getWeChatResponseJson(PayParamBo payParam, HttpHeaders headers) {
|
|
|
// 微信线上支付
|
|
|
payParam.setPayWay("WEIXIN");
|
|
|
String openId = null;
|
|
@@ -152,7 +155,7 @@ public class PayNonOrderServiceImpl implements PayNonOrderService {
|
|
|
PayParamBo payParam = new PayParamBo();
|
|
|
// payDto -> payParam
|
|
|
BeanUtils.copyProperties(paySecondDto, payParam);
|
|
|
- //支付宝支付
|
|
|
+ // 银联支付
|
|
|
payParam.setPayWay("UNIONPAY");
|
|
|
payParam.setPayType("GATEWAY_UNIONPAY");
|
|
|
// 二手发布默认100元
|
|
@@ -310,7 +313,20 @@ public class PayNonOrderServiceImpl implements PayNonOrderService {
|
|
|
*/
|
|
|
@Override
|
|
|
public ResponseJson<JSONObject> paySuperVipByWeChat(PayVipDto payVipDto, HttpHeaders headers) {
|
|
|
- return null;
|
|
|
+ PayParamBo tempParam = new PayParamBo();
|
|
|
+ // payDto -> payParam
|
|
|
+ BeanUtils.copyProperties(payVipDto, tempParam);
|
|
|
+ ResponseJson<PayParamBo> jsonParam = getWeChatResponseJson(tempParam, headers);
|
|
|
+ if (-1 == jsonParam.getCode()){
|
|
|
+ return ResponseJson.error(jsonParam.getMsg(), null);
|
|
|
+ }
|
|
|
+ PayParamBo payParam = jsonParam.getData();
|
|
|
+ // 获取会员套餐价格
|
|
|
+ Double price = payOrderMapper.getVipPackagePriceById(payParam.getVipId());
|
|
|
+ payParam.setPayAmount(MathUtil.mul(price, 100).intValue());
|
|
|
+ payParam.setNotifyUrl(superVipUrl);
|
|
|
+ log.info("【升级超级会员微信支付】>>>>>>>>>>>vipId:" + payParam.getVipId()+",获取openId:" + payParam.getOpenId());
|
|
|
+ return toPaySuperVip(payParam, headers);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -325,7 +341,18 @@ public class PayNonOrderServiceImpl implements PayNonOrderService {
|
|
|
*/
|
|
|
@Override
|
|
|
public ResponseJson<JSONObject> paySuperVipByAlipay(PayVipDto payVipDto, HttpHeaders headers) {
|
|
|
- return null;
|
|
|
+ PayParamBo payParam = new PayParamBo();
|
|
|
+ // payDto -> payParam
|
|
|
+ BeanUtils.copyProperties(payVipDto, payParam);
|
|
|
+ //支付宝支付
|
|
|
+ payParam.setPayWay("ALIPAY");
|
|
|
+ payParam.setPayType("ALIPAY_H5");
|
|
|
+ // 获取会员套餐价格
|
|
|
+ Double price = payOrderMapper.getVipPackagePriceById(payParam.getVipId());
|
|
|
+ payParam.setPayAmount(MathUtil.mul(price, 100).intValue());
|
|
|
+ payParam.setNotifyUrl(superVipUrl);
|
|
|
+ log.info("【升级超级会员支付宝支付】>>>>>>>>>>>vipId:" + payParam.getVipId());
|
|
|
+ return toPaySuperVip(payParam, headers);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -342,7 +369,112 @@ public class PayNonOrderServiceImpl implements PayNonOrderService {
|
|
|
*/
|
|
|
@Override
|
|
|
public ResponseJson<JSONObject> paySuperVipByUnionPay(PayVipDto payVipDto, HttpHeaders headers) {
|
|
|
- return null;
|
|
|
+ PayParamBo payParam = new PayParamBo();
|
|
|
+ // payDto -> payParam
|
|
|
+ BeanUtils.copyProperties(payVipDto, payParam);
|
|
|
+ // 银联支付
|
|
|
+ payParam.setPayWay("UNIONPAY");
|
|
|
+ payParam.setPayType("GATEWAY_UNIONPAY");
|
|
|
+ // 获取会员套餐价格
|
|
|
+ Double price = payOrderMapper.getVipPackagePriceById(payParam.getVipId());
|
|
|
+ payParam.setPayAmount(MathUtil.mul(price, 100).intValue());
|
|
|
+ payParam.setNotifyUrl(superVipUrl);
|
|
|
+ log.info("【升级超级会员银联线上支付】>>>>>>>>>>>vipId:" + payParam.getVipId());
|
|
|
+ return toPaySuperVip(payParam, headers);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 升级超级会员支付
|
|
|
+ */
|
|
|
+ private ResponseJson<JSONObject> toPaySuperVip(PayParamBo payParam, HttpHeaders headers) {
|
|
|
+ // 定义支付请求结果
|
|
|
+ JSONObject result = null;
|
|
|
+ try {
|
|
|
+ // 时间戳
|
|
|
+ long time = System.currentTimeMillis() / 1000;
|
|
|
+ // 用户IP地址
|
|
|
+ String userIp = headers.getFirst("X-CLIENT-IP");
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
+ json.put("merAccount", PayUtil.merAccount);
|
|
|
+ json.put("merNo", PayUtil.merNo);
|
|
|
+ json.put("time", time);
|
|
|
+ //支付金额
|
|
|
+ json.put("amount", payParam.getPayAmount());
|
|
|
+ json.put("payWay", payParam.getPayWay());
|
|
|
+ json.put("payType", payParam.getPayType());
|
|
|
+ json.put("userIp", userIp);
|
|
|
+ json.put("returnUrl", payParam.getReturnUrl());
|
|
|
+ json.put("notifyUrl", payParam.getNotifyUrl());
|
|
|
+ if (StringUtils.isNotBlank(payParam.getBankCode())) {
|
|
|
+ json.put("bankCode", payParam.getBankCode());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(payParam.getUserType())) {
|
|
|
+ json.put("userType", payParam.getUserType());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(payParam.getOpenId())) {
|
|
|
+ json.put("openId", payParam.getOpenId());
|
|
|
+ }
|
|
|
+ String environment = "";
|
|
|
+ if (payParam.getNotifyUrl().contains("18002")) {
|
|
|
+ environment = "DEV";
|
|
|
+ } else if (payParam.getNotifyUrl().contains("core-b")) {
|
|
|
+ environment = "BETA";
|
|
|
+ }
|
|
|
+ // 商户订单号
|
|
|
+ String orderId = payParam.getUserId() + "V" + payParam.getVipId() + "T" + time + environment;
|
|
|
+ json.put("orderId", orderId);
|
|
|
+ //商品名称
|
|
|
+ String product = "采美订单" + orderId;
|
|
|
+ json.put("product", product);
|
|
|
+ String attach = payParam.getProductId() + "," + payParam.getPayType();
|
|
|
+ json.put("attach", attach);
|
|
|
+ // 升级超级会员默认私账
|
|
|
+ List<Map<String, String>> list = new ArrayList<>();
|
|
|
+ Map<String, String> map = new HashMap<>(3);
|
|
|
+ map.put("subUserNo", PayUtil.privateAccountNo);
|
|
|
+ map.put("splitBillType", "1");
|
|
|
+ map.put("splitBillValue", "1");
|
|
|
+ list.add(map);
|
|
|
+ String splitBillDetail = JSONObject.toJSONString(list);
|
|
|
+ json.put("splitBillDetail", splitBillDetail);
|
|
|
+ String sign = PayUtil.getPaySign(json, PayUtil.merKey);
|
|
|
+ json.put("sign", sign);
|
|
|
+ // 私钥加密
|
|
|
+ String data = RSAUtil.privateEncrypt(json.toJSONString(), PayUtil.merKey);
|
|
|
+ // 提交
|
|
|
+ result = PayUtil.httpGet("https://platform.mhxxkj.com/paygateway/mbpay/order/v1", PayUtil.merAccount, data);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("错误信息", e);
|
|
|
+ return ResponseJson.error("支付失败!", null);
|
|
|
+ }
|
|
|
+ String code = result.getString("code");
|
|
|
+ if (!"000000".equals(code)) {
|
|
|
+ String msg = result.getString("msg");
|
|
|
+ log.info("第三方支付失败>>>>>>>msg:" + msg);
|
|
|
+ return ResponseJson.error(msg, null);
|
|
|
+ }
|
|
|
+// // 保存二手发布分账参数
|
|
|
+// SplitAccountPo splitAccount = new SplitAccountPo();
|
|
|
+// splitAccount.setOrderId(payParam.getOrderId());
|
|
|
+// splitAccount.setProductId(payParam.getProductId());
|
|
|
+// // 二手交易供应商
|
|
|
+// splitAccount.setShopId(1252);
|
|
|
+// splitAccount.setProductType(4);
|
|
|
+// splitAccount.setType(2);
|
|
|
+// if ("UNIONPAY".equals(payParam.getPayWay())) {
|
|
|
+// splitAccount.setSplitAccount(92.00);
|
|
|
+// } else {
|
|
|
+// splitAccount.setSplitAccount(99.62);
|
|
|
+// }
|
|
|
+// JSONObject data = result.getJSONObject("data");
|
|
|
+// splitAccount.setMbOrderId(data.getString("mbOrderId"));
|
|
|
+// splitAccount.setOrderRequestNo(data.getString("orderId"));
|
|
|
+// splitAccount.setPayStatus(0);
|
|
|
+// // 保存分账详情
|
|
|
+// payOrderMapper.insertSplitAccount(splitAccount);
|
|
|
+
|
|
|
+ return ResponseJson.success(result);
|
|
|
}
|
|
|
|
|
|
/**
|