From 25b765b60e12728da2dc0e162a53ffafdcc2d879 Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Tue, 2 Aug 2022 10:31:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bweb/controller/HighCouponController.java | 13 ++++---- .../com/hai/schedule/HighCouponSchedule.java | 13 ++++---- .../service/impl/HighOrderServiceImpl.java | 31 +++++++++++++------ 3 files changed, 35 insertions(+), 22 deletions(-) diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java b/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java index 6ba509d1..667fcef2 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java @@ -19,6 +19,7 @@ import com.hai.common.utils.DateUtil; import com.hai.common.utils.MemberValidateUtil; import com.hai.common.utils.ResponseMsgUtil; import com.hai.config.HuiLianTongConfig; +import com.hai.config.HuiLianTongUnionCardConfig; import com.hai.entity.*; import com.hai.enum_type.ApproveType; import com.hai.model.HighCouponHandselModel; @@ -711,19 +712,17 @@ public class HighCouponController { throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOF_FOUND, ""); } - // 获取token - String token = huiLianTongConfig.getToken(); - // 查询电子卡券类型 - JSONObject corpCouTypes = HuiLianTongConfig.getCorpCouTypes(token); - System.out.println(corpCouTypes.toJSONString()); - if (!corpCouTypes.getString("result").equals("success")) { + JSONObject corpCouTypes = HuiLianTongConfig.getHltFuelCoupList(); + if (!corpCouTypes.getString("respCode").equals("0000")) { log.error("HighCouponController -> insertCoupon() error!","获取电子卡券列表失败"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "获取电子卡券列表失败"); } + // 参数解密 + JSONObject resolveResponseData = HuiLianTongUnionCardConfig.resolveResponse(corpCouTypes.getString("data")); HighCoupon coupon; - JSONArray dataArray = corpCouTypes.getJSONArray("data"); + JSONArray dataArray = resolveResponseData.getJSONArray("data"); if (dataArray != null && dataArray.size() > 0) { for (Object object : dataArray) { JSONObject dataObject = (JSONObject)object; diff --git a/hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java b/hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java index 9d88fe18..a2d71a6b 100644 --- a/hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java +++ b/hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java @@ -6,6 +6,7 @@ import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.utils.ResponseMsgUtil; import com.hai.config.HuiLianTongConfig; +import com.hai.config.HuiLianTongUnionCardConfig; import com.hai.dao.HighCouponAgentCodeMapper; import com.hai.dao.HighCouponCodeOtherMapper; import com.hai.dao.HighUserCouponMapper; @@ -78,13 +79,13 @@ public class HighCouponSchedule { example.createCriteria().andStatusEqualTo(20).andTypeEqualTo(1); List otherList = highCouponCodeOtherMapper.selectByExample(example); - // 获取token - String token = huiLianTongConfig.getToken(); - for (HighCouponCodeOther couponCodeOther : otherList) { - JSONObject data = HuiLianTongConfig.getCouState(token, couponCodeOther.getCouNo()); - if (data.getString("result").equals("success")) { - if (data.getJSONObject("data").getInteger("state") != 20) { + JSONObject jsonObject = HuiLianTongConfig.getPayOrderByCouNo(couponCodeOther.getCouNo()); + + if (jsonObject.getString("respCode").equals("0000")) { + JSONObject data = HuiLianTongUnionCardConfig.resolveResponse(jsonObject.getString("data")); + + if (data.getString("respCode").equals("0000") && data.getJSONObject("data").getInteger("state") != 20) { couponCodeOther.setStatus(data.getJSONObject("data").getInteger("state")); highCouponCodeOtherMapper.updateByPrimaryKey(couponCodeOther); diff --git a/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java index 480bd22c..d994beae 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java @@ -207,6 +207,20 @@ public class HighOrderServiceImpl implements HighOrderService { highChildOrderMapper.updateByPrimaryKey(childOrder); } + if (couponDetail.getCouponSource().equals(4)) { + // 下单请求 + JSONObject jsonObject = HuiLianTongConfig.recharge(highOrder.getOrderNo(), + childOrder.getSaleCount(), + couponDetail.getCouponKey(), + highOrder.getMemPhone()); + if (!jsonObject.getString("respCode").equals("0000")) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "下单失败"); + } + JSONObject response = HuiLianTongUnionCardConfig.resolveResponse(jsonObject.getString("data")); + childOrder.setExt2(response.getJSONObject("data").getString("rechargeOrderId")); + highChildOrderMapper.updateByPrimaryKey(childOrder); + } + if (!childOrder.getGiveawayType()) { // 查看是否需要赠送卡卷 List handselListByCoupon = highCouponHandselService.getHandselListByCoupon(childOrder.getGoodsId()); @@ -313,20 +327,18 @@ public class HighOrderServiceImpl implements HighOrderService { } // 贵州高速 if (coupon.getCouponSource() == 4) { - // 获取token - String token = huiLianTongConfig.getToken(); - - Map push = new HashMap<>(); - push.put("token", token); + Map push = new HashMap<>(); push.put("couTypeCode", coupon.getCouponKey()); push.put("distCouCount", highChildOrder.getSaleCount()); push.put("userPhone", highUser.getPhone()); push.put("thirdUserId", highUser.getUnionId()); // 推送给高速 - JSONObject returnParam = HuiLianTongConfig.couJointDist(token, highOrder.getOrderNo(), coupon.getCouponKey(), highChildOrder.getSaleCount(), highUser.getPhone(), highUser.getUnionId()); - if (returnParam != null && returnParam.getString("result").equals("success")) { - JSONArray dataArray = returnParam.getJSONArray("data"); + JSONObject returnParam = HuiLianTongConfig.costRechargeOrder(highChildOrder.getExt2()); + if (returnParam != null && returnParam.getString("respCode").equals("0000")) { + // 解密 + JSONObject jsonObject = HuiLianTongUnionCardConfig.resolveResponse(returnParam.getString("data")); + JSONArray dataArray = JSONObject.parseObject(jsonObject.getString("data"), JSONArray.class); for (Object data : dataArray) { JSONObject dataObject = (JSONObject) data; HighCouponCodeOther couponCodeOther = new HighCouponCodeOther(); @@ -354,12 +366,13 @@ public class HighOrderServiceImpl implements HighOrderService { highUserCouponMapper.insert(highUserCoupon); } } + // 推送记录 HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); highGasOrderPush.setType(OrderPushType.type6.getType()); highGasOrderPush.setOrderNo(highOrder.getOrderNo()); highGasOrderPush.setCreateTime(new Date()); - highGasOrderPush.setCode(returnParam.getString("result")); + highGasOrderPush.setCode(returnParam.getString("respCode")); highGasOrderPush.setRequestContent(JSONObject.toJSONString(push)); highGasOrderPush.setReturnContent(returnParam.toJSONString()); highGasOrderPushMapper.insert(highGasOrderPush);