From 50289015093ef6ffecd1746f6fe15753b8185ef4 Mon Sep 17 00:00:00 2001 From: Sum1Dream <418471657@qq.com> Date: Mon, 20 Nov 2023 13:50:30 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/2.0-dev' into 2.0-dev --- .../bweb/controller/ApiCouponController.java | 28 ++++- .../bweb/controller/HighCouponController.java | 2 +- .../bweb/controller/HighTestController.java | 2 +- .../com/web/controller/OrderController.java | 4 +- .../notify/GroupOrderController.java | 7 +- .../controller/notify/ScNotifyController.java | 103 +++++++++++++++ .../java/com/hai/config/ScPetroConfig.java | 119 +++++++++++++++++- .../impl/HighCouponAgentServiceImpl.java | 28 +++++ .../impl/HighCouponCodeServiceImpl.java | 37 ++++++ .../HighDiscountAgentCodeServiceImpl.java | 101 ++++++++++----- .../impl/HighMerchantStoreServiceImpl.java | 1 + 11 files changed, 392 insertions(+), 40 deletions(-) create mode 100644 hai-order/src/main/java/com/web/controller/notify/ScNotifyController.java diff --git a/hai-bweb/src/main/java/com/bweb/controller/ApiCouponController.java b/hai-bweb/src/main/java/com/bweb/controller/ApiCouponController.java index af038d10..af93452f 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/ApiCouponController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/ApiCouponController.java @@ -1,9 +1,11 @@ package com.bweb.controller; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.hai.common.utils.ResponseMsgUtil; -import com.hai.entity.ApiBlxCoupon; +import com.hai.config.ScPetroConfig; import com.hai.model.ResponseData; import com.hai.openApi.service.ApiBlxCouponService; import io.swagger.annotations.Api; @@ -18,7 +20,6 @@ import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; import java.util.HashMap; -import java.util.Map; @Controller @RequestMapping(value = "/apiCoupon") @@ -30,6 +31,8 @@ public class ApiCouponController { @Resource private ApiBlxCouponService apiBlxCouponService; + + @RequestMapping(value = "/getBlxCouponList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取比邻星停车券列表") @@ -46,4 +49,25 @@ public class ApiCouponController { } } + @RequestMapping(value = "/synCouponRule", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "获取四川中石油卡券") + public ResponseData synCouponRule() { + try { + + JSONObject jsonObject = ScPetroConfig.synCouponRule(); + + if (jsonObject.getString("code").equals("1")) { + String data = ScPetroConfig.decrypt(jsonObject.getString("biz_content")); + JSONArray jsonArray = JSONArray.parseArray(data); + return ResponseMsgUtil.success(jsonArray); + } + return ResponseMsgUtil.success("请求失败"); + + } catch (Exception e) { + log.error("HighDiscountPackageController --> getDiscountPackageList() error!", e); + return ResponseMsgUtil.exception(e); + } + } + } 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 7a9a7129..81702877 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java @@ -318,7 +318,7 @@ public class HighCouponController { } // 中石化 - if (coupon.getCouponSource() != null && (coupon.getCouponSource() != 4 && coupon.getCouponSource() != 5 && coupon.getCouponSource() != 6)) { + if (coupon.getCouponSource() != null && (coupon.getCouponSource() != 4 && coupon.getCouponSource() != 5 && coupon.getCouponSource() != 6 && coupon.getCouponSource() != 7)) { // 根据卡卷查询 销售码库存 if (highCouponCodeService.getStockCountByCoupon(coupon.getId()) == 0) { log.error("HighCouponController -> upShelfApprove() error!","卡卷库存数量错误"); diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java b/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java index b99653b4..7ccf3a44 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java @@ -1 +1 @@ - package com.bweb.controller; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.utils.HttpsUtils; import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.WxUtils; import com.hai.config.*; import com.hai.entity.*; import com.hai.enum_type.GasOilPriceStatusEnum; import com.hai.model.HighMerchantModel; import com.hai.model.HighMerchantStoreModel; import com.hai.model.ResponseData; import com.hai.openApi.config.BlxConfig; import com.hai.order.service.OrderService; import com.hai.order.type.OrderProductType; import com.hai.order.type.OrderRefundOpUserType; import com.hai.order.utils.OrderUtil; import com.hai.pay.channel.huipay.config.HuiConfig; import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.bouncycastle.LICENSE; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.io.FileOutputStream; import java.io.InputStream; import java.math.BigDecimal; import java.net.URL; import java.net.URLConnection; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/test") @Api(value = "订单接口") public class HighTestController { private static Logger log = LoggerFactory.getLogger(HighTestController.class); @Resource private OrderService orderService; @Resource private HighUserCardService highUserCardService; @Resource private HighOrderService highOrderService; @Resource private HighUserService highUserService; @Resource private HighMerchantService highMerchantService; @Resource private HighMerchantStoreService highMerchantStoreService; @Resource private HighGasOilPriceService highGasOilPriceService; @Resource private HuiConfig huiConfig; @Resource private CommonService commonService; @Resource private HighOilCardOrderService highOilCardOrderService; @RequestMapping(value="/resolveResponse",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "解析") public ResponseData resolveResponse( @RequestParam(name = "data", required = false) String data ) { try { JSONObject cardInfoObject = HuiLianTongUnionCardConfig.resolveResponse(data); return ResponseMsgUtil.success(cardInfoObject); } catch (Exception e) { log.error("getUserByTelephone",e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getHuiLianTongCardConsume", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询汇联通工会卡消费记录") public ResponseData getHuiLianTongCardConsume(@RequestParam(name = "businessType", required = true) String businessType, @RequestParam(name = "cardNo", required = true) String cardNo, @RequestParam(name = "sdate", required = true) Long sdate, @RequestParam(name = "edate", required = true) Long edate, @RequestParam(name = "pageNum", required = true) Integer pageNum, @RequestParam(name = "pageSize", required = true) Integer pageSize, HttpServletRequest request) { try { JSONObject consumptionRecord = HuiLianTongUnionCardConfig.queryConsumptionRecordByBusiness(businessType, cardNo, sdate, edate, pageNum, pageSize); if (StringUtils.isBlank(consumptionRecord.getString("data"))) { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQUEST_ERROR, ""); } JSONArray array = HuiLianTongUnionCardConfig.resolveResponse(consumptionRecord.getString("data")).getJSONArray("records"); return ResponseMsgUtil.success(array); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardConsume() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/createOrder", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "创建订单") public ResponseData createOrder(@RequestBody JSONObject object) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("timetable" , new Date().getTime()); mapPost.put("orderNo" , "TEST" + OrderUtil.generateOrderNo()); mapPost.put("productType" , object.getString("productType")); mapPost.put("content" , object.getJSONObject("content").toString()); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/order/createOrder" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/payOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "支付订单") public ResponseData payOrder(@RequestParam(name = "mchOrderNo", required = true) String mchOrderNo) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("mchOrderNo" , mchOrderNo); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("mchOrderNo" , mchOrderNo); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/order/orderPay" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryOrderDetail", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询订单详情") public ResponseData queryOrderDetail(@RequestParam(name = "mchOrderNo", required = true) String mchOrderNo) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("mchOrderNo" , mchOrderNo); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("mchOrderNo" , mchOrderNo); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/order/queryOrderDetail" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/deposit", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "工会卡充值") public ResponseData deposit(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); HighChildOrder highChildOrder = order.getHighChildOrderList().get(0); if (order.getOrderStatus() != 2) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单状态错误"); } // 汇联通充值 String goodsDesc = "汇联通充值"+order.getPayPrice()+"元"; String tranDesc = ""; String businessType = "ghk_deposit"; String orderNoAgain = OrderUtil.generateOrderNo(); order.setOrderStatus(Integer.valueOf(3)); order.setRemarks("工会卡再次充值订单号" + orderNoAgain); highOrderService.updateOrder(order); // 汇联通卡充值 JSONObject deposit = HuiLianTongUnionCardConfig.deposit(orderNoAgain, highChildOrder.getGoodsSpecName(), order.getPayPrice(), businessType, order.getPaySerialNo(), goodsDesc); return ResponseMsgUtil.success( HuiLianTongUnionCardConfig.resolveResponse(deposit.getString("data"))); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getHuiLianTongCardByCardNo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据卡号查询汇联通工会卡详情") public ResponseData getHuiLianTongCardByCardNo(@RequestParam(name = "cardNo", required = true) String cardNo) { try { // 查询工会卡 JSONObject cardInfo = HuiLianTongUnionCardConfig.queryBalance(cardNo); JSONObject resolveResponse = HuiLianTongUnionCardConfig.resolveResponse(cardInfo.getString("data")); return ResponseMsgUtil.success(resolveResponse); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardByCardNo() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/consumption", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "工会卡支付") public ResponseData consumption(@RequestParam(name = "payRealPrice", required = true) BigDecimal payRealPrice, @RequestParam(name = "cardNo", required = true) String cardNo) { try { String goodsDesc = ""; String tranDesc = ""; String instCode = "11101527"; String businessType = "hisen_consume"; // 工会卡支付 JSONObject consumption = HuiLianTongUnionCardConfig.consumption(OrderUtil.generateOrderNo(), cardNo, payRealPrice, businessType, instCode, goodsDesc, tranDesc); if (!consumption.getString("respCode").equals("0000")) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumption.getString("respMessage")); } // 响应参数 JSONObject consumptionResult = HuiLianTongUnionCardConfig.resolveResponse(consumption.getString("data")); if (consumptionResult.getBoolean("success") != true) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumptionResult.getString("message")); } return ResponseMsgUtil.success(consumptionResult); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardByCardNo() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/refundOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "工会卡退款") public ResponseData refundOrder(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); if (order.getOrderStatus() != 2) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单状态错误"); } orderService.refundOrder(order, OrderProductType.getDataByType(order.getProductType()).getName() + "退款",OrderRefundOpUserType.TYPE1, null, "系统自动退款"); if (order.getProductType().equals(4)) { HighUser user = highUserService.findByUserId(order.getMemId()); // 获取应退款积分 int integralNum = order.getTotalPrice().multiply(new BigDecimal(100)).intValue(); if ( integralNum> user.getGold()) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "积分数量不足"); } String remark = "订单" + order.getOrderNo() + "退还积分:" + integralNum; // 积分退款 highUserService.goldHandle(user.getId(), integralNum,2, 3, order.getId() , remark , order.getOrderNo()); } return ResponseMsgUtil.success("退款成功"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/externalOrderRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "对外订单退款") public ResponseData externalOrderRefund(@RequestParam(name = "paySerialNo", required = true) String paySerialNo, @RequestParam(name = "WxMchId", required = true) String WxMchId, @RequestParam(name = "payRealPrice", required = true) String payRealPrice) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "B94B5E62807FA56A7260AB581D8A1B48"); mapPost.put("merchId" , "20230394901"); mapPost.put("paySerialNo" , paySerialNo); mapPost.put("wxMchId" , WxMchId); mapPost.put("payRealPrice" , payRealPrice); mapPost.put("refundPrice" , payRealPrice); Map map = new HashMap<>(); map.put("apiKey" , "B94B5E62807FA56A7260AB581D8A1B48"); map.put("merchId" , "20230394901"); map.put("paySerialNo" , paySerialNo); map.put("wxMchId" , WxMchId); map.put("payRealPrice" , payRealPrice); map.put("refundPrice" , payRealPrice); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("https://hsg.dctpay.com/v1/order/externalOrderRefund" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getBlxCouponBalance", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询停车券") public ResponseData getBlxCouponBalance(@RequestParam(name = "phone", required = true) String phone) { try { highUserCardService.getBlxCouponBalance(phone); return ResponseMsgUtil.success("object"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryJsParking", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询捷顺停车场") public ResponseData queryJsParking(@RequestParam(name = "gps", required = true) String gps) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("gps" , gps); mapPost.put("range" , "1000"); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/queryJsParking" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getUserCouponPage", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询捷顺停车场") public ResponseData getUserCouponPage(@RequestParam(name = "phone", required = true) String phone) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("phone" , phone); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/getUserCouponPage" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryJsOrderList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询车牌订单列表信息") public ResponseData queryJsOrderList(@RequestParam(name = "carNo", required = true) String carNo, @RequestParam(name = "orderStatus", required = true) String orderStatus) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("orderStatus" , orderStatus); mapPost.put("carNo" , carNo); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/queryJsOrderList" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getCouponList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询车牌订单列表信息") public ResponseData getCouponList() { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2 FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/getCouponList" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/sendCoupon", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "发放券") public ResponseData sendCoupon(@RequestParam(name = "couponCode", required = true) String couponCode, @RequestParam(name = "receiverCount", required = true) String receiverCount, @RequestParam(name = "receiverPhone", required = true) String receiverPhone) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/getCouponList" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/preorder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "发起支付") public ResponseData preorder() { try { JSONObject object = new JSONObject(); object.put("outTradeNo" , "HUI" + OrderUtil.generateOrderNo()); object.put("transType" , "JSAPI"); object.put("payMode" , "WECHAT"); object.put("totalAmount" , "0.01"); object.put("profitSharing" , 0); object.put("subject" , "测试"); object.put("userId" , "oUGn_4unIjp90MY-oEXluY4laDrQ"); return ResponseMsgUtil.success(huiConfig.preorder(object)); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryGasInfoListByPage", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询团油门店") public ResponseData queryGasInfoListByPage() { try { HighMerchantModel merchant = highMerchantService.getMerchantById(39L); if (merchant == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到商户"); } JSONObject jsonObjectP = TuanYouConfig.queryGasInfoListByPage(1, 1000); JSONObject resultObjectP = jsonObjectP.getObject("result", JSONObject.class); for (int i = 1; i <= resultObjectP.getInteger("totalPageNum").intValue();i++) { JSONObject jsonObject = TuanYouConfig.queryGasInfoListByPage(i, 1000); JSONObject resultObject = jsonObject.getObject("result", JSONObject.class); JSONArray jsonArray = resultObject.getJSONArray("gasInfoList"); HighMerchantStore highMerchantStore; HighGasOilPrice highGasOilPrice; for (Object gasObject : jsonArray) { JSONObject object = JSONObject.parseObject(JSONObject.toJSONString(gasObject)); HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreByKey(object.getString("gasId")); if (store != null) { store.setType(1); store.setSourceType(2); store.setMerchantId(merchant.getId()); store.setCompanyId(merchant.getCompanyId()); store.setStoreKey(object.getString("gasId")); store.setStoreName(object.getString("gasName")); store.setStoreLogo(object.getString("gasLogoSmall")); store.setRegionId(object.getLong("provinceCode")); store.setRegionName(object.getString("provinceName")); store.setAddress(object.getString("gasAddress")); store.setLongitude(object.getString("gasAddressLongitude")); store.setLatitude(object.getString("gasAddressLatitude")); store.setStatus(object.getInteger("gasStatus")); store.setPrestoreType(0); store.setOperatorId(0L); store.setOperatorName("系统创建"); store.setUpdateTime(new Date()); store.setExt1(object.getString("gasSourceId")); highMerchantStoreService.updateMerchantStoreDetail(store); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); // 查询门店油号 highGasOilPrice = highGasOilPriceService.getGasOilPriceByStoreAndOilNo(store.getId(), oilPriceObject.getString("oilNo")); if (highGasOilPrice == null) { highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getString("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); highGasOilPrice.setStatus(GasOilPriceStatusEnum.status1.getStatus()); } else { highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getString("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); } highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } else { highMerchantStore = new HighMerchantStore(); highMerchantStore.setType(1); highMerchantStore.setSourceType(2); highMerchantStore.setMerchantId(merchant.getId()); highMerchantStore.setCompanyId(merchant.getCompanyId()); highMerchantStore.setStoreKey(object.getString("gasId")); highMerchantStore.setStoreName(object.getString("gasName")); highMerchantStore.setStoreLogo(object.getString("gasLogoSmall")); highMerchantStore.setRegionId(object.getLong("provinceCode")); highMerchantStore.setRegionName(object.getString("provinceName")); highMerchantStore.setAddress(object.getString("gasAddress")); highMerchantStore.setLongitude(object.getString("gasAddressLongitude")); highMerchantStore.setLatitude(object.getString("gasAddressLatitude")); highMerchantStore.setStatus(1); highMerchantStore.setPrestoreType(0); highMerchantStore.setOperatorId(0L); highMerchantStore.setOperatorName("系统创建"); highMerchantStore.setCreateTime(new Date()); highMerchantStore.setUpdateTime(new Date()); highMerchantStore.setExt1(object.getString("gasSourceId")); HighMerchantStoreModel merchantStoreModel = new HighMerchantStoreModel(); BeanUtils.copyProperties(highMerchantStore, merchantStoreModel); highMerchantStoreService.insertMerchantStore(merchantStoreModel); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(merchantStoreModel.getId()); highGasOilPrice.setOilNo(oilPriceObject.getString("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } } } return ResponseMsgUtil.success("完成"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/test", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "测试") public ResponseData test(@RequestParam(name = "no", required = true) String no) { try { JSONObject jsonObject = DianConfig.getGasInfoByGasId(no); return ResponseMsgUtil.success(jsonObject); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getGasInfoAll", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取全量油站") public ResponseData getGasInfoAll() { try { HighMerchantModel merchant = highMerchantService.getMerchantById(39L); JSONObject jsonObject = DianConfig.getGasInfoAll(); JSONArray resultObject = jsonObject.getObject("result", JSONArray.class); for (int i = 0; i < resultObject.size();i++) { Object objectData = resultObject.get(i); JSONObject object = JSONObject.parseObject(JSONObject.toJSONString(objectData)); HighMerchantStore highMerchantStore; HighGasOilPrice highGasOilPrice; HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreByKey(object.getString("jyzid")); SecRegion region = commonService.getRegionsByName(object.getString("province")); if (store != null) { store.setType(1); store.setSourceType(6); store.setMerchantId(merchant.getId()); store.setCompanyId(merchant.getCompanyId()); store.setStoreKey(object.getString("jyzid")); store.setStoreName(object.getString("mingcheng")); store.setStoreLogo(object.getString("tupian")); store.setRegionId(region.getRegionId()); store.setRegionName(object.getString("province")); store.setAddress(object.getString("dizhi")); store.setLongitude(object.getString("lng")); store.setLatitude(object.getString("lat")); store.setStatus(object.getInteger("zhuangtai")); store.setPrestoreType(0); store.setOperatorId(0L); store.setOperatorName("系统创建"); store.setUpdateTime(new Date()); store.setExt1(object.getString("gasSourceId")); highMerchantStoreService.updateMerchantStoreDetail(store); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); // 查询门店油号 highGasOilPrice = highGasOilPriceService.getGasOilPriceByStoreAndOilNo(store.getId(), oilPriceObject.getString("youhao")); if (highGasOilPrice == null) { highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getString("youhao")); highGasOilPrice.setOilNoName(oilPriceObject.getString("youhao") + "#"); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oiltype")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oiltype").equals("1") ? "汽油": "柴油"); highGasOilPrice.setStatus(GasOilPriceStatusEnum.status1.getStatus()); } else { highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getString("youhao")); highGasOilPrice.setOilNoName( oilPriceObject.getString("youhao") + "#"); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oiltype")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oiltype").equals("1") ? "汽油": "柴油"); } highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } else { highMerchantStore = new HighMerchantStore(); highMerchantStore.setType(1); highMerchantStore.setSourceType(6); highMerchantStore.setMerchantId(merchant.getId()); highMerchantStore.setCompanyId(merchant.getCompanyId()); highMerchantStore.setStoreKey(object.getString("jyzid")); highMerchantStore.setStoreName(object.getString("mingcheng")); highMerchantStore.setStoreLogo(object.getString("tupian")); highMerchantStore.setRegionId(region.getRegionId()); highMerchantStore.setRegionName(object.getString("province")); highMerchantStore.setAddress(object.getString("dizhi")); highMerchantStore.setLongitude(object.getString("lng")); highMerchantStore.setLatitude(object.getString("lat")); highMerchantStore.setStatus(1); highMerchantStore.setPrestoreType(0); highMerchantStore.setOperatorId(0L); highMerchantStore.setOperatorName("系统创建"); highMerchantStore.setCreateTime(new Date()); highMerchantStore.setUpdateTime(new Date()); highMerchantStore.setExt1(object.getString("gasSourceId")); HighMerchantStoreModel merchantStoreModel = new HighMerchantStoreModel(); BeanUtils.copyProperties(highMerchantStore, merchantStoreModel); highMerchantStoreService.insertMerchantStore(merchantStoreModel); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(merchantStoreModel.getId()); highGasOilPrice.setOilNo(oilPriceObject.getString("youhao")); highGasOilPrice.setOilNoName(oilPriceObject.getString("youhao") + "#"); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oiltype")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oiltype").equals("1") ? "汽油": "柴油"); highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } } return ResponseMsgUtil.success(jsonObject); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getOrderPay", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "getOrderPay") public ResponseData getOrderPay(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOilCardOrder highOilCardOrder = highOilCardOrderService.findOrder(orderNo); highOilCardOrder.setStatus(2); JSONObject object = KytcService.getOrderPay(highOilCardOrder.getThirdOrderNo() , highOilCardOrder.getPrice() , highOilCardOrder.getCardNo()); highOilCardOrder.setExt1(object.toJSONString()); highOilCardOrderService.updateOilCardOrder(highOilCardOrder); return ResponseMsgUtil.success("成功"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getOrderInfo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "getOrderInfo") public ResponseData getOrderInfo(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOilCardOrder highOilCardOrder = highOilCardOrderService.findOrder(orderNo); JSONObject object = KytcService.getOrderInfo(highOilCardOrder.getThirdOrderNo()); highOilCardOrder.setExt2(object.toJSONString()); if (object.getBoolean("State") == true) { JSONObject jsonObject = object.getJSONObject("Data"); if (jsonObject.getInteger("OilOrderState") == 2) { highOilCardOrder.setStatus(3); HighOrder highOrder = highOrderService.getOrderByOrderNo(highOilCardOrder.getOrderNo()); highOrder.setOrderStatus(3); highOrder.getHighChildOrderList().get(0).setChildOrderStatus(3); highOrderService.updateOrder(highOrder); } } highOilCardOrderService.updateOilCardOrder(highOilCardOrder); return ResponseMsgUtil.success("成功"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/synCouponRule", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取卡券") public ResponseData synCouponRule() { try { return ResponseMsgUtil.success(ScPetroConfig.synCouponRule()); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } } \ No newline at end of file + package com.bweb.controller; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.utils.HttpsUtils; import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.WxUtils; import com.hai.config.*; import com.hai.entity.*; import com.hai.enum_type.GasOilPriceStatusEnum; import com.hai.model.HighMerchantModel; import com.hai.model.HighMerchantStoreModel; import com.hai.model.ResponseData; import com.hai.openApi.config.BlxConfig; import com.hai.order.service.OrderService; import com.hai.order.type.OrderProductType; import com.hai.order.type.OrderRefundOpUserType; import com.hai.order.utils.OrderUtil; import com.hai.pay.channel.huipay.config.HuiConfig; import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.bouncycastle.LICENSE; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.io.FileOutputStream; import java.io.InputStream; import java.math.BigDecimal; import java.net.URL; import java.net.URLConnection; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/test") @Api(value = "订单接口") public class HighTestController { private static Logger log = LoggerFactory.getLogger(HighTestController.class); @Resource private OrderService orderService; @Resource private HighUserCardService highUserCardService; @Resource private HighOrderService highOrderService; @Resource private HighUserService highUserService; @Resource private HighMerchantService highMerchantService; @Resource private HighMerchantStoreService highMerchantStoreService; @Resource private HighGasOilPriceService highGasOilPriceService; @Resource private HuiConfig huiConfig; @Resource private CommonService commonService; @Resource private HighOilCardOrderService highOilCardOrderService; @RequestMapping(value="/resolveResponse",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "解析") public ResponseData resolveResponse( @RequestParam(name = "data", required = false) String data ) { try { JSONObject cardInfoObject = HuiLianTongUnionCardConfig.resolveResponse(data); return ResponseMsgUtil.success(cardInfoObject); } catch (Exception e) { log.error("getUserByTelephone",e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getHuiLianTongCardConsume", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询汇联通工会卡消费记录") public ResponseData getHuiLianTongCardConsume(@RequestParam(name = "businessType", required = true) String businessType, @RequestParam(name = "cardNo", required = true) String cardNo, @RequestParam(name = "sdate", required = true) Long sdate, @RequestParam(name = "edate", required = true) Long edate, @RequestParam(name = "pageNum", required = true) Integer pageNum, @RequestParam(name = "pageSize", required = true) Integer pageSize, HttpServletRequest request) { try { JSONObject consumptionRecord = HuiLianTongUnionCardConfig.queryConsumptionRecordByBusiness(businessType, cardNo, sdate, edate, pageNum, pageSize); if (StringUtils.isBlank(consumptionRecord.getString("data"))) { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQUEST_ERROR, ""); } JSONArray array = HuiLianTongUnionCardConfig.resolveResponse(consumptionRecord.getString("data")).getJSONArray("records"); return ResponseMsgUtil.success(array); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardConsume() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/createOrder", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "创建订单") public ResponseData createOrder(@RequestBody JSONObject object) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("timetable" , new Date().getTime()); mapPost.put("orderNo" , "TEST" + OrderUtil.generateOrderNo()); mapPost.put("productType" , object.getString("productType")); mapPost.put("content" , object.getJSONObject("content").toString()); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/order/createOrder" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/payOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "支付订单") public ResponseData payOrder(@RequestParam(name = "mchOrderNo", required = true) String mchOrderNo) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("mchOrderNo" , mchOrderNo); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("mchOrderNo" , mchOrderNo); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/order/orderPay" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryOrderDetail", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询订单详情") public ResponseData queryOrderDetail(@RequestParam(name = "mchOrderNo", required = true) String mchOrderNo) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("mchOrderNo" , mchOrderNo); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("mchOrderNo" , mchOrderNo); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/order/queryOrderDetail" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/deposit", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "工会卡充值") public ResponseData deposit(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); HighChildOrder highChildOrder = order.getHighChildOrderList().get(0); if (order.getOrderStatus() != 2) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单状态错误"); } // 汇联通充值 String goodsDesc = "汇联通充值"+order.getPayPrice()+"元"; String tranDesc = ""; String businessType = "ghk_deposit"; String orderNoAgain = OrderUtil.generateOrderNo(); order.setOrderStatus(Integer.valueOf(3)); order.setRemarks("工会卡再次充值订单号" + orderNoAgain); highOrderService.updateOrder(order); // 汇联通卡充值 JSONObject deposit = HuiLianTongUnionCardConfig.deposit(orderNoAgain, highChildOrder.getGoodsSpecName(), order.getPayPrice(), businessType, order.getPaySerialNo(), goodsDesc); return ResponseMsgUtil.success( HuiLianTongUnionCardConfig.resolveResponse(deposit.getString("data"))); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getHuiLianTongCardByCardNo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据卡号查询汇联通工会卡详情") public ResponseData getHuiLianTongCardByCardNo(@RequestParam(name = "cardNo", required = true) String cardNo) { try { // 查询工会卡 JSONObject cardInfo = HuiLianTongUnionCardConfig.queryBalance(cardNo); JSONObject resolveResponse = HuiLianTongUnionCardConfig.resolveResponse(cardInfo.getString("data")); return ResponseMsgUtil.success(resolveResponse); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardByCardNo() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/consumption", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "工会卡支付") public ResponseData consumption(@RequestParam(name = "payRealPrice", required = true) BigDecimal payRealPrice, @RequestParam(name = "cardNo", required = true) String cardNo) { try { String goodsDesc = ""; String tranDesc = ""; String instCode = "11101527"; String businessType = "hisen_consume"; // 工会卡支付 JSONObject consumption = HuiLianTongUnionCardConfig.consumption(OrderUtil.generateOrderNo(), cardNo, payRealPrice, businessType, instCode, goodsDesc, tranDesc); if (!consumption.getString("respCode").equals("0000")) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumption.getString("respMessage")); } // 响应参数 JSONObject consumptionResult = HuiLianTongUnionCardConfig.resolveResponse(consumption.getString("data")); if (consumptionResult.getBoolean("success") != true) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumptionResult.getString("message")); } return ResponseMsgUtil.success(consumptionResult); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardByCardNo() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/refundOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "工会卡退款") public ResponseData refundOrder(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); if (order.getOrderStatus() != 2) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单状态错误"); } orderService.refundOrder(order, OrderProductType.getDataByType(order.getProductType()).getName() + "退款",OrderRefundOpUserType.TYPE1, null, "系统自动退款"); if (order.getProductType().equals(4)) { HighUser user = highUserService.findByUserId(order.getMemId()); // 获取应退款积分 int integralNum = order.getTotalPrice().multiply(new BigDecimal(100)).intValue(); if ( integralNum> user.getGold()) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "积分数量不足"); } String remark = "订单" + order.getOrderNo() + "退还积分:" + integralNum; // 积分退款 highUserService.goldHandle(user.getId(), integralNum,2, 3, order.getId() , remark , order.getOrderNo()); } return ResponseMsgUtil.success("退款成功"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/externalOrderRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "对外订单退款") public ResponseData externalOrderRefund(@RequestParam(name = "paySerialNo", required = true) String paySerialNo, @RequestParam(name = "WxMchId", required = true) String WxMchId, @RequestParam(name = "payRealPrice", required = true) String payRealPrice) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "B94B5E62807FA56A7260AB581D8A1B48"); mapPost.put("merchId" , "20230394901"); mapPost.put("paySerialNo" , paySerialNo); mapPost.put("wxMchId" , WxMchId); mapPost.put("payRealPrice" , payRealPrice); mapPost.put("refundPrice" , payRealPrice); Map map = new HashMap<>(); map.put("apiKey" , "B94B5E62807FA56A7260AB581D8A1B48"); map.put("merchId" , "20230394901"); map.put("paySerialNo" , paySerialNo); map.put("wxMchId" , WxMchId); map.put("payRealPrice" , payRealPrice); map.put("refundPrice" , payRealPrice); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("https://hsg.dctpay.com/v1/order/externalOrderRefund" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getBlxCouponBalance", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询停车券") public ResponseData getBlxCouponBalance(@RequestParam(name = "phone", required = true) String phone) { try { highUserCardService.getBlxCouponBalance(phone); return ResponseMsgUtil.success("object"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryJsParking", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询捷顺停车场") public ResponseData queryJsParking(@RequestParam(name = "gps", required = true) String gps) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("gps" , gps); mapPost.put("range" , "1000"); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/queryJsParking" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getUserCouponPage", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询捷顺停车场") public ResponseData getUserCouponPage(@RequestParam(name = "phone", required = true) String phone) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("phone" , phone); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/getUserCouponPage" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryJsOrderList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询车牌订单列表信息") public ResponseData queryJsOrderList(@RequestParam(name = "carNo", required = true) String carNo, @RequestParam(name = "orderStatus", required = true) String orderStatus) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("orderStatus" , orderStatus); mapPost.put("carNo" , carNo); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/queryJsOrderList" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getCouponList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询车牌订单列表信息") public ResponseData getCouponList() { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2 FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/getCouponList" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/sendCoupon", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "发放券") public ResponseData sendCoupon(@RequestParam(name = "couponCode", required = true) String couponCode, @RequestParam(name = "receiverCount", required = true) String receiverCount, @RequestParam(name = "receiverPhone", required = true) String receiverPhone) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/getCouponList" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/preorder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "发起支付") public ResponseData preorder() { try { JSONObject object = new JSONObject(); object.put("outTradeNo" , "HUI" + OrderUtil.generateOrderNo()); object.put("transType" , "JSAPI"); object.put("payMode" , "WECHAT"); object.put("totalAmount" , "0.01"); object.put("profitSharing" , 0); object.put("subject" , "测试"); object.put("userId" , "oUGn_4unIjp90MY-oEXluY4laDrQ"); return ResponseMsgUtil.success(huiConfig.preorder(object)); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryGasInfoListByPage", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询团油门店") public ResponseData queryGasInfoListByPage() { try { HighMerchantModel merchant = highMerchantService.getMerchantById(39L); if (merchant == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到商户"); } JSONObject jsonObjectP = TuanYouConfig.queryGasInfoListByPage(1, 1000); JSONObject resultObjectP = jsonObjectP.getObject("result", JSONObject.class); for (int i = 1; i <= resultObjectP.getInteger("totalPageNum").intValue();i++) { JSONObject jsonObject = TuanYouConfig.queryGasInfoListByPage(i, 1000); JSONObject resultObject = jsonObject.getObject("result", JSONObject.class); JSONArray jsonArray = resultObject.getJSONArray("gasInfoList"); HighMerchantStore highMerchantStore; HighGasOilPrice highGasOilPrice; for (Object gasObject : jsonArray) { JSONObject object = JSONObject.parseObject(JSONObject.toJSONString(gasObject)); HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreByKey(object.getString("gasId")); if (store != null) { store.setType(1); store.setSourceType(2); store.setMerchantId(merchant.getId()); store.setCompanyId(merchant.getCompanyId()); store.setStoreKey(object.getString("gasId")); store.setStoreName(object.getString("gasName")); store.setStoreLogo(object.getString("gasLogoSmall")); store.setRegionId(object.getLong("provinceCode")); store.setRegionName(object.getString("provinceName")); store.setAddress(object.getString("gasAddress")); store.setLongitude(object.getString("gasAddressLongitude")); store.setLatitude(object.getString("gasAddressLatitude")); store.setStatus(object.getInteger("gasStatus")); store.setPrestoreType(0); store.setOperatorId(0L); store.setOperatorName("系统创建"); store.setUpdateTime(new Date()); store.setExt1(object.getString("gasSourceId")); highMerchantStoreService.updateMerchantStoreDetail(store); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); // 查询门店油号 highGasOilPrice = highGasOilPriceService.getGasOilPriceByStoreAndOilNo(store.getId(), oilPriceObject.getString("oilNo")); if (highGasOilPrice == null) { highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getString("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); highGasOilPrice.setStatus(GasOilPriceStatusEnum.status1.getStatus()); } else { highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getString("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); } highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } else { highMerchantStore = new HighMerchantStore(); highMerchantStore.setType(1); highMerchantStore.setSourceType(2); highMerchantStore.setMerchantId(merchant.getId()); highMerchantStore.setCompanyId(merchant.getCompanyId()); highMerchantStore.setStoreKey(object.getString("gasId")); highMerchantStore.setStoreName(object.getString("gasName")); highMerchantStore.setStoreLogo(object.getString("gasLogoSmall")); highMerchantStore.setRegionId(object.getLong("provinceCode")); highMerchantStore.setRegionName(object.getString("provinceName")); highMerchantStore.setAddress(object.getString("gasAddress")); highMerchantStore.setLongitude(object.getString("gasAddressLongitude")); highMerchantStore.setLatitude(object.getString("gasAddressLatitude")); highMerchantStore.setStatus(1); highMerchantStore.setPrestoreType(0); highMerchantStore.setOperatorId(0L); highMerchantStore.setOperatorName("系统创建"); highMerchantStore.setCreateTime(new Date()); highMerchantStore.setUpdateTime(new Date()); highMerchantStore.setExt1(object.getString("gasSourceId")); HighMerchantStoreModel merchantStoreModel = new HighMerchantStoreModel(); BeanUtils.copyProperties(highMerchantStore, merchantStoreModel); highMerchantStoreService.insertMerchantStore(merchantStoreModel); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(merchantStoreModel.getId()); highGasOilPrice.setOilNo(oilPriceObject.getString("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } } } return ResponseMsgUtil.success("完成"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/test", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "测试") public ResponseData test(@RequestParam(name = "no", required = true) String no) { try { JSONObject jsonObject = DianConfig.getGasInfoByGasId(no); return ResponseMsgUtil.success(jsonObject); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getGasInfoAll", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取全量油站") public ResponseData getGasInfoAll() { try { HighMerchantModel merchant = highMerchantService.getMerchantById(39L); JSONObject jsonObject = DianConfig.getGasInfoAll(); JSONArray resultObject = jsonObject.getObject("result", JSONArray.class); for (int i = 0; i < resultObject.size();i++) { Object objectData = resultObject.get(i); JSONObject object = JSONObject.parseObject(JSONObject.toJSONString(objectData)); HighMerchantStore highMerchantStore; HighGasOilPrice highGasOilPrice; HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreByKey(object.getString("jyzid")); SecRegion region = commonService.getRegionsByName(object.getString("province")); if (store != null) { store.setType(1); store.setSourceType(6); store.setMerchantId(merchant.getId()); store.setCompanyId(merchant.getCompanyId()); store.setStoreKey(object.getString("jyzid")); store.setStoreName(object.getString("mingcheng")); store.setStoreLogo(object.getString("tupian")); store.setRegionId(region.getRegionId()); store.setRegionName(object.getString("province")); store.setAddress(object.getString("dizhi")); store.setLongitude(object.getString("lng")); store.setLatitude(object.getString("lat")); store.setStatus(object.getInteger("zhuangtai")); store.setPrestoreType(0); store.setOperatorId(0L); store.setOperatorName("系统创建"); store.setUpdateTime(new Date()); store.setExt1(object.getString("gasSourceId")); highMerchantStoreService.updateMerchantStoreDetail(store); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); // 查询门店油号 highGasOilPrice = highGasOilPriceService.getGasOilPriceByStoreAndOilNo(store.getId(), oilPriceObject.getString("youhao")); if (highGasOilPrice == null) { highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getString("youhao")); highGasOilPrice.setOilNoName(oilPriceObject.getString("youhao") + "#"); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oiltype")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oiltype").equals("1") ? "汽油": "柴油"); highGasOilPrice.setStatus(GasOilPriceStatusEnum.status1.getStatus()); } else { highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getString("youhao")); highGasOilPrice.setOilNoName( oilPriceObject.getString("youhao") + "#"); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oiltype")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oiltype").equals("1") ? "汽油": "柴油"); } highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } else { highMerchantStore = new HighMerchantStore(); highMerchantStore.setType(1); highMerchantStore.setSourceType(6); highMerchantStore.setMerchantId(merchant.getId()); highMerchantStore.setCompanyId(merchant.getCompanyId()); highMerchantStore.setStoreKey(object.getString("jyzid")); highMerchantStore.setStoreName(object.getString("mingcheng")); highMerchantStore.setStoreLogo(object.getString("tupian")); highMerchantStore.setRegionId(region.getRegionId()); highMerchantStore.setRegionName(object.getString("province")); highMerchantStore.setAddress(object.getString("dizhi")); highMerchantStore.setLongitude(object.getString("lng")); highMerchantStore.setLatitude(object.getString("lat")); highMerchantStore.setStatus(1); highMerchantStore.setPrestoreType(0); highMerchantStore.setOperatorId(0L); highMerchantStore.setOperatorName("系统创建"); highMerchantStore.setCreateTime(new Date()); highMerchantStore.setUpdateTime(new Date()); highMerchantStore.setExt1(object.getString("gasSourceId")); HighMerchantStoreModel merchantStoreModel = new HighMerchantStoreModel(); BeanUtils.copyProperties(highMerchantStore, merchantStoreModel); highMerchantStoreService.insertMerchantStore(merchantStoreModel); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(merchantStoreModel.getId()); highGasOilPrice.setOilNo(oilPriceObject.getString("youhao")); highGasOilPrice.setOilNoName(oilPriceObject.getString("youhao") + "#"); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oiltype")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oiltype").equals("1") ? "汽油": "柴油"); highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } } return ResponseMsgUtil.success(jsonObject); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getOrderPay", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "getOrderPay") public ResponseData getOrderPay(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOilCardOrder highOilCardOrder = highOilCardOrderService.findOrder(orderNo); highOilCardOrder.setStatus(2); JSONObject object = KytcService.getOrderPay(highOilCardOrder.getThirdOrderNo() , highOilCardOrder.getPrice() , highOilCardOrder.getCardNo()); highOilCardOrder.setExt1(object.toJSONString()); highOilCardOrderService.updateOilCardOrder(highOilCardOrder); return ResponseMsgUtil.success("成功"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getOrderInfo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "getOrderInfo") public ResponseData getOrderInfo(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOilCardOrder highOilCardOrder = highOilCardOrderService.findOrder(orderNo); JSONObject object = KytcService.getOrderInfo(highOilCardOrder.getThirdOrderNo()); highOilCardOrder.setExt2(object.toJSONString()); if (object.getBoolean("State") == true) { JSONObject jsonObject = object.getJSONObject("Data"); if (jsonObject.getInteger("OilOrderState") == 2) { highOilCardOrder.setStatus(3); HighOrder highOrder = highOrderService.getOrderByOrderNo(highOilCardOrder.getOrderNo()); highOrder.setOrderStatus(3); highOrder.getHighChildOrderList().get(0).setChildOrderStatus(3); highOrderService.updateOrder(highOrder); } } highOilCardOrderService.updateOilCardOrder(highOilCardOrder); return ResponseMsgUtil.success("成功"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/synCouponRule", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取卡券") public ResponseData synCouponRule() { try { return ResponseMsgUtil.success(ScPetroConfig.synCouponRule()); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getCoupon", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "卡券下单") public ResponseData getCoupon() { try { JSONObject jsonObject = ScPetroConfig.getCoupon("16000443991501" , "18090580471" , OrderUtil.generateOrderNo()); String data = ScPetroConfig.decrypt(jsonObject.getString("biz_content")); JSONObject object = JSONObject.parseObject(data); return ResponseMsgUtil.success(object); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } } \ No newline at end of file diff --git a/hai-order/src/main/java/com/web/controller/OrderController.java b/hai-order/src/main/java/com/web/controller/OrderController.java index f87c4614..329fe205 100644 --- a/hai-order/src/main/java/com/web/controller/OrderController.java +++ b/hai-order/src/main/java/com/web/controller/OrderController.java @@ -282,7 +282,7 @@ public class OrderController { public ResponseData getDetailByOrderNo(@RequestParam(name = "orderNo", required = false) String orderNo, @RequestParam(name = "paySerialNo", required = false) String paySerialNo, @RequestParam(name = "payChannelOrderNo", required = false) String payChannelOrderNo - ) { + ) { try { if (StringUtils.isBlank(orderNo) && StringUtils.isBlank(paySerialNo) && StringUtils.isBlank(payChannelOrderNo)) { throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_ORDER, ""); @@ -380,7 +380,7 @@ public class OrderController { if (userModel == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.USE_VISIT_ILLEGAL, ""); } - + Map param = new HashMap<>(); param.put("userId", userModel.getHighUser().getId()); param.put("title", title); diff --git a/hai-order/src/main/java/com/web/controller/notify/GroupOrderController.java b/hai-order/src/main/java/com/web/controller/notify/GroupOrderController.java index aca574e3..4f501969 100644 --- a/hai-order/src/main/java/com/web/controller/notify/GroupOrderController.java +++ b/hai-order/src/main/java/com/web/controller/notify/GroupOrderController.java @@ -63,10 +63,15 @@ public class GroupOrderController { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到相关核销券!"); } - HighOrder highOrder = highOrderService.getOrderById(highGroupCode.getId()); + + HighOrder highOrder = highOrderService.getOrderById(highGroupCode.getOrderId()); HighGroupOrder highGroupOrder = groupCodeService.findGroupOrder(highOrder.getOrderNo()); + if (highGroupCode.getStatus() != 1 || highOrder.getOrderStatus() == 3) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已核销不可再次核销!"); + } + highGroupCode.setStatus(2); highGroupCode.setUpdateTime(new Date()); groupCodeService.updateGroupCode(highGroupCode); diff --git a/hai-order/src/main/java/com/web/controller/notify/ScNotifyController.java b/hai-order/src/main/java/com/web/controller/notify/ScNotifyController.java new file mode 100644 index 00000000..4bc0a00c --- /dev/null +++ b/hai-order/src/main/java/com/web/controller/notify/ScNotifyController.java @@ -0,0 +1,103 @@ +package com.web.controller.notify; + +import com.alibaba.fastjson.JSONObject; +import com.hai.common.utils.AESTool; +import com.hai.common.utils.MD5Util; +import com.hai.config.ChongQingCNPCService; +import com.hai.config.CommonSysConst; +import com.hai.dao.HighGasOrderPushMapper; +import com.hai.entity.HighGasOrderPush; +import com.hai.enum_type.OrderPushType; +import com.hai.service.HighCouponCodeOtherService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +import javax.annotation.Resource; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +@Controller +@RequestMapping(value = "/scNotify") +@Api(value = "四川业务通知") +public class ScNotifyController { + + private static final Logger log = LoggerFactory.getLogger(ScNotifyController.class); + + @Resource + private HighCouponCodeOtherService couponCodeOtherService; + + @Resource + private HighGasOrderPushMapper highGasOrderPushMapper; + + @RequestMapping(value = "/scPetroNotify", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "重庆中石油通知") + public Object scPetroNotify(@RequestBody String paramsStr) { + System.out.println(paramsStr); + log.info("重庆中石油核销通知"); + log.info("通知参数:" + paramsStr); + try { + if (StringUtils.isNotBlank(paramsStr)) { + + JSONObject sendMessage = JSONObject.parseObject(paramsStr).getJSONObject("sendMessage"); + JSONObject body = ChongQingCNPCService.decryptBody(sendMessage.getString("body")); + HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); + highGasOrderPush.setType(OrderPushType.type10.getType()); + highGasOrderPush.setOrderNo(body.getString("tradeId")); + highGasOrderPush.setCreateTime(new Date()); + highGasOrderPush.setRequestContent("核销回调"); + highGasOrderPush.setReturnContent(paramsStr); + highGasOrderPushMapper.insert(highGasOrderPush); + + couponCodeOtherService.cqCnpcUseNotify(body); + Map param = new HashMap<>(); + param.put("status", 1); + param.put("msg", "成功"); + String verifyCode = AESTool.Encrypt(JSONObject.toJSONString(param), CommonSysConst.getSysConfig().getChongQingCnpcMerKey()); + + Map returnContent = new HashMap<>(); + Map returnPostMessage = new HashMap<>(); + + Map returnHead = new HashMap<>(); + returnHead.put("verifyCode", MD5Util.encode((verifyCode + CommonSysConst.getSysConfig().getChongQingCnpcMerKey()).getBytes()).toLowerCase()); + returnHead.put("requestType", "couponNotice"); + returnPostMessage.put("head", returnHead); + + returnPostMessage.put("body", verifyCode); + returnContent.put("postMessage", returnPostMessage); + return returnContent; + } else { + Map param = new HashMap<>(); + param.put("status", 0); + param.put("msg", "解析参数错误"); + String verifyCode = AESTool.Encrypt(JSONObject.toJSONString(param), CommonSysConst.getSysConfig().getChongQingCnpcMerKey()); + + Map returnContent = new HashMap<>(); + Map returnPostMessage = new HashMap<>(); + + Map returnHead = new HashMap<>(); + returnHead.put("verifyCode", MD5Util.encode((verifyCode + CommonSysConst.getSysConfig().getChongQingCnpcMerKey()).getBytes()).toLowerCase()); + returnHead.put("requestType", "couponNotice"); + returnPostMessage.put("head", returnHead); + + returnPostMessage.put("body", verifyCode); + returnContent.put("postMessage", returnPostMessage); + return returnContent; + } + } catch (Exception e) { + log.info("重庆中石油核销通知业务出现异常", e); + return null; + // return ResponseMsgUtil.exception(e); + } + } + +} diff --git a/hai-service/src/main/java/com/hai/config/ScPetroConfig.java b/hai-service/src/main/java/com/hai/config/ScPetroConfig.java index a0a83889..55523db1 100644 --- a/hai-service/src/main/java/com/hai/config/ScPetroConfig.java +++ b/hai-service/src/main/java/com/hai/config/ScPetroConfig.java @@ -31,6 +31,14 @@ public class ScPetroConfig { private final static String charset = "UTF-8"; + /** + * @Author Sum1Dream + * @Name synCouponRule + * @Description // 获取券列表 + * @Date 11:17 2023/11/17 + + * @return com.alibaba.fastjson.JSONObject + */ public static JSONObject synCouponRule() throws Exception{ Map req = new HashMap<>(); req.put("version", version); @@ -56,6 +64,113 @@ public class ScPetroConfig { return HttpsUtils.doPost(reqUrl + "syn-coupon-rule/v1", req , new HashMap<>()); } + + /** + * @Author Sum1Dream + * @Name getCoupon + * @Description // 获取券code + * @Date 11:19 2023/11/17 + * @Param code + * @Param phone + * @Param orderNo + * @return com.alibaba.fastjson.JSONObject + */ + public static JSONObject getCoupon(String code , String phone , String orderNo) throws Exception{ + Map req = new HashMap<>(); + req.put("version", version); + req.put("appid", ScPetroAppid); + req.put("signtype", "MD5"); + req.put("timestamp", DateUtil.date2String(new Date(), DateUtil.Y_M_D_HMS)); + + // 业务数据 + JSONObject billBizContent = new JSONObject(); + billBizContent.put("request_code" , code); + billBizContent.put("user_code" , phone); + billBizContent.put("out_trade_no" , orderNo); + + //业务内容加密 + String bizContent = JSONObject.toJSONString(billBizContent); + bizContent = encrypt(bizContent, ScPetroAesKey); + + //加密的内容放到参数中 + req.put("biz_content", bizContent); + //生成签名 + String sign = createSign(req, ScPetroAppKey); + //签名放到参数中 + req.put("sign", sign); + // 请求接口 + return HttpsUtils.doPost(reqUrl + "get-coupon", req , new HashMap<>()); + } + + /** + * @Author Sum1Dream + * @Name couponDetail + * @Description // 获取静态码 + * @Date 11:20 2023/11/17 + * @Param ticketNum + * @return com.alibaba.fastjson.JSONObject + */ + public static JSONObject couponDetail(String ticketNum) throws Exception{ + Map req = new HashMap<>(); + req.put("version", version); + req.put("appid", ScPetroAppid); + req.put("signtype", "MD5"); + req.put("timestamp", DateUtil.date2String(new Date(), DateUtil.Y_M_D_HMS)); + + // 业务数据 + JSONObject billBizContent = new JSONObject(); + billBizContent.put("ticket_num" , ticketNum); + + + //业务内容加密 + String bizContent = JSONObject.toJSONString(billBizContent); + bizContent = encrypt(bizContent, ScPetroAesKey); + + //加密的内容放到参数中 + req.put("biz_content", bizContent); + //生成签名 + String sign = createSign(req, ScPetroAppKey); + //签名放到参数中 + req.put("sign", sign); + // 请求接口 + return HttpsUtils.doPost(reqUrl + "couponDetail", req , new HashMap<>()); + } + + /** + * @Author Sum1Dream + * @Name cancelCoupon + * @Description // 作废下单 + * @Date 11:21 2023/11/17 + * @Param ticketNum + * @return com.alibaba.fastjson.JSONObject + */ + public static JSONObject cancelCoupon(String ticketNum) throws Exception{ + Map req = new HashMap<>(); + req.put("version", version); + req.put("appid", ScPetroAppid); + req.put("signtype", "MD5"); + req.put("timestamp", DateUtil.date2String(new Date(), DateUtil.Y_M_D_HMS)); + + // 业务数据 + JSONObject billBizContent = new JSONObject(); + billBizContent.put("ticket_num" , ticketNum); + + + //业务内容加密 + String bizContent = JSONObject.toJSONString(billBizContent); + bizContent = encrypt(bizContent, ScPetroAesKey); + + //加密的内容放到参数中 + req.put("biz_content", bizContent); + //生成签名 + String sign = createSign(req, ScPetroAppKey); + //签名放到参数中 + req.put("sign", sign); + // 请求接口 + return HttpsUtils.doPost(reqUrl + "cancelCoupon", req , new HashMap<>()); + } + + /** * @param params 签名params null和""不参与签名 * @param key 密钥 @@ -128,9 +243,9 @@ public class ScPetroConfig { * @Param key * @return java.lang.String */ - public static String decrypt(final String content, final String key) { + public static String decrypt(final String content) { try { - byte[] raw = key.getBytes("UTF-8"); + byte[] raw = ScPetroAesKey.getBytes("UTF-8"); SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES"); Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); cipher.init(2, skeySpec); 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 f1edf1bd..af517c74 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 @@ -13,6 +13,7 @@ import com.hai.common.utils.ResponseMsgUtil; import com.hai.config.ChongQingCNPCService; import com.hai.config.HuiLianTongConfig; import com.hai.config.HuiLianTongUnionCardConfig; +import com.hai.config.ScPetroConfig; import com.hai.dao.*; import com.hai.entity.*; import com.hai.enum_type.OrderPushType; @@ -361,6 +362,33 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { couponCodeOther.setCreateTime(new Date()); highCouponCodeOtherMapper.insert(couponCodeOther); } + } else if (coupon.getCouponSource().equals(7)) { + if (StringUtils.isBlank(phone)) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请填写客户手机号"); + } + if (!MemberValidateUtil.validatePhone(phone)) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "手机号格式错误"); + } + + // 发放卡券 + JSONObject jsonObject = ScPetroConfig.getCoupon(coupon.getCouponKey() , phone , couponAgentCode.getConvertCode()); + + if (!jsonObject.getString("code").equals("1")) { + throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "当前卡券不可购买"); + } + + String data = ScPetroConfig.decrypt(jsonObject.getString("biz_content")); + JSONObject object = JSONObject.parseObject(data); + + HighCouponCodeOther couponCodeOther = new HighCouponCodeOther(); + couponCodeOther.setType(5); + couponCodeOther.setCouponAgentCodeId(couponAgentCodeId); + couponCodeOther.setCouTypeCode(object.getString("request_code")); + couponCodeOther.setCouNo(object.getString("ticket_num")); + couponCodeOther.setActiveTime(new Date()); + couponCodeOther.setStatus(20); + couponCodeOther.setCreateTime(new Date()); + couponCodeOtherService.insertCouponCodeOther(couponCodeOther); } Map map = new HashMap<>(); diff --git a/hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java index ef6a7a99..4b68c8bc 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java @@ -11,6 +11,7 @@ import com.hai.common.utils.IDGenerator; import com.hai.config.ChongQingCNPCService; import com.hai.config.HuiLianTongConfig; import com.hai.config.HuiLianTongUnionCardConfig; +import com.hai.config.ScPetroConfig; import com.hai.dao.HighChildOrderMapper; import com.hai.dao.HighCouponCodeMapper; import com.hai.dao.HighCouponCodeMapperExt; @@ -22,6 +23,7 @@ import com.hai.openApi.config.BlxConfig; import com.hai.openApi.service.ApiBlxCouponService; import com.hai.order.service.OrderService; import com.hai.order.type.OrderStatus; +import com.hai.order.utils.OrderUtil; import com.hai.service.*; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; @@ -525,6 +527,41 @@ public class HighCouponCodeServiceImpl implements HighCouponCodeService { throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , object.getString("msg")); } } + } else if (coupon.getCouponSource().equals(7)) { + // 发放卡券 + JSONObject jsonObject = ScPetroConfig.getCoupon(coupon.getCouponKey() , order.getMemPhone() , order.getOrderNo()); + + if (!jsonObject.getString("code").equals("1")) { + throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "当前卡券不可购买"); + } + + String data = ScPetroConfig.decrypt(jsonObject.getString("biz_content")); + JSONObject object = JSONObject.parseObject(data); + + HighCouponCodeOther couponCodeOther = new HighCouponCodeOther(); + couponCodeOther.setType(5); + couponCodeOther.setOrderId(order.getId()); + couponCodeOther.setChildOrderId(childOrder.getId()); + couponCodeOther.setCouTypeCode(object.getString("request_code")); + couponCodeOther.setCouNo(object.getString("ticket_num")); + couponCodeOther.setActiveTime(new Date()); + couponCodeOther.setStatus(20); + couponCodeOther.setCreateTime(new Date()); + couponCodeOtherService.insertCouponCodeOther(couponCodeOther); + + // 卡卷关联用户 + HighUserCoupon highUserCoupon = new HighUserCoupon(); + highUserCoupon.setMerchantId(coupon.getMerchantId()); + highUserCoupon.setCouponId(coupon.getId()); + highUserCoupon.setOrderId(order.getId()); + highUserCoupon.setChildOrderId(childOrder.getId()); + highUserCoupon.setUserId(order.getMemId()); + highUserCoupon.setCreateTime(new Date()); + highUserCoupon.setQrCodeImg(couponCodeOther.getCouNo()); + highUserCoupon.setUseEndTime(couponCodeOther.getValidEndDate()); + highUserCoupon.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用 + highUserCouponService.insertUserCoupon(highUserCoupon); + } else { // 查询子订单的兑换码 HighCouponCode code = getCodeByChildOrderNo(childOrder.getChildOrderNo()); diff --git a/hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentCodeServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentCodeServiceImpl.java index 96342a80..bdaa7954 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentCodeServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentCodeServiceImpl.java @@ -8,6 +8,7 @@ import com.hai.common.exception.SysCode; import com.hai.common.security.UserCenter; import com.hai.common.utils.DateUtil; import com.hai.config.ChongQingCNPCService; +import com.hai.config.ScPetroConfig; import com.hai.dao.HighCouponCodeMapper; import com.hai.dao.HighCouponCodeOtherMapper; import com.hai.dao.HighDiscountAgentCodeMapper; @@ -257,45 +258,83 @@ public class HighDiscountAgentCodeServiceImpl implements HighDiscountAgentCodeSe if (couponRelList.size() == 0) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券未配置卡券"); } - List couponList = couponRelList.stream().filter(o -> o.getHighCoupon().getCouponSource().equals(5)).collect(Collectors.toList()); - if (couponList.size() == 0) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券未配置重庆中石油卡券"); - } - // 重庆中石油业务状态 - SecConfig cqCnpcStatus = secConfigService.findByCodeType("CQ_CNPC_STATUS_" + couponList.get(0).getHighCoupon().getCouponKey()); - if (cqCnpcStatus != null && StringUtils.isNotBlank(cqCnpcStatus.getCodeValue())) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, cqCnpcStatus.getCodeValue()); - } - String tradeId = discountAgentCode.getId()+""+System.currentTimeMillis()+""; - // 预发码 - JSONObject preSendCoupon = ChongQingCNPCService.preSendCoupon(couponList.get(0).getHighCoupon().getCouponKey(), tradeId, 1, userModel.getHighUser().getPhone()); - if (!preSendCoupon.getInteger("status").equals(1)) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "领取优惠券失败,请稍后重试"); - } - // 给用户发码 - JSONObject response = ChongQingCNPCService.sendCNPCTicket( - couponList.get(0).getHighCoupon().getCouponKey(), - tradeId, - 1, - userModel.getHighUser().getPhone()); - JSONObject couponDetail = response.getJSONObject("ticketDetail"); - JSONArray codeList = response.getJSONArray("codeList"); - - for (Object data : codeList) { + + if (discount.getUsingRange() == 8) { + + List couponList = couponRelList.stream().filter(o -> o.getHighCoupon().getCouponSource().equals(5)).collect(Collectors.toList()); + if (couponList.size() == 0) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券未配置重庆中石油卡券"); + } + // 重庆中石油业务状态 + SecConfig cqCnpcStatus = secConfigService.findByCodeType("CQ_CNPC_STATUS_" + couponList.get(0).getHighCoupon().getCouponKey()); + if (cqCnpcStatus != null && StringUtils.isNotBlank(cqCnpcStatus.getCodeValue())) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, cqCnpcStatus.getCodeValue()); + } + String tradeId = discountAgentCode.getId()+""+System.currentTimeMillis()+""; + // 预发码 + JSONObject preSendCoupon = ChongQingCNPCService.preSendCoupon(couponList.get(0).getHighCoupon().getCouponKey(), tradeId, 1, userModel.getHighUser().getPhone()); + if (!preSendCoupon.getInteger("status").equals(1)) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "领取优惠券失败,请稍后重试"); + } + // 给用户发码 + JSONObject response = ChongQingCNPCService.sendCNPCTicket( + couponList.get(0).getHighCoupon().getCouponKey(), + tradeId, + 1, + userModel.getHighUser().getPhone()); + JSONObject couponDetail = response.getJSONObject("ticketDetail"); + JSONArray codeList = response.getJSONArray("codeList"); + + for (Object data : codeList) { + HighCouponCodeOther couponCodeOther = new HighCouponCodeOther(); + couponCodeOther.setType(3); + couponCodeOther.setDiscountAgentCodeId(discountAgentCode.getId()); + couponCodeOther.setCouTypeCode(couponDetail.getString("requestCode")); + couponCodeOther.setCouNo(ChongQingCNPCService.decryptCouponCode(String.valueOf(data))); + couponCodeOther.setActiveTime(new Date()); + couponCodeOther.setValidStartDate(DateUtil.format(couponDetail.getString("effectiveTime"), "yyyy-MM-dd")); + couponCodeOther.setValidEndDate(DateUtil.format(couponDetail.getString("expiredDate"), "yyyy-MM-dd")); + couponCodeOther.setStatus(20); + couponCodeOther.setCreateTime(new Date()); + highCouponCodeOtherMapper.insert(couponCodeOther); + } + discountAgentCode.setExt2(tradeId); + updateCode(discountAgentCode); + } else if (discount.getUsingRange() == 11) { + List couponList = couponRelList.stream().filter(o -> o.getHighCoupon().getCouponSource().equals(7)).collect(Collectors.toList()); + if (couponList.size() == 0) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券未配置四川中石油卡券"); + } + // 四川中石油业务状态 + SecConfig ScStatus = secConfigService.findByCodeType("SC_PRINTER_STATUS_" + couponList.get(0).getHighCoupon().getCouponKey()); + if (ScStatus != null && StringUtils.isNotBlank(ScStatus.getCodeValue())) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, ScStatus.getCodeValue()); + } + String tradeId = discountAgentCode.getId()+""+System.currentTimeMillis()+""; + // 预发码 + JSONObject preSendCoupon = ScPetroConfig.getCoupon(couponList.get(0).getHighCoupon().getCouponKey(), userModel.getHighUser().getPhone() , tradeId); + if (!preSendCoupon.getString("code").equals("1")) { + throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "当前优惠券不可购买"); + } + + String data = ScPetroConfig.decrypt(preSendCoupon.getString("biz_content")); + JSONObject object = JSONObject.parseObject(data); + HighCouponCodeOther couponCodeOther = new HighCouponCodeOther(); couponCodeOther.setType(3); couponCodeOther.setDiscountAgentCodeId(discountAgentCode.getId()); - couponCodeOther.setCouTypeCode(couponDetail.getString("requestCode")); - couponCodeOther.setCouNo(ChongQingCNPCService.decryptCouponCode(String.valueOf(data))); + couponCodeOther.setCouTypeCode(object.getString("request_code")); + couponCodeOther.setCouNo(object.getString("ticket_num")); couponCodeOther.setActiveTime(new Date()); - couponCodeOther.setValidStartDate(DateUtil.format(couponDetail.getString("effectiveTime"), "yyyy-MM-dd")); - couponCodeOther.setValidEndDate(DateUtil.format(couponDetail.getString("expiredDate"), "yyyy-MM-dd")); + couponCodeOther.setStatus(20); couponCodeOther.setCreateTime(new Date()); highCouponCodeOtherMapper.insert(couponCodeOther); + + discountAgentCode.setExt2(tradeId); + updateCode(discountAgentCode); } - discountAgentCode.setExt2(tradeId); - updateCode(discountAgentCode); + } } else { // 加锁失败,重试 diff --git a/hai-service/src/main/java/com/hai/service/impl/HighMerchantStoreServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighMerchantStoreServiceImpl.java index 8f48501c..b8226f1a 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighMerchantStoreServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighMerchantStoreServiceImpl.java @@ -174,6 +174,7 @@ public class HighMerchantStoreServiceImpl implements HighMerchantStoreService { } @Override + public HighMerchantStore getMerStoreDetailByKey(String storeKey) { HighMerchantStoreExample example = new HighMerchantStoreExample(); example.createCriteria().andStoreKeyEqualTo(storeKey);