|
@@ -1434,5 +1434,536 @@ public class HeliPayNonOrderServiceImpl implements HeliPayNonOrderService {
|
|
|
return ResponseJson.error("支付失败", null);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public ResponseJson<String> authVipUnionPay(HeliDto heliDto, HttpHeaders headers) {
|
|
|
+ VipRecordBo record = payOrderMapper.getAuthVipRecord(heliDto.getVipRecordId());
|
|
|
+ if (null != record.getPayStatus() && 1 == record.getPayStatus()) {
|
|
|
+ return ResponseJson.error("该笔记录已支付,请勿重复支付!", null);
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ log.info("--------进入认证通会员网银线上支付接口----------");
|
|
|
+ HeliOnlineVo heliOnlineVo = new HeliOnlineVo();
|
|
|
+ heliPayUtil.setLinkValue(heliOnlineVo, heliDto, "authVip", headers);
|
|
|
+ Map<String, String> map = MyBeanUtils.convertBean(heliOnlineVo, new LinkedHashMap());
|
|
|
+ String oriMessage = MyBeanUtils.getSignedByPresetParameter(map, HeliOnlineVo.NEED_SIGN_PARAMS);
|
|
|
+ oriMessage += SPLIT + Constant.WANGYIN;
|
|
|
+ String sign = Disguiser.disguiseMD5(oriMessage.trim());
|
|
|
+ Map<String, String> sPara = new HashMap<String, String>();
|
|
|
+ sPara.put("P1_bizType", heliOnlineVo.getP1_bizType());
|
|
|
+ sPara.put("P2_orderId", heliOnlineVo.getP2_orderId());
|
|
|
+ sPara.put("P3_customerNumber", heliOnlineVo.getP3_customerNumber());
|
|
|
+ sPara.put("P4_orderAmount", heliOnlineVo.getP4_orderAmount());
|
|
|
+ sPara.put("P5_bankId", heliOnlineVo.getP5_bankId());
|
|
|
+ sPara.put("P6_business", heliOnlineVo.getP6_business());
|
|
|
+ sPara.put("P7_timestamp", heliOnlineVo.getP7_timestamp());
|
|
|
+ sPara.put("P8_goodsName", heliOnlineVo.getP8_goodsName());
|
|
|
+ sPara.put("P9_period", heliOnlineVo.getP9_period());
|
|
|
+ sPara.put("P10_periodUnit", heliOnlineVo.getP10_periodUnit());
|
|
|
+ sPara.put("P11_callbackUrl", heliOnlineVo.getP11_callbackUrl());
|
|
|
+ sPara.put("P12_serverCallbackUrl", heliOnlineVo.getP12_serverCallback());
|
|
|
+ sPara.put("P13_orderIp", heliOnlineVo.getP13_orderIp());
|
|
|
+ sPara.put("P14_onlineCardType", heliOnlineVo.getP14_onlineCardType());
|
|
|
+ sPara.put("P15_desc", heliOnlineVo.getP15_desc());
|
|
|
+ sPara.put("sign", sign);
|
|
|
+ StringBuffer sbHtml = new StringBuffer();
|
|
|
+ List<String> keys = new ArrayList<String>(sPara.keySet());
|
|
|
+ // post方式传递
|
|
|
+ sbHtml.append("<form id=\"onlineForm\" name=\"onlineForm\" action=\"").append(YL).append("\" method=\"post\">");
|
|
|
+ String name = "";
|
|
|
+ String value = "";
|
|
|
+ for (int i = 0; i < keys.size(); i++) {
|
|
|
+ name = (String) keys.get(i);
|
|
|
+ value = (String) sPara.get(name);
|
|
|
+ if (value != null && !"".equals(value)) {
|
|
|
+ sbHtml.append("<input type=\"hidden\" name=\"").append(name).append("\" value=\"" + value + "\"/>");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //submit按钮控件请不要含有name属性
|
|
|
+ sbHtml.append("<input type=\"submit\" value=\"确认付款\"></form>");
|
|
|
+
|
|
|
+ // 保存开通认证通会员分账参数
|
|
|
+ SplitAccountPo splitAccount = new SplitAccountPo();
|
|
|
+ splitAccount.setAuthVipRecordId(heliDto.getVipRecordId());
|
|
|
+ // 超级会员 公账-专票
|
|
|
+ splitAccount.setType(1);
|
|
|
+ // 待分账总金额
|
|
|
+ Double splitAmount = Double.valueOf(heliOnlineVo.getP4_orderAmount());
|
|
|
+ //b2b10块 b2c0.2%
|
|
|
+ if ("B2B".equals(heliDto.getUserType())) {
|
|
|
+ splitAmount = MathUtil.sub(splitAmount, 10).doubleValue();
|
|
|
+ } else {
|
|
|
+ splitAmount = MathUtil.mul(splitAmount, 0.998).doubleValue();
|
|
|
+ }
|
|
|
+ splitAccount.setSplitAccount(splitAmount);
|
|
|
+ //流水号暂存唯一订单id
|
|
|
+ splitAccount.setMbOrderId(heliOnlineVo.getP2_orderId());
|
|
|
+ splitAccount.setOrderRequestNo(heliOnlineVo.getP2_orderId());
|
|
|
+ splitAccount.setPayStatus(0);
|
|
|
+ // 保存分账详情
|
|
|
+ payOrderMapper.insertSplitAccount(splitAccount);
|
|
|
+ return ResponseJson.success(sbHtml.toString());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("错误信息", e);
|
|
|
+ return ResponseJson.error("支付失败!", null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseJson<JSONObject> payAuthVipByWeChat(HeliDto heliDto, HttpHeaders headers) {
|
|
|
+ log.info("--------进入认证通会员公众号/小程序预创建订单接口----------");
|
|
|
+ try {
|
|
|
+ AppPayPublicCreateOrderVo pay = new AppPayPublicCreateOrderVo();
|
|
|
+ //微信给openid
|
|
|
+ if ("GZX".equals(heliDto.getPayType()) || "XCX".equals(heliDto.getPayType())) {
|
|
|
+ PayParamBo tempParam = new PayParamBo();
|
|
|
+ BeanUtils.copyProperties(heliDto, tempParam);
|
|
|
+ ResponseJson<PayParamBo> jsonParam = getWeChatResponseJson(tempParam, headers);
|
|
|
+ if (-1 == jsonParam.getCode()) {
|
|
|
+ return ResponseJson.error(jsonParam.getMsg(), null);
|
|
|
+ }
|
|
|
+ PayParamBo payParam = jsonParam.getData();
|
|
|
+ pay.setP8_openid(payParam.getOpenId());
|
|
|
+ }
|
|
|
+ // 获取会员套餐记录
|
|
|
+ VipRecordBo record = payOrderMapper.getAuthVipRecord(heliDto.getVipRecordId());
|
|
|
+ if (null == record) {
|
|
|
+ log.info("【开通认证通会员-微信线上支付】该笔记录异常,记录Id:" + heliDto.getVipRecordId());
|
|
|
+ return ResponseJson.error("该笔记录异常!", null);
|
|
|
+ }
|
|
|
+ if (null != record.getPayStatus() && 1 == record.getPayStatus()) {
|
|
|
+ return ResponseJson.error("该笔记录已支付,请勿重复支付!", null);
|
|
|
+ }
|
|
|
+ //合利宝接口参数赋值
|
|
|
+ heliPayUtil.setOnlineValue(pay, heliDto, "authVip", headers);
|
|
|
+ Map<String, String> map = MyBeanUtils.convertBean(pay, new LinkedHashMap());
|
|
|
+ String oriMessage = MyBeanUtils.getSignedByPresetParameter(map, AppPayPublicCreateOrderVo.NEED_SIGN_PARAMS);
|
|
|
+ oriMessage += Constant.SPLIT + Constant.SAOMA;
|
|
|
+ log.info("签名原文串:" + oriMessage);
|
|
|
+ String sign = Disguiser.disguiseMD5(oriMessage.trim());
|
|
|
+ log.info("签名串:" + sign);
|
|
|
+ map.put("sign", sign);
|
|
|
+ log.info("发送参数:" + map);
|
|
|
+ Map<String, Object> resultMap = HttpClientService.getHttpResp(map, Constant.REQUEST_URL);
|
|
|
+ log.info("响应结果:" + resultMap);
|
|
|
+ if ((Integer) resultMap.get("statusCode") == HttpStatus.SC_OK) {
|
|
|
+ String resultMsg = (String) resultMap.get("response");
|
|
|
+ AppPayPublicOrderResponseVo orderResponseVo = JSONObject.parseObject(resultMsg, AppPayPublicOrderResponseVo.class);
|
|
|
+ String assemblyRespOriSign = MyBeanUtils.getSignedByPresetParameter(orderResponseVo, AppPayPublicOrderResponseVo.NEED_SIGN_PARAMS);
|
|
|
+ log.info("组装返回结果签名串:" + assemblyRespOriSign);
|
|
|
+ assemblyRespOriSign += Constant.SPLIT + Constant.SAOMA;
|
|
|
+ String responseSign = orderResponseVo.getSign();
|
|
|
+ log.info("响应签名:" + responseSign);
|
|
|
+ String checkSign = Disguiser.disguiseMD5(assemblyRespOriSign.trim());
|
|
|
+ if (checkSign.equals(responseSign) && "0000".equals(orderResponseVo.getRt2_retCode())) {
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(resultMsg);
|
|
|
+ // 保存开通认证通会员分账参数
|
|
|
+ SplitAccountPo splitAccount = new SplitAccountPo();
|
|
|
+ splitAccount.setAuthVipRecordId(heliDto.getVipRecordId());
|
|
|
+ // 超级会员 公账-专票
|
|
|
+ splitAccount.setType(1);
|
|
|
+ // 待分账总金额
|
|
|
+ double splitAmount = record.getPrice();
|
|
|
+ // 总手续费
|
|
|
+ double procedureFee;
|
|
|
+ //手续费
|
|
|
+ procedureFee = MathUtil.mul(splitAmount, 0.0025, 2).doubleValue();
|
|
|
+ if (MathUtil.compare(procedureFee, 0) == 0) {
|
|
|
+ procedureFee = 0.01;
|
|
|
+ }
|
|
|
+ splitAmount = MathUtil.sub(splitAmount, procedureFee).doubleValue();
|
|
|
+ splitAccount.setSplitAccount(splitAmount);
|
|
|
+ splitAccount.setMbOrderId(orderResponseVo.getRt6_serialNumber());
|
|
|
+ splitAccount.setOrderRequestNo(orderResponseVo.getRt5_orderId());
|
|
|
+ splitAccount.setPayStatus(0);
|
|
|
+ // 保存分账详情
|
|
|
+ payOrderMapper.insertSplitAccount(splitAccount);
|
|
|
+ return ResponseJson.success("请求成功", jsonObject);
|
|
|
+ } else {
|
|
|
+ return ResponseJson.error("支付请求失败", JSONObject.parseObject(resultMsg));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return ResponseJson.error("请求失败", null);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("交易失败" + e);
|
|
|
+ return ResponseJson.error("交易失败", null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseJson<JSONObject> payAuthVipByAlipay(HeliDto heliDto, HttpHeaders headers) {
|
|
|
+ // 获取会员套餐记录
|
|
|
+ VipRecordBo record = payOrderMapper.getAuthVipRecord(heliDto.getVipRecordId());
|
|
|
+ if (null != record.getPayStatus() && 1 == record.getPayStatus()) {
|
|
|
+ return ResponseJson.error("该笔记录已支付,请勿重复支付!", null);
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ AppCreateOrderVo pay = new AppCreateOrderVo();
|
|
|
+ //合利宝主扫接口参数赋值
|
|
|
+ heliPayUtil.setValue(pay, heliDto, "authVip", headers);
|
|
|
+ if (!(StringUtils.equals(AppPayType.ALIPAY.name(), pay.getP8_appType())
|
|
|
+ && StringUtils.equals(PayType.SWIPE.name(), pay.getP4_payType()))) {
|
|
|
+ pay.setOpenId(null);
|
|
|
+ pay.setAuthConfirmMode(null);
|
|
|
+ }
|
|
|
+ Map<String, String> map = MyBeanUtils.convertBean(pay, new LinkedHashMap());
|
|
|
+ String oriMessage = MyBeanUtils.getSignedByPresetParameter(map, AppCreateOrderVo.NEED_SIGN_PARAMS);
|
|
|
+ //密钥拼接
|
|
|
+ oriMessage += Constant.SPLIT + Constant.SAOMA;
|
|
|
+ log.info("签名原文串:" + oriMessage);
|
|
|
+ String sign = Disguiser.disguiseMD5(oriMessage.trim());
|
|
|
+ log.info("签名串:" + sign);
|
|
|
+ map.put("sign", sign);
|
|
|
+ log.info("发送参数:" + map);
|
|
|
+ Map<String, Object> resultMap = HttpClientService.getHttpResp(map, Constant.REQUEST_URL);
|
|
|
+ log.info("响应结果:" + resultMap);
|
|
|
+ if ((Integer) resultMap.get("statusCode") == HttpStatus.SC_OK) {
|
|
|
+ String resultMsg = (String) resultMap.get("response");
|
|
|
+ AppCreateOrderResponseVo orderResponseVo = JSONObject.parseObject(resultMsg, AppCreateOrderResponseVo.class);
|
|
|
+ String assemblyRespOriSign = MyBeanUtils.getSignedByPresetParameter(orderResponseVo, AppCreateOrderResponseVo.NEED_SIGN_PARAMS);
|
|
|
+ log.info("组装返回结果签名串:" + assemblyRespOriSign);
|
|
|
+ assemblyRespOriSign += Constant.SPLIT + Constant.SAOMA;
|
|
|
+ String responseSign = orderResponseVo.getSign();
|
|
|
+ log.info("响应签名:" + responseSign);
|
|
|
+ String checkSign = Disguiser.disguiseMD5(assemblyRespOriSign.trim());
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(resultMsg);
|
|
|
+ if (checkSign.equals(responseSign) && "0000".equals(orderResponseVo.getRt2_retCode())) {
|
|
|
+ //保存分账参数
|
|
|
+ SplitAccountPo splitAccount = new SplitAccountPo();
|
|
|
+ splitAccount.setAuthVipRecordId(heliDto.getVipRecordId());
|
|
|
+ // 超级会员 公账-专票
|
|
|
+ splitAccount.setType(1);
|
|
|
+ // 待分账总金额
|
|
|
+ double splitAmount = record.getPrice();
|
|
|
+ // 总手续费
|
|
|
+ double procedureFee;
|
|
|
+ //手续费
|
|
|
+ procedureFee = MathUtil.mul(splitAmount, 0.0025, 2).doubleValue();
|
|
|
+ if (MathUtil.compare(procedureFee, 0) == 0) {
|
|
|
+ procedureFee = 0.01;
|
|
|
+ }
|
|
|
+ splitAmount = MathUtil.sub(splitAmount, procedureFee).doubleValue();
|
|
|
+ splitAccount.setSplitAccount(splitAmount);
|
|
|
+ splitAccount.setMbOrderId(orderResponseVo.getRt6_serialNumber());
|
|
|
+ splitAccount.setOrderRequestNo(orderResponseVo.getRt5_orderId());
|
|
|
+ splitAccount.setPayStatus(0);
|
|
|
+ // 保存分账详情
|
|
|
+ payOrderMapper.insertSplitAccount(splitAccount);
|
|
|
+ return ResponseJson.success("二维码创建成功", jsonObject);
|
|
|
+ } else {
|
|
|
+ return ResponseJson.error("二维码创建失败", jsonObject);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return ResponseJson.error("创建二维码请求失败", null);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("创建二维码请求失败" + e);
|
|
|
+ return ResponseJson.error("创建二维码请求失败", null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String paymentAuthVipCallback(NotifyResponseVo res) throws IllegalAccessException, IntrospectionException, InvocationTargetException {
|
|
|
+ log.info("******************** 开通认证通会员异步回调 start *******************");
|
|
|
+ String sign = res.getSign();
|
|
|
+ log.info("回调签名" + sign);
|
|
|
+ // 公钥验签
|
|
|
+ String oriMessage = MyBeanUtils.getSigned(res, null);
|
|
|
+ String oriMessage1 = oriMessage + Constant.SPLIT + Constant.SAOMA;
|
|
|
+ String checkSign1 = Disguiser.disguiseMD5(oriMessage1.trim());
|
|
|
+ boolean b = sign.equals(checkSign1);
|
|
|
+ if (!b) {
|
|
|
+ return "验签失败!";
|
|
|
+ }
|
|
|
+ // 订单状态
|
|
|
+ String orderStatus = res.getRt4_status();
|
|
|
+ // 平台唯一流水号
|
|
|
+ String mbOrderId = res.getRt3_systemSerial();
|
|
|
+ // 商户唯一订单号
|
|
|
+ String orderRequestNo = res.getRt2_orderId();
|
|
|
+ // 金额,以元为单位
|
|
|
+ Double amount = Double.valueOf(res.getRt5_orderAmount());
|
|
|
+ String payFormData = JSON.toJSONString(res);
|
|
|
+ log.info("【开通认证通会员异步回调】>>>>>>>>>>>支付订单状态:" + orderStatus);
|
|
|
+ if (!"SUCCESS".equals(orderStatus)) {
|
|
|
+ return "支付失败";
|
|
|
+ }
|
|
|
+ log.info("【开通认证通会员异步回调】>>>>>>>>>>>>>>本次支付金额:" + amount);
|
|
|
+ // 附加数据,支付时若有传输则原样返回(vipId,userId,recordId,payType),下单时为空,则不返回该数据
|
|
|
+ String attach = res.getRt8_desc();
|
|
|
+ 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.setUserId(userId);
|
|
|
+ authVip.setBeginTime(beginTime);
|
|
|
+ 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";
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String unionAuthVipCallback(UnionResVo data) throws IllegalAccessException, IntrospectionException, InvocationTargetException {
|
|
|
+ log.info("******************** 开通认证通会员网银支付异步回调 start *******************");
|
|
|
+ String sign = data.getSign();
|
|
|
+ log.info("回调签名" + sign);
|
|
|
+ // 公钥验签
|
|
|
+ String oriMessage = MyBeanUtils.getSigned(data, null);
|
|
|
+ String oriMessage4 = oriMessage + Constant.SPLIT + Constant.WANGYIN;
|
|
|
+ String checkSign4 = Disguiser.disguiseMD5(oriMessage4.trim());
|
|
|
+ boolean b = sign.equals(checkSign4);
|
|
|
+ if (!b) {
|
|
|
+ return "验签失败!";
|
|
|
+ }
|
|
|
+ // 订单状态
|
|
|
+ String orderStatus = data.getRt11_orderStatus();
|
|
|
+ // 平台唯一流水号
|
|
|
+ String mbOrderId = data.getRt12_serialNumber();
|
|
|
+ // 商户唯一订单号
|
|
|
+ String orderRequestNo = data.getRt5_orderId();
|
|
|
+ // 金额,以元为单位
|
|
|
+ Double amount = Double.valueOf(data.getRt6_orderAmount());
|
|
|
+ String payFormData = JSON.toJSONString(data);
|
|
|
+ log.info("【开通认证通会员异步回调】>>>>>>>>>>>支付订单状态:" + orderStatus);
|
|
|
+ if (!"SUCCESS".equals(orderStatus)) {
|
|
|
+ return "支付失败";
|
|
|
+ }
|
|
|
+ log.info("【开通认证通会员异步回调】>>>>>>>>>>>>>>本次支付金额:" + amount);
|
|
|
+ // 附加数据,支付时若有传输则原样返回(vipId,userId,recordId,payType),下单时为空,则不返回该数据
|
|
|
+ String attach = data.getRt13_desc();
|
|
|
+ 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.setUserId(userId);
|
|
|
+ authVip.setBeginTime(beginTime);
|
|
|
+ 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";
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseJson 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));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|