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 a2d71a6b..191f6bfb 100644 --- a/hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java +++ b/hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java @@ -78,8 +78,50 @@ public class HighCouponSchedule { HighCouponCodeOtherExample example = new HighCouponCodeOtherExample(); 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) { + couponCodeOther.setStatus(data.getJSONObject("data").getInteger("state")); + highCouponCodeOtherMapper.updateByPrimaryKey(couponCodeOther); + + if (couponCodeOther.getCouponAgentCodeId() != null) { + HighCouponAgentCode agentCode = highCouponAgentCodeMapper.selectByPrimaryKey(couponCodeOther.getCouponAgentCodeId()); + if (agentCode == null) { + agentCode.setStatus(3); + highCouponAgentCodeMapper.updateByPrimaryKey(agentCode); + } + } + + if (couponCodeOther.getChildOrderId() != null) { + HighUserCouponExample userCouponExample = new HighUserCouponExample(); + userCouponExample.createCriteria().andQrCodeImgEqualTo(couponCodeOther.getCouNo()).andStatusEqualTo(1); + List list = highUserCouponMapper.selectByExample(userCouponExample); + if (list.size() > 0) { + HighUserCoupon userCoupon = list.get(0); + if (data.getJSONObject("data").getInteger("state") == 40) { + userCoupon.setStatus(2); + userCoupon.setConsumeTime(new Date()); + } else { + userCoupon.setStatus(0); + } + highUserCouponMapper.updateByPrimaryKey(userCoupon); + } + // 查询订单中的汇联通卡券全部已处理 + HighCouponCodeOtherExample otherExample = new HighCouponCodeOtherExample(); + otherExample.createCriteria().andChildOrderIdEqualTo(couponCodeOther.getChildOrderId()).andStatusEqualTo(20).andTypeEqualTo(1); + if (highCouponCodeOtherMapper.selectByExample(otherExample).size() == 0) { + highOrderService.childOrderComplete(couponCodeOther.getChildOrderId()); + } + } + + } + } + } +/* for (HighCouponCodeOther couponCodeOther : otherList) { JSONObject jsonObject = HuiLianTongConfig.getPayOrderByCouNo(couponCodeOther.getCouNo()); if (jsonObject.getString("respCode").equals("0000")) { @@ -121,7 +163,7 @@ public class HighCouponSchedule { } } - } + }*/ } } diff --git a/hai-service/src/main/java/com/hai/config/HuiLianTongConfig.java b/hai-service/src/main/java/com/hai/config/HuiLianTongConfig.java index 8bd05846..693bc632 100644 --- a/hai-service/src/main/java/com/hai/config/HuiLianTongConfig.java +++ b/hai-service/src/main/java/com/hai/config/HuiLianTongConfig.java @@ -58,7 +58,7 @@ public class HuiLianTongConfig { return HuiLianTongUnionCardConfig.request(CommonSysConst.getSysConfig().getHuiliantongSinopecUrl() + "/getHltFuelCoupList", map); } - /** +/* *//** * 下单购买加油券 * @param orderNo * @param distCouCount @@ -66,7 +66,7 @@ public class HuiLianTongConfig { * @param phone * @return * @throws Exception - */ + *//* public static JSONObject recharge(String orderNo, Integer distCouCount, String couTypeCode, String phone) throws Exception { Map map = new HashMap<>(); map.put("orderNo", orderNo); @@ -77,12 +77,12 @@ public class HuiLianTongConfig { return HuiLianTongUnionCardConfig.request(CommonSysConst.getSysConfig().getHuiliantongSinopecUrl()+"/recharge", map); } - /** + *//** * 购买加油券充值订单 * @param couNo 订单号 * @return * @throws Exception - */ + *//* public static JSONObject getPayOrderByCouNo(String couNo) throws Exception { Map map = new HashMap<>(); map.put("couNo", couNo); @@ -90,18 +90,18 @@ public class HuiLianTongConfig { return HuiLianTongUnionCardConfig.request(CommonSysConst.getSysConfig().getHuiliantongSinopecUrl()+"/getPayOrderByCouNo", map); } - /** + *//** * 购买加油券充值订单 * @param rechargeOrderId 订单号 * @return * @throws Exception - */ + *//* public static JSONObject costRechargeOrder(String rechargeOrderId) throws Exception { Map map = new HashMap<>(); map.put("rechargeOrderId", rechargeOrderId); map.put("distributorId", CommonSysConst.getSysConfig().getHuiliantongDistributorId()); return HuiLianTongUnionCardConfig.request(CommonSysConst.getSysConfig().getHuiliantongSinopecUrl()+"/costRechargeOrder", map); - } + }*/ /** 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 490736f5..a9671209 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,7 +207,7 @@ public class HighOrderServiceImpl implements HighOrderService { highChildOrderMapper.updateByPrimaryKey(childOrder); } - if (couponDetail.getCouponSource().equals(4)) { +/* if (couponDetail.getCouponSource().equals(4)) { // 下单请求 JSONObject jsonObject = HuiLianTongConfig.recharge(highOrder.getOrderNo(), childOrder.getSaleCount(), @@ -219,7 +219,7 @@ public class HighOrderServiceImpl implements HighOrderService { JSONObject response = HuiLianTongUnionCardConfig.resolveResponse(jsonObject.getString("data")); childOrder.setExt2(response.getJSONObject("data").getString("rechargeOrderId")); highChildOrderMapper.updateByPrimaryKey(childOrder); - } + }*/ if (!childOrder.getGiveawayType()) { // 查看是否需要赠送卡卷 @@ -327,7 +327,49 @@ public class HighOrderServiceImpl implements HighOrderService { } // 贵州高速 if (coupon.getCouponSource() == 4) { - Map push = new HashMap<>(); + // 获取token + String token = huiLianTongConfig.getToken(); + + Map push = new HashMap<>(); + push.put("token", token); + 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"); + for (Object data : dataArray) { + JSONObject dataObject = (JSONObject) data; + HighCouponCodeOther couponCodeOther = new HighCouponCodeOther(); + couponCodeOther.setType(1); + couponCodeOther.setOrderId(highOrder.getId()); + couponCodeOther.setChildOrderId(highChildOrder.getId()); + couponCodeOther.setCouTypeCode(dataObject.getString("couTypeCode")); + couponCodeOther.setCouNo(dataObject.getString("couNo")); + couponCodeOther.setStatus(20); + couponCodeOther.setCreateTime(new Date()); + couponCodeOther.setActiveTime(dataObject.getDate("activeTime")); + couponCodeOther.setValidStartDate(dataObject.getDate("validStartDate")); + couponCodeOther.setValidEndDate(dataObject.getDate("validEndDate")); + highCouponCodeOtherMapper.insert(couponCodeOther); + + // 卡卷关联用户 + HighUserCoupon highUserCoupon = new HighUserCoupon(); + highUserCoupon.setMerchantId(coupon.getMerchantId()); + highUserCoupon.setCouponId(coupon.getId()); + highUserCoupon.setUserId(highOrder.getMemId()); + highUserCoupon.setCreateTime(new Date()); + highUserCoupon.setQrCodeImg(dataObject.getString("couNo")); + highUserCoupon.setUseEndTime(dataObject.getDate("validEndDate")); + highUserCoupon.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用 + highUserCouponMapper.insert(highUserCoupon); + } + } + +/* Map push = new HashMap<>(); push.put("couTypeCode", coupon.getCouponKey()); push.put("distCouCount", highChildOrder.getSaleCount()); push.put("userPhone", highUser.getPhone()); @@ -365,7 +407,7 @@ public class HighOrderServiceImpl implements HighOrderService { highUserCoupon.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用 highUserCouponMapper.insert(highUserCoupon); } - } + }*/ // 推送记录 HighGasOrderPush highGasOrderPush = new HighGasOrderPush();