|
@@ -6,18 +6,17 @@ import com.caimei365.order.components.HeliPayUtil;
|
|
|
import com.caimei365.order.components.WeChatService;
|
|
|
import com.caimei365.order.constant.Constant;
|
|
|
import com.caimei365.order.mapper.BaseMapper;
|
|
|
+import com.caimei365.order.mapper.OrderClubMapper;
|
|
|
import com.caimei365.order.mapper.PayOrderMapper;
|
|
|
import com.caimei365.order.model.ResponseJson;
|
|
|
import com.caimei365.order.model.bo.PayParamBo;
|
|
|
import com.caimei365.order.model.bo.VipRecordBo;
|
|
|
import com.caimei365.order.model.dto.HeliDto;
|
|
|
+import com.caimei365.order.model.dto.PayCouponDto;
|
|
|
import com.caimei365.order.model.enums.AccountPayOrderType;
|
|
|
import com.caimei365.order.model.enums.AppPayType;
|
|
|
import com.caimei365.order.model.enums.PayType;
|
|
|
-import com.caimei365.order.model.po.DiscernReceiptPo;
|
|
|
-import com.caimei365.order.model.po.OrderReceiptRelationPo;
|
|
|
-import com.caimei365.order.model.po.SplitAccountPo;
|
|
|
-import com.caimei365.order.model.po.UserVipPo;
|
|
|
+import com.caimei365.order.model.po.*;
|
|
|
import com.caimei365.order.model.vo.*;
|
|
|
import com.caimei365.order.service.HeliPayNonOrderService;
|
|
|
import com.caimei365.order.service.RemoteCallService;
|
|
@@ -59,6 +58,210 @@ public class HeliPayNonOrderServiceImpl implements HeliPayNonOrderService {
|
|
|
private WeChatService weChatService;
|
|
|
@Resource
|
|
|
private RemoteCallService remoteCallService;
|
|
|
+ @Resource
|
|
|
+ private OrderClubMapper orderClubMapper;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseJson<PayCouponDto> getCouponRecord(PayCouponDto payCouponDto, HttpHeaders headers) {
|
|
|
+ //个人机构返回状态码-1 不是医美 -2
|
|
|
+ if (49 == payCouponDto.getCouponId()) {
|
|
|
+ //正式id49优惠券 普通机构和非医美机构无法购买
|
|
|
+ //先判断是否是普通机构,是就打回
|
|
|
+ Integer userIdentity = baseMapper.getIdentityByUserId(payCouponDto.getUserId());
|
|
|
+ if (userIdentity != null && 4 == userIdentity) {
|
|
|
+ return ResponseJson.error(-1, "仅供医美机构购买!", null);
|
|
|
+ }
|
|
|
+ Integer clubType = payOrderMapper.findClubType(payCouponDto.getUserId());
|
|
|
+ //为空或者不等于1 医美=1和生美=2
|
|
|
+ if (null == clubType || 1 != clubType) {
|
|
|
+ return ResponseJson.error(-2, "仅供医美机构购买!", null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ CouponRecordPo cr = new CouponRecordPo();
|
|
|
+ cr.setCouponId(payCouponDto.getCouponId());
|
|
|
+ cr.setUserId(payCouponDto.getUserId());
|
|
|
+ payOrderMapper.insertCouponRecord(cr);
|
|
|
+ payCouponDto.setCouponRecordId(cr.getId());
|
|
|
+ return ResponseJson.success(payCouponDto);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseJson<JSONObject> payCouponByWeChat(HeliDto heliDto, HttpHeaders headers) {
|
|
|
+ Integer status = payOrderMapper.findPayStatus(heliDto.getCouponRecordId());
|
|
|
+ if (null != status && 1 == status) {
|
|
|
+ return ResponseJson.error("该笔记录已支付,请勿重复支付!", null);
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ AppPayPublicCreateOrderVo pay = new AppPayPublicCreateOrderVo();
|
|
|
+ //公众号,小程序获取openid
|
|
|
+ if ("GZH".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());
|
|
|
+ }
|
|
|
+ //合利宝主扫接口参数赋值
|
|
|
+ heliPayUtil.setOnlineValue(pay, heliDto, "coupon", 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.setCouponRecordId(heliDto.getCouponRecordId());
|
|
|
+ // 优惠券 公账-专票
|
|
|
+ splitAccount.setType(1);
|
|
|
+ // 待分账总金额
|
|
|
+ double splitAmount =Double.parseDouble(heliDto.getPayAmount());
|
|
|
+ // 总手续费
|
|
|
+ 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 String couponCallback(NotifyResponseVo res) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
|
|
|
+ log.info("******************** 升级超级会员异步回调 start *******************");
|
|
|
+ String sign = res.getSign();
|
|
|
+ log.info("回调签名" + sign);
|
|
|
+ // 公钥验签
|
|
|
+ String oriMessage = MyBeanUtils.getSigned(res, null);
|
|
|
+ String oriMessage1 = oriMessage + Constant.SPLIT + Constant.SAOMA;
|
|
|
+ String oriMessage2 = oriMessage + Constant.SPLIT + Constant.FENZHANG;
|
|
|
+ String oriMessage3 = oriMessage + Constant.SPLIT + Constant.XUNI;
|
|
|
+ String oriMessage4 = oriMessage + Constant.SPLIT + Constant.WANGYIN;
|
|
|
+ String checkSign1 = Disguiser.disguiseMD5(oriMessage1.trim());
|
|
|
+ String checkSign2 = Disguiser.disguiseMD5(oriMessage2.trim());
|
|
|
+ String checkSign3 = Disguiser.disguiseMD5(oriMessage3.trim());
|
|
|
+ String checkSign4 = Disguiser.disguiseMD5(oriMessage4.trim());
|
|
|
+ boolean b = sign.equals(checkSign1) || sign.equals(checkSign2) || sign.equals(checkSign3) || sign.equals(checkSign4);
|
|
|
+ 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 couponId = 0;
|
|
|
+ int userId = 0;
|
|
|
+ int recordId = 0;
|
|
|
+ int payType = 0;
|
|
|
+ int source = 0;
|
|
|
+ try {
|
|
|
+ // 优惠券Id
|
|
|
+ couponId = Integer.parseInt(split[0]);
|
|
|
+ // 用户Id
|
|
|
+ userId = Integer.parseInt(split[1]);
|
|
|
+ // 购买历史记录Id
|
|
|
+ recordId = Integer.parseInt(split[2]);
|
|
|
+ // 支付方式
|
|
|
+ payType = Integer.parseInt(split[3]);
|
|
|
+ //购买渠道
|
|
|
+ source = Integer.parseInt(split[4]);
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ log.info("【购买优惠券异步回调】>>>>>>>>>>>>>>获取回调参数解析失败!");
|
|
|
+ }
|
|
|
+ //cm_coupon_club数据库修改
|
|
|
+ CouponClubPo couponClubPo = new CouponClubPo();
|
|
|
+ couponClubPo.setSource(source);
|
|
|
+ couponClubPo.setUserId(userId);
|
|
|
+ couponClubPo.setCouponId(couponId);
|
|
|
+ couponClubPo.setStatus("1");
|
|
|
+ couponClubPo.setDelFlag("0");
|
|
|
+ couponClubPo.setCreateDate(new Date());
|
|
|
+ orderClubMapper.insertCouponClub(couponClubPo);
|
|
|
+ // 改历史记录支付状态
|
|
|
+ payOrderMapper.updateCouponRecord(recordId);
|
|
|
+ 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(payType);
|
|
|
+ discernReceipt.setReceiptType(8);
|
|
|
+ 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() + ",couponRecordId:" + recordId);
|
|
|
+ // 收款项和订单关系表
|
|
|
+ OrderReceiptRelationPo relation = new OrderReceiptRelationPo();
|
|
|
+ relation.setReceiptId(discernReceipt.getId());
|
|
|
+ relation.setCouponRecordId(recordId);
|
|
|
+ relation.setAssociateAmount(amount);
|
|
|
+ relation.setMbOrderId(mbOrderId);
|
|
|
+ relation.setOrderRequestNo(orderRequestNo);
|
|
|
+ relation.setSplitStatus(1);
|
|
|
+ relation.setRelationType(6);
|
|
|
+ relation.setDelFlag(0);
|
|
|
+ // 保存 收款项和订单关系
|
|
|
+ baseMapper.insertOrderReceiptRelation(relation);
|
|
|
+ log.info("【购买优惠券异步回调】>>>>>>>>>>>收款项和购买历史关系(insert[cm_receipt_order_relation])id:" + relation.getId() + ",couponRecordId:" + recordId);
|
|
|
+ //修改分账付款状态
|
|
|
+ payOrderMapper.updateSplitAccountByPay(mbOrderId);
|
|
|
+ return "SUCCESS";
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 二手发布 小程序/公众号
|
|
@@ -337,35 +540,6 @@ public class HeliPayNonOrderServiceImpl implements HeliPayNonOrderService {
|
|
|
return "SUCCESS";
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 设置支付基础参数
|
|
|
- */
|
|
|
- private JSONObject getPayJsonObject(PayParamBo payParam, HttpHeaders headers, long time) {
|
|
|
- // 用户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());
|
|
|
- }
|
|
|
- return json;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 升级超级会员-微信线上支付
|
|
|
*
|
|
@@ -974,7 +1148,7 @@ public class HeliPayNonOrderServiceImpl implements HeliPayNonOrderService {
|
|
|
log.info("二手网银分账类型参数payType错误======================》" + payType);
|
|
|
return "SUCCESS";
|
|
|
}
|
|
|
- split(data.getRt5_orderId(), totalAmount);
|
|
|
+// split(data.getRt5_orderId(), totalAmount);
|
|
|
return "SUCCESS";
|
|
|
}
|
|
|
|
|
@@ -1064,7 +1238,246 @@ public class HeliPayNonOrderServiceImpl implements HeliPayNonOrderService {
|
|
|
log.info("二手网银分账类型参数payType错误======================》" + payType);
|
|
|
return "SUCCESS";
|
|
|
}
|
|
|
- split(res.getRt5_orderId(), totalAmount);
|
|
|
+// split(res.getRt5_orderId(), totalAmount);
|
|
|
+ return "SUCCESS";
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseJson<JSONObject> payCouponByAlipay(HeliDto heliDto, HttpHeaders headers) {
|
|
|
+ Integer status = payOrderMapper.findPayStatus(heliDto.getCouponRecordId());
|
|
|
+ if (null != status && 1 == status) {
|
|
|
+ return ResponseJson.error("该笔记录已支付,请勿重复支付!", null);
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ AppCreateOrderVo pay = new AppCreateOrderVo();
|
|
|
+ //合利宝主扫接口参数赋值
|
|
|
+ heliPayUtil.setValue(pay, heliDto, "coupon", 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.setCouponRecordId(heliDto.getCouponRecordId());
|
|
|
+ // 优惠券 公账-专票
|
|
|
+ splitAccount.setType(1);
|
|
|
+ // 待分账总金额
|
|
|
+ double splitAmount =Double.parseDouble(heliDto.getPayAmount());
|
|
|
+ // 总手续费
|
|
|
+ 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 ResponseJson<String> couponUnionPay(HeliDto heliDto, HttpHeaders headers) {
|
|
|
+ Integer status = payOrderMapper.findPayStatus(heliDto.getCouponRecordId());
|
|
|
+ if (null != status && 1 == status) {
|
|
|
+ return ResponseJson.error("该笔记录已支付,请勿重复支付!", null);
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ log.info("--------进入优惠券网银线上支付接口----------");
|
|
|
+ HeliOnlineVo heliOnlineVo = new HeliOnlineVo();
|
|
|
+ heliPayUtil.setLinkValue(heliOnlineVo, heliDto, "coupon", 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.setCouponRecordId(heliDto.getCouponRecordId());
|
|
|
+ // 超级会员 公账-专票
|
|
|
+ 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 String unionCouponCallback(UnionResVo data) throws IntrospectionException, InvocationTargetException, IllegalAccessException{
|
|
|
+ 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 "支付失败";
|
|
|
+ }
|
|
|
+ String attach = data.getRt13_desc();
|
|
|
+ String[] split = attach.split(",");
|
|
|
+ int couponId = 0;
|
|
|
+ int userId = 0;
|
|
|
+ int recordId = 0;
|
|
|
+ int payType = 0;
|
|
|
+ int source = 0;
|
|
|
+ try {
|
|
|
+ // 优惠券Id
|
|
|
+ couponId = Integer.parseInt(split[0]);
|
|
|
+ // 用户Id
|
|
|
+ userId = Integer.parseInt(split[1]);
|
|
|
+ // 购买历史记录Id
|
|
|
+ recordId = Integer.parseInt(split[2]);
|
|
|
+ // 支付方式
|
|
|
+ payType = Integer.parseInt(split[3]);
|
|
|
+ //购买渠道
|
|
|
+ source = Integer.parseInt(split[4]);
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ log.info("【购买优惠券异步回调】>>>>>>>>>>>>>>获取回调参数解析失败!");
|
|
|
+ }
|
|
|
+ //cm_coupon_club数据库修改
|
|
|
+ CouponClubPo couponClubPo = new CouponClubPo();
|
|
|
+ couponClubPo.setSource(source);
|
|
|
+ couponClubPo.setUserId(userId);
|
|
|
+ couponClubPo.setCouponId(couponId);
|
|
|
+ couponClubPo.setStatus("1");
|
|
|
+ couponClubPo.setDelFlag("0");
|
|
|
+ couponClubPo.setCreateDate(new Date());
|
|
|
+ orderClubMapper.insertCouponClub(couponClubPo);
|
|
|
+ // 改历史记录支付状态
|
|
|
+ payOrderMapper.updateCouponRecord(recordId);
|
|
|
+ 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(payType);
|
|
|
+ discernReceipt.setReceiptType(8);
|
|
|
+ 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() + ",couponRecordId:" + recordId);
|
|
|
+ // 收款项和订单关系表
|
|
|
+ OrderReceiptRelationPo relation = new OrderReceiptRelationPo();
|
|
|
+ relation.setReceiptId(discernReceipt.getId());
|
|
|
+ relation.setCouponRecordId(recordId);
|
|
|
+ relation.setAssociateAmount(amount);
|
|
|
+ relation.setMbOrderId(mbOrderId);
|
|
|
+ relation.setOrderRequestNo(orderRequestNo);
|
|
|
+ relation.setSplitStatus(1);
|
|
|
+ relation.setRelationType(6);
|
|
|
+ relation.setDelFlag(0);
|
|
|
+ // 保存 收款项和订单关系
|
|
|
+ baseMapper.insertOrderReceiptRelation(relation);
|
|
|
+ log.info("【购买优惠券异步回调】>>>>>>>>>>>收款项和购买历史关系(insert[cm_receipt_order_relation])id:" + relation.getId() + ",couponRecordId:" + recordId);
|
|
|
+ //修改分账付款状态
|
|
|
+ payOrderMapper.updateSplitAccountByPay(mbOrderId);
|
|
|
return "SUCCESS";
|
|
|
}
|
|
|
|