diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java b/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java index b4c561fc..b8ea8365 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java @@ -457,12 +457,14 @@ public class HighOrderController { } } - - if (request.getHeader("regionId") != null && request.getHeader("regionId").length() != 0) { SecRegion region = commonService.getParentByRegion(Long.valueOf(request.getHeader("regionId"))); - BsCompany bsCompany = bsCompanyService.selectCompanyByRegion(region.getRegionId().toString()); - highOrder.setCompanyId(bsCompany.getId()); + if (region != null) { + BsCompany bsCompany = bsCompanyService.selectCompanyByRegion(region.getRegionId().toString()); + if (bsCompany != null) { + highOrder.setCompanyId(bsCompany.getId()); + } + } } highOrder.setMerchId(request.getHeader("mchId")); diff --git a/hai-service/src/main/java/com/hai/config/HuiLianTongUnionCardConfig.java b/hai-service/src/main/java/com/hai/config/HuiLianTongUnionCardConfig.java index 6809bf10..6d25dce9 100644 --- a/hai-service/src/main/java/com/hai/config/HuiLianTongUnionCardConfig.java +++ b/hai-service/src/main/java/com/hai/config/HuiLianTongUnionCardConfig.java @@ -296,6 +296,12 @@ public class HuiLianTongUnionCardConfig { return request("fuelCoupons/syncPayOrder", map); } + public static void main(String[] args) { + String data = "Gbkl57c3fEBg+E3HfPuQ55SDLVyAf2Ys3VN1cifAfXIoT1gnbFR0NaiH/z1OIZZiuqlFwDLLu6mt\\nuTcVJuO1hhr5QW09U1uIfz1mQwCBwvx4/PKxXQ7rR7/rnbvnsMxRupCMjc1vBdq902CiXq8RZVEq\\n8LrnkFZ9R+9IokVEc5nGG7XvKCmikEH80xtkvw0EwuPl1mEGp92uUbpxTahhwy5M9SAnIBZIjN5D\\nxi3F4tZ0kOhiuNNTO/CECE9sWZfO".replace("\\n", ""); + String decodeData = DesUtil.decode("F8E91A3C", data, Charset.forName("UTF-8")); + JSONObject.parseObject(decodeData); + + } } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighCouponAgentServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighCouponAgentServiceImpl.java index 88749f0b..37e49106 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighCouponAgentServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighCouponAgentServiceImpl.java @@ -606,15 +606,31 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { couponAgent.setSalesCount(couponAgent.getSalesCount() + 1); highCouponAgentRelMapper.updateByPrimaryKey(couponAgent); - // 下单请求 + // 第一次,下单请求 JSONObject rechargeObject = HuiLianTongConfig.recharge(convertCode.getConvertCode(), 1, coupon.getCouponKey(), phone); + + System.out.println("第一次下单" + rechargeObject.toJSONString()); if (!rechargeObject.getString("respCode").equals("0000")) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "下单失败"); } JSONObject response = HuiLianTongUnionCardConfig.resolveResponse(rechargeObject.getString("data")); + if (response == null || response.getJSONObject("data") == null) { + // 第二次,下单请求 + // 重新生成兑换码 + convertCode.setConvertCode(generateConvertCode(couponAgent.getId())); + rechargeObject = HuiLianTongConfig.recharge(convertCode.getConvertCode(), + 1, + coupon.getCouponKey(), + phone); + System.out.println("第二次下单" + rechargeObject.toJSONString()); + response = HuiLianTongUnionCardConfig.resolveResponse(rechargeObject.getString("data")); + if (response == null || response.getJSONObject("data") == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "下单失败"); + } + } convertCode.setExt1(response.getJSONObject("data").getString("rechargeOrderId")); highCouponAgentCodeMapper.updateByPrimaryKey(convertCode); 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 18972eb0..5df36e92 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 @@ -2289,8 +2289,7 @@ public class HighOrderServiceImpl implements HighOrderService { } // 下单 -// jsonObject = QianZhuConfig.starbucksOrders(user.getId().toString(), object.getString("storeCode"), List.toString().replace(" ", ""), object.getString("customerMobile")); - jsonObject = QianZhuConfig.starbucksOrders(user.getId().toString(), "50562", List.toString().replace(" ", ""), object.getString("customerMobile")); + jsonObject = QianZhuConfig.starbucksOrders(user.getId().toString(), object.getString("storeCode"), List.toString().replace(" ", ""), object.getString("customerMobile")); // 判断下单是否成功 if (!Objects.equals(jsonObject.getString("code"), "200")) {