|
@@ -29,7 +29,6 @@ import org.springframework.http.HttpHeaders;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
-import java.math.BigDecimal;
|
|
|
|
import java.security.NoSuchAlgorithmException;
|
|
import java.security.NoSuchAlgorithmException;
|
|
import java.security.spec.InvalidKeySpecException;
|
|
import java.security.spec.InvalidKeySpecException;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
@@ -58,6 +57,8 @@ public class PayNonOrderServiceImpl implements PayNonOrderService {
|
|
private String secondHandUrl;
|
|
private String secondHandUrl;
|
|
@Value("${pay.vip-notify-url}")
|
|
@Value("${pay.vip-notify-url}")
|
|
private String superVipUrl;
|
|
private String superVipUrl;
|
|
|
|
+ @Value("${pay.auth-vip-notify-url}")
|
|
|
|
+ private String authVipUrl;
|
|
@Value("${pay.coupon-notify-url}")
|
|
@Value("${pay.coupon-notify-url}")
|
|
private String couponUrl;
|
|
private String couponUrl;
|
|
@Resource
|
|
@Resource
|
|
@@ -1040,4 +1041,415 @@ public class PayNonOrderServiceImpl implements PayNonOrderService {
|
|
payOrderMapper.updateSplitAccountByPay(mbOrderId);
|
|
payOrderMapper.updateSplitAccountByPay(mbOrderId);
|
|
return "SUCCESS";
|
|
return "SUCCESS";
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 开通认证通会员-微信线上支付
|
|
|
|
+ *
|
|
|
|
+ * @param payVipDto {
|
|
|
|
+ * vipRecordId 会员购买记录Id
|
|
|
|
+ * returnUrl 页面回调地址
|
|
|
|
+ * code 微信小程序code
|
|
|
|
+ * state 微信公众号state参数
|
|
|
|
+ * }
|
|
|
|
+ * @param headers
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public ResponseJson<JSONObject> payAuthVipByWeChat(PayVipDto payVipDto, HttpHeaders headers) {
|
|
|
|
+ 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();
|
|
|
|
+ // 获取会员套餐记录
|
|
|
|
+ VipRecordBo record = payOrderMapper.getAuthVipRecord(payParam.getVipRecordId());
|
|
|
|
+ if (null == record) {
|
|
|
|
+ log.info("【开通认证通会员-微信线上支付】该笔记录异常,记录Id:" + payParam.getVipRecordId());
|
|
|
|
+ return ResponseJson.error("该笔记录异常!", null);
|
|
|
|
+ }
|
|
|
|
+ if (null != record.getPayStatus() && 1 == record.getPayStatus()) {
|
|
|
|
+ return ResponseJson.error("该笔记录已支付,请勿重复支付!", null);
|
|
|
|
+ }
|
|
|
|
+ payParam.setVipId(record.getPackageId());
|
|
|
|
+ payParam.setUserId(record.getUserId());
|
|
|
|
+ // 获取会员套餐价格
|
|
|
|
+ Double price = payOrderMapper.getAuthVipPackagePrice(record.getPackageId());
|
|
|
|
+ payParam.setPayAmount(MathUtil.mul(price, 100).intValue());
|
|
|
|
+ payParam.setNotifyUrl(authVipUrl);
|
|
|
|
+ log.info("【开通认证通会员微信支付】>>>>>>>>>>>vipRecordId:" + payParam.getVipRecordId() + ",获取openId:" + payParam.getOpenId());
|
|
|
|
+ return toPayAuthVip(payParam, headers);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 开通认证通会员-支付宝线上支付
|
|
|
|
+ *
|
|
|
|
+ * @param payVipDto {
|
|
|
|
+ * vipRecordId 会员购买记录Id
|
|
|
|
+ * returnUrl 页面回调地址
|
|
|
|
+ * }
|
|
|
|
+ * @param headers
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public ResponseJson<JSONObject> payAuthVipByAlipay(PayVipDto payVipDto, HttpHeaders headers) {
|
|
|
|
+ PayParamBo payParam = new PayParamBo();
|
|
|
|
+ // payDto -> payParam
|
|
|
|
+ BeanUtils.copyProperties(payVipDto, payParam);
|
|
|
|
+ //支付宝支付
|
|
|
|
+ payParam.setPayWay("ALIPAY");
|
|
|
|
+ payParam.setPayType("ALIPAY_H5");
|
|
|
|
+ // 获取会员套餐记录
|
|
|
|
+ VipRecordBo record = payOrderMapper.getAuthVipRecord(payParam.getVipRecordId());
|
|
|
|
+ if (null != record.getPayStatus() && 1 == record.getPayStatus()) {
|
|
|
|
+ return ResponseJson.error("该笔记录已支付,请勿重复支付!", null);
|
|
|
|
+ }
|
|
|
|
+ payParam.setVipId(record.getPackageId());
|
|
|
|
+ payParam.setUserId(record.getUserId());
|
|
|
|
+ // 获取会员套餐价格
|
|
|
|
+ Double price = payOrderMapper.getAuthVipPackagePrice(record.getPackageId());
|
|
|
|
+ payParam.setPayAmount(MathUtil.mul(price, 100).intValue());
|
|
|
|
+ payParam.setNotifyUrl(authVipUrl);
|
|
|
|
+ log.info("【开通认证通会员支付宝支付】>>>>>>>>>>>vipRecordId:" + payParam.getVipRecordId());
|
|
|
|
+ return toPayAuthVip(payParam, headers);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 开通认证通会员-银联线上支付
|
|
|
|
+ *
|
|
|
|
+ * @param payVipDto {
|
|
|
|
+ * vipRecordId 会员购买记录Id
|
|
|
|
+ * returnUrl 页面回调地址
|
|
|
|
+ * bankCode 银行编码(银联支付使用)
|
|
|
|
+ * userType 用户类型(银联支付使用)企业:ENTERPRISE,个人:USER
|
|
|
|
+ * }
|
|
|
|
+ * @param headers
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public ResponseJson<JSONObject> payAuthVipByUnionPay(PayVipDto payVipDto, HttpHeaders headers) {
|
|
|
|
+ PayParamBo payParam = new PayParamBo();
|
|
|
|
+ // payDto -> payParam
|
|
|
|
+ BeanUtils.copyProperties(payVipDto, payParam);
|
|
|
|
+ // 银联支付
|
|
|
|
+ payParam.setPayWay("UNIONPAY");
|
|
|
|
+ payParam.setPayType("GATEWAY_UNIONPAY");
|
|
|
|
+ // 获取会员套餐记录
|
|
|
|
+ VipRecordBo record = payOrderMapper.getAuthVipRecord(payParam.getVipRecordId());
|
|
|
|
+ if (null != record.getPayStatus() && 1 == record.getPayStatus()) {
|
|
|
|
+ return ResponseJson.error("该笔记录已支付,请勿重复支付!", null);
|
|
|
|
+ }
|
|
|
|
+ payParam.setVipId(record.getPackageId());
|
|
|
|
+ payParam.setUserId(record.getUserId());
|
|
|
|
+ // 获取会员套餐价格
|
|
|
|
+ Double price = payOrderMapper.getAuthVipPackagePrice(record.getPackageId());
|
|
|
|
+ payParam.setPayAmount(MathUtil.mul(price, 100).intValue());
|
|
|
|
+ payParam.setNotifyUrl(authVipUrl);
|
|
|
|
+ log.info("【开通认证通会员银联线上支付】>>>>>>>>>>>vipRecordId:" + payParam.getVipRecordId());
|
|
|
|
+ return toPayAuthVip(payParam, headers);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 开通认证通会员支付
|
|
|
|
+ */
|
|
|
|
+ private ResponseJson<JSONObject> toPayAuthVip(PayParamBo payParam, HttpHeaders headers) {
|
|
|
|
+ // 定义支付请求结果
|
|
|
|
+ JSONObject result = null;
|
|
|
|
+ try {
|
|
|
|
+ // 时间戳
|
|
|
|
+ long time = System.currentTimeMillis() / 1000;
|
|
|
|
+ // 设置支付基础参数
|
|
|
|
+ JSONObject json = getPayJsonObject(payParam, headers, time);
|
|
|
|
+ // 支付环境
|
|
|
|
+ String environment = "";
|
|
|
|
+ if (payParam.getNotifyUrl().contains("18002")) {
|
|
|
|
+ environment = "DEV";
|
|
|
|
+ } else if (payParam.getNotifyUrl().contains("core-b")) {
|
|
|
|
+ environment = "BETA";
|
|
|
|
+ }
|
|
|
|
+ // 商户订单号
|
|
|
|
+ String orderId = payParam.getUserId() + "R" + payParam.getVipRecordId() + "V" + payParam.getVipId() + "T" + time + environment;
|
|
|
|
+ json.put("orderId", orderId);
|
|
|
|
+ //商品名称
|
|
|
|
+ String product = "采美订单" + orderId;
|
|
|
|
+ json.put("product", product);
|
|
|
|
+ //支付类型
|
|
|
|
+ String payType = PayUtil.getPayTypeId(payParam.getPayType(), payParam.getUserType());
|
|
|
|
+ String attach = payParam.getVipId() + "," + payParam.getUserId() + "," + payParam.getVipRecordId() + "," + payType;
|
|
|
|
+ json.put("attach", attach);
|
|
|
|
+ // 开通认证通会员默认公账
|
|
|
|
+ List<Map<String, String>> list = new ArrayList<>();
|
|
|
|
+ Map<String, String> map = new HashMap<>(3);
|
|
|
|
+ map.put("subUserNo", PayUtil.publicAccountNo);
|
|
|
|
+ // 1按比例分账
|
|
|
|
+ map.put("splitBillType", "1");
|
|
|
|
+ // 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);
|
|
|
|
+ }
|
|
|
|
+ // 保存开通认证通会员分账参数
|
|
|
|
+ JSONObject data = result.getJSONObject("data");
|
|
|
|
+ SplitAccountPo splitAccount = new SplitAccountPo();
|
|
|
|
+ splitAccount.setAuthVipRecordId(payParam.getVipRecordId());
|
|
|
|
+ // 认证通会员 公账-专票
|
|
|
|
+ splitAccount.setType(1);
|
|
|
|
+ // 待分账总金额
|
|
|
|
+ double splitAmount = MathUtil.div(payParam.getPayAmount(), 100).doubleValue();
|
|
|
|
+ // 总手续费
|
|
|
|
+ double procedureFee;
|
|
|
|
+ if ("UNIONPAY".equals(payParam.getPayWay())) {
|
|
|
|
+ procedureFee = 8.00;
|
|
|
|
+ } else {
|
|
|
|
+ //手续费
|
|
|
|
+ procedureFee = MathUtil.mul(splitAmount, 0.0038, 2).doubleValue();
|
|
|
|
+ if (MathUtil.compare(procedureFee, 0) == 0) {
|
|
|
|
+ procedureFee = 0.01;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ splitAmount = MathUtil.sub(splitAmount, procedureFee).doubleValue();
|
|
|
|
+ splitAccount.setSplitAccount(splitAmount);
|
|
|
|
+ splitAccount.setMbOrderId(data.getString("mbOrderId"));
|
|
|
|
+ splitAccount.setOrderRequestNo(data.getString("orderId"));
|
|
|
|
+ splitAccount.setPayStatus(0);
|
|
|
|
+ // 保存分账详情
|
|
|
|
+ payOrderMapper.insertSplitAccount(splitAccount);
|
|
|
|
+ log.info("【开通认证通会员支付成功!】>>>>>>>>>>>vipRecordId:" + payParam.getVipRecordId() + ",data:" + data.toJSONString());
|
|
|
|
+ return ResponseJson.success(result);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 开通认证通会员-支付回调
|
|
|
|
+ *
|
|
|
|
+ * @param data
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public String paymentAuthVipCallback(String data) throws NoSuchAlgorithmException, InvalidKeySpecException {
|
|
|
|
+ log.info("******************** 开通认证通会员异步回调 start *******************");
|
|
|
|
+ // 公钥解密
|
|
|
|
+ JSONObject json = PayUtil.publicKeyDecrypt(data, PayUtil.publicKey);
|
|
|
|
+ log.info("【开通认证通会员异步回调】>>>>>>>>>>>公钥解密:" + json);
|
|
|
|
+ // 公钥验签
|
|
|
|
+ String signaa = json.getString("sign");
|
|
|
|
+ json.remove("sign");
|
|
|
|
+ String signbb = PayUtil.getPaySign(json, PayUtil.publicKey);
|
|
|
|
+ if (!signaa.equals(signbb)) {
|
|
|
|
+ return "验签失败";
|
|
|
|
+ }
|
|
|
|
+ // 订单状态
|
|
|
|
+ String orderStatus = json.getString("orderStatus");
|
|
|
|
+ // 平台唯一流水号
|
|
|
|
+ String mbOrderId = json.getString("mbOrderId");
|
|
|
|
+ // 商户唯一订单号
|
|
|
|
+ String orderRequestNo = json.getString("orderId");
|
|
|
|
+ // 金额,以元为单位
|
|
|
|
+ Double amount = json.getDouble("amount");
|
|
|
|
+ String payFormData = json.toJSONString();
|
|
|
|
+ log.info("【开通认证通会员异步回调】>>>>>>>>>>>支付订单状态:" + orderStatus);
|
|
|
|
+ if ("FAILED".equals(orderStatus)) {
|
|
|
|
+ return "支付失败";
|
|
|
|
+ }
|
|
|
|
+ log.info("【开通认证通会员异步回调】>>>>>>>>>>>>>>本次支付金额:" + amount);
|
|
|
|
+ // 附加数据,支付时若有传输则原样返回(vipId,userId,recordId,payType),下单时为空,则不返回该数据
|
|
|
|
+ String attach = json.getString("attach");
|
|
|
|
+ String[] split = attach.split(",");
|
|
|
|
+ int vipId = 0;
|
|
|
|
+ int userId = 0;
|
|
|
|
+ int recordId = 0;
|
|
|
|
+ int payType = 0;
|
|
|
|
+ try {
|
|
|
|
+ // 会员套餐Id
|
|
|
|
+ vipId = Integer.parseInt(split[0]);
|
|
|
|
+ // 用户Id
|
|
|
|
+ userId = Integer.parseInt(split[1]);
|
|
|
|
+ // 购买历史记录Id
|
|
|
|
+ recordId = Integer.parseInt(split[2]);
|
|
|
|
+ // 支付方式
|
|
|
|
+ payType = Integer.parseInt(split[3]);
|
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
|
+ log.info("【开通认证通会员异步回调】>>>>>>>>>>>>>>获取回调参数解析失败!");
|
|
|
|
+ }
|
|
|
|
+ //认证通会员数据库修改
|
|
|
|
+ UserVipPo authVip = new UserVipPo();
|
|
|
|
+ UserVipPo dbAuthVip = payOrderMapper.getAuthVipInfo(userId);
|
|
|
|
+ Date beginTime = new Date();
|
|
|
|
+ if (null != dbAuthVip) {
|
|
|
|
+ authVip.setId(dbAuthVip.getId());
|
|
|
|
+ if (dbAuthVip.getEndTime().compareTo(beginTime) > 0) {
|
|
|
|
+ // 有效期内续费,用原结束时间作为开始时间来计算结束时间
|
|
|
|
+ beginTime = dbAuthVip.getEndTime();
|
|
|
|
+ authVip.setBeginTime(beginTime);
|
|
|
|
+ } else {
|
|
|
|
+ // 过期重新续费
|
|
|
|
+ authVip.setBeginTime(beginTime);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ authVip.setBeginTime(beginTime);
|
|
|
|
+ }
|
|
|
|
+ authVip.setUserId(userId);
|
|
|
|
+ authVip.setUpdateTime(new Date());
|
|
|
|
+ Calendar cal = Calendar.getInstance();
|
|
|
|
+ cal.setTime(beginTime);
|
|
|
|
+ // 查询认证通会员套餐信息
|
|
|
|
+ AuthVipPackagePo packagePo = payOrderMapper.getAuthVipPackageById(vipId);
|
|
|
|
+ cal.add(1 == packagePo.getUnit() ? Calendar.MONTH : Calendar.YEAR, packagePo.getDuration());
|
|
|
|
+ authVip.setEndTime(cal.getTime());
|
|
|
|
+ authVip.setDelFlag(0);
|
|
|
|
+ if (null != authVip.getId()) {
|
|
|
|
+ // 更新会员信息
|
|
|
|
+ payOrderMapper.updateAuthVipInfo(authVip);
|
|
|
|
+ if (authVip.getBeginTime().compareTo(beginTime) >= 0) {
|
|
|
|
+ // 删除原有角色关联
|
|
|
|
+ payOrderMapper.deleteAuthVipRoleRelation(userId);
|
|
|
|
+ // 会员过期重新分配角色
|
|
|
|
+ saveRoleRelation(userId, "1");
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ // 新增会员信息
|
|
|
|
+ payOrderMapper.insertAuthVipInfo(authVip);
|
|
|
|
+ // 删除原有角色关联
|
|
|
|
+ payOrderMapper.deleteAuthVipRoleRelation(userId);
|
|
|
|
+ // 分配角色
|
|
|
|
+ saveRoleRelation(userId, "1");
|
|
|
|
+ }
|
|
|
|
+ // 修改会员历史记录支付状态
|
|
|
|
+ VipRecordBo record = payOrderMapper.getAuthVipRecord(recordId);
|
|
|
|
+ record.setPayStatus(1);
|
|
|
|
+ record.setBeginTime(beginTime);
|
|
|
|
+ record.setEndTime(cal.getTime());
|
|
|
|
+ record.setPayWay(1);
|
|
|
|
+ record.setPayType(payType);
|
|
|
|
+ record.setPayTime(new Date());
|
|
|
|
+ payOrderMapper.updateAuthVipRecord(record);
|
|
|
|
+ // 修改支付链接状态
|
|
|
|
+ OrderPayLinkVo orderPayLink = payOrderMapper.getAuthVipPayLink(recordId, amount);
|
|
|
|
+ if (null != orderPayLink && (12 == payType || 17 == payType)) {
|
|
|
|
+ orderPayLink.setPayStatus(1);
|
|
|
|
+ payOrderMapper.updateOrderPayLinkStatus(orderPayLink);
|
|
|
|
+ }
|
|
|
|
+ Date date = new Date();
|
|
|
|
+ String curDateStr = (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(date);
|
|
|
|
+ // 保存收款记录
|
|
|
|
+ DiscernReceiptPo discernReceipt = new DiscernReceiptPo();
|
|
|
|
+ discernReceipt.setPayWay(1);
|
|
|
|
+ discernReceipt.setPayType(record.getPayType());
|
|
|
|
+ discernReceipt.setReceiptType(9);
|
|
|
|
+ discernReceipt.setReceiptStatus(3);
|
|
|
|
+ discernReceipt.setReceiptAmount(amount);
|
|
|
|
+ discernReceipt.setConfirmType(4);
|
|
|
|
+ discernReceipt.setRePayFlag(1);
|
|
|
|
+ discernReceipt.setFormData(payFormData);
|
|
|
|
+ discernReceipt.setReceiptDate(curDateStr);
|
|
|
|
+ discernReceipt.setConfirmDate(curDateStr);
|
|
|
|
+ discernReceipt.setReviewDate(curDateStr);
|
|
|
|
+ discernReceipt.setUpdateDate(curDateStr);
|
|
|
|
+ discernReceipt.setDelFlag(0);
|
|
|
|
+ // 保存 收款记录
|
|
|
|
+ baseMapper.insertDiscernReceipt(discernReceipt);
|
|
|
|
+ log.info("【开通认证通会员异步回调】>>>>>>>>>>>>>>保存识别款项(insert[cm_discern_receipt])id:" + discernReceipt.getId() + ",vipRecordId:" + recordId);
|
|
|
|
+ // 收款项和订单关系表
|
|
|
|
+ OrderReceiptRelationPo relation = new OrderReceiptRelationPo();
|
|
|
|
+ relation.setReceiptId(discernReceipt.getId());
|
|
|
|
+ relation.setAuthVipRecordId(recordId);
|
|
|
|
+ relation.setAssociateAmount(amount);
|
|
|
|
+ relation.setMbOrderId(mbOrderId);
|
|
|
|
+ relation.setOrderRequestNo(orderRequestNo);
|
|
|
|
+ relation.setSplitStatus(1);
|
|
|
|
+ relation.setRelationType(3);
|
|
|
|
+ relation.setDelFlag(0);
|
|
|
|
+ // 保存 收款项和订单关系
|
|
|
|
+ baseMapper.insertOrderReceiptRelation(relation);
|
|
|
|
+ log.info("【开通认证通会员异步回调】>>>>>>>>>>>收款项和购买历史关系(insert[cm_receipt_order_relation])id:" + relation.getId() + ",vipRecordId:" + recordId);
|
|
|
|
+ //修改分账付款状态
|
|
|
|
+ payOrderMapper.updateSplitAccountByPay(mbOrderId);
|
|
|
|
+ return "SUCCESS";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 开通认证通会员-线上退款
|
|
|
|
+ *
|
|
|
|
+ * @param payVipDto {
|
|
|
|
+ * vipRecordId 会员购买记录Id
|
|
|
|
+ * code 退款口令
|
|
|
|
+ * }
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public ResponseJson<JSONObject> authVipOnlineRefund(PayVipDto payVipDto) throws NoSuchAlgorithmException, InvalidKeySpecException {
|
|
|
|
+ // 认证通会员支付记录
|
|
|
|
+ DiscernReceiptVo discernReceipt = orderCommonMapper.getVipDiscernReceipt(payVipDto.getVipRecordId());
|
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
|
+ json.put("merAccount", PayUtil.merAccount);
|
|
|
|
+ // 当前时间戳
|
|
|
|
+ long time = System.currentTimeMillis() / 1000;
|
|
|
|
+ json.put("time", time);
|
|
|
|
+ //商户退款流水号,由商户自行生成,必须唯一
|
|
|
|
+ String randomLetter = CodeUtil.randomLetter(6);
|
|
|
|
+ String merchantRefundNo = payVipDto.getVipRecordId() + payVipDto.getCode() + randomLetter + "##" + discernReceipt.getId();
|
|
|
|
+ json.put("merchantRefundNo", merchantRefundNo);
|
|
|
|
+ //退款金额,单位分,必须大于0
|
|
|
|
+ double refundAmt = MathUtil.mul(discernReceipt.getAssociateAmount(), 100).doubleValue();
|
|
|
|
+ json.put("refundAmt", refundAmt);
|
|
|
|
+ //退款原因
|
|
|
|
+ String refundCause = "用户主动退款";
|
|
|
|
+ json.put("refundCause", refundCause);
|
|
|
|
+ //平台交易订单号
|
|
|
|
+ json.put("mbOrderId", discernReceipt.getMbOrderId());
|
|
|
|
+ String sign = PayUtil.getPaySign(json, PayUtil.merKey);
|
|
|
|
+ json.put("sign", sign);
|
|
|
|
+ String data = PayUtil.privateKeyEncrypt(json, PayUtil.merKey);
|
|
|
|
+ JSONObject result = PayUtil.httpPost("https://platform.mhxxkj.com/paygateway/mbrefund/orderRefund/v1", PayUtil.merAccount, data);
|
|
|
|
+ String code = result.getString("code");
|
|
|
|
+ if (!"000000".equals(code)) {
|
|
|
|
+ String msg = result.getString("msg");
|
|
|
|
+ log.info("【线上退款】失败>>>>>>>msg:" + msg);
|
|
|
|
+ return ResponseJson.error(result);
|
|
|
|
+ }
|
|
|
|
+ log.info("【线上退款】成功>>>>>>>vipRecordId:" + payVipDto.getVipRecordId());
|
|
|
|
+ return ResponseJson.success(result);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public ResponseJson<Map<String,Map<String,String>>> authVipCheck(Integer vipRecordId) {
|
|
|
|
+ // 获取会员套餐记录
|
|
|
|
+ VipRecordBo record = payOrderMapper.getAuthVipRecord(vipRecordId);
|
|
|
|
+ Map<String, Map<String,String>> map1 = new HashMap<>();
|
|
|
|
+ Map<String, String> map2 = new HashMap<>();
|
|
|
|
+ if (null != record.getPayStatus() && 1 == record.getPayStatus()) {
|
|
|
|
+ map2.put("status", "1");
|
|
|
|
+ map1.put("data", map2);
|
|
|
|
+ return ResponseJson.success("支付成功!", map1);
|
|
|
|
+ }
|
|
|
|
+ map2.put("status", "0");
|
|
|
|
+ map1.put("data", map2);
|
|
|
|
+ return ResponseJson.success("支付失败", map1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void saveRoleRelation(Integer userId, String roleIds) {
|
|
|
|
+ if (StringUtils.isNotEmpty(roleIds)) {
|
|
|
|
+ // 设置用户角色
|
|
|
|
+ String[] split = roleIds.split(",");
|
|
|
|
+ for (String s : split) {
|
|
|
|
+ if (org.springframework.util.StringUtils.hasLength(s)) {
|
|
|
|
+ // 保存用户角色关系
|
|
|
|
+ payOrderMapper.insertAuthVipRoleRelation(userId, Integer.valueOf(s));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|