From e25f2021a8c31b318be313176d707f9c95baf7ef Mon Sep 17 00:00:00 2001 From: Sum1Dream <418471657@qq.com> Date: Thu, 6 Apr 2023 10:18:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=AF=9D=E8=B4=B9=E4=B8=9A?= =?UTF-8?q?=E5=8A=A1=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/HighGoodsTypeController.java | 18 ++- .../bweb/controller/HighTestController.java | 2 +- .../cweb/controller/CmsContentController.java | 21 ++- .../com/hai/common/exception/ErrorCode.java | 4 +- .../com/hai/common/security/UserCenter.java | 2 + .../java/com/hai/config/DataUtilConfig.java | 50 +++++++ .../com/hai/config/WeChatQrcodeUtils.java | 63 +++++++-- .../openApi/config/PriceComputeConfig.java | 57 +++++++- .../service/ApiOrderCreateHandleService.java | 10 ++ .../impl/ApiOrderCreateHandleServiceImpl.java | 128 ++++++++++++++---- .../service/impl/ApiOrderServiceImpl.java | 75 +++++++++- .../hai/order/service/OrderPayService.java | 2 +- .../impl/OrderCreateHandleServiceImpl.java | 2 +- .../service/impl/OrderPayServiceImpl.java | 55 +++++--- .../impl/HighDiscountPackageServiceImpl.java | 4 + .../service/impl/HighOrderServiceImpl.java | 6 + .../impl/OutRechargeOrderServiceImpl.java | 40 +++--- .../com/v1/controller/WxMsgController.java | 22 +-- .../com/v1/controller/orderController.java | 33 ++++- v1/src/main/resources/dev/application.yml | 2 +- 20 files changed, 489 insertions(+), 107 deletions(-) create mode 100644 hai-service/src/main/java/com/hai/config/DataUtilConfig.java diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighGoodsTypeController.java b/hai-bweb/src/main/java/com/bweb/controller/HighGoodsTypeController.java index 318175b8..3d2b129b 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighGoodsTypeController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighGoodsTypeController.java @@ -55,10 +55,14 @@ public class HighGoodsTypeController { @RequestParam(name = "userService", required = false) String userService, HttpServletRequest request) { try { + //发布人员 + SessionObject sessionObject = userCenter.getSessionObject(request); + UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); Map map = new HashMap<>(); map.put("title", title); map.put("userService", userService); + map.put("companyId", userInfoModel.getBsCompany().getId().toString()); PageHelper.startPage(pageNum,pageSize); return ResponseMsgUtil.success(new PageInfo<>(highGoodsTypeService.getListGoodsType(map))); @@ -130,15 +134,16 @@ public class HighGoodsTypeController { if (StringUtils.isBlank(highGoodsType.getTitle()) || StringUtils.isBlank(highGoodsType.getImg()) + || highGoodsType.getBusinessType() == null ) { log.error("HighAgentController -> insertAgent() error!","参数错误"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } - // 校验账号用户名是否存在 + // 校验名称是否重复 if (highGoodsTypeService.findByTitle(highGoodsType.getTitle())) { - log.error("HighGoodsTypeController --> insertGoodsType() error!", "已存在"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.ADD_REPEATEDLY, ""); + log.error("HighGoodsTypeController --> insertGoodsType() error!", "名称已存在"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.TITLE_, ""); } highGoodsType.setCreatedTime(new Date()); @@ -146,6 +151,7 @@ public class HighGoodsTypeController { highGoodsType.setUpdatedTime(new Date()); highGoodsType.setUpdatedUserId(userInfoModel.getSecUser().getId().intValue()); highGoodsType.setStatus(1); + highGoodsType.setCompanyId(userInfoModel.getBsCompany().getId()); highGoodsTypeService.insertGoodsType(highGoodsType); @@ -169,6 +175,7 @@ public class HighGoodsTypeController { if (StringUtils.isBlank(highGoodsType.getTitle()) || StringUtils.isBlank(highGoodsType.getImg()) + || highGoodsType.getBusinessType() == null || highGoodsType.getId() == null ) { log.error("HighAgentController -> insertAgent() error!","参数错误"); @@ -179,13 +186,14 @@ public class HighGoodsTypeController { // 校验账号用户名是否存在 if (highGoodsTypeService.findByTitle(highGoodsType.getTitle()) && !highGoodsTypes.getId().equals(highGoodsType.getId())) { - log.error("HighGoodsTypeController --> insertGoodsType() error!", "已存在"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.ADD_REPEATEDLY, ""); + log.error("HighGoodsTypeController --> insertGoodsType() error!", "名称已存在"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.TITLE_, ""); } highGoodsTypes.setUpdatedTime(new Date()); highGoodsTypes.setUpdatedUserId(userInfoModel.getSecUser().getId().intValue()); highGoodsTypes.setImg(highGoodsType.getImg()); + highGoodsTypes.setCompanyId(userInfoModel.getBsCompany().getId()); highGoodsTypes.setTitle(highGoodsType.getTitle()); highGoodsTypeService.updateGoodsType(highGoodsTypes); 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 6da6b459..c55794f0 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.excel.EasyExcel; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.alipay.api.domain.ForbbidenTime; import com.alipay.api.domain.OfferObject; import com.bweb.config.SysConst; 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.*; import com.hai.config.*; import com.hai.entity.*; import com.hai.model.OrderRefundModel; import com.hai.model.ResponseData; import com.hai.order.model.ExportOrderMobileModel; import com.hai.order.model.OrderThirdPartyModel; import com.hai.order.service.OrderRefundService; import com.hai.order.service.OrderService; import com.hai.order.type.*; import com.hai.order.utils.OrderUtil; 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.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.io.File; import java.math.BigDecimal; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * @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 OutRechargeOrderService outRechargeOrderService; @Autowired private OutRechargeChildOrderService childOrderService; @Resource private HighOrderService highOrderService; @Autowired private RedisTemplate redisTemplate; @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 = "/getStationStores", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取油站") public ResponseData getStationStores() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); 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/refuelOnline/getStationStore" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getRechargeProduct", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取充值产品") public ResponseData getRechargeProduct() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); 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/mobileRecharge/getMobileProduct" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getAllCities", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询可用城市") public ResponseData getAllCities() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); 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/apiMerchants/getAllCities" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/starbucksStore", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询星巴克门店") public ResponseData starbucksStore() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("lat" , "29.56900"); mapPost.put("lon" , "106.55843"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("lat" , "29.56900"); map.put("lon" , "106.55843"); 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/starbucks/starbucksStore" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/starbucksProducts", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询星巴克商品") public ResponseData starbucksProducts() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); 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/starbucks/starbucksProducts" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/kfcStoresList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询肯德基门店") public ResponseData kfcStoresList() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); 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/kfc/kfcStoresList" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/kfcProductByStoreCode", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据门店编码查询KFC产品") public ResponseData kfcProductByStoreCode(@RequestParam(name = "storeCode", required = true) String storeCode) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("storeCode" , storeCode); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("storeCode" , storeCode); 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/kfc/kfcProductByStoreCode" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/memberProducts", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询会员产品") public ResponseData memberProducts() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); 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/memberRecharge/memberProducts" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() 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("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("timetable" , new Date().getTime()); mapPost.put("orderNo" , "TEST" + OrderUtil.generateOrderNo()); mapPost.put("productType" , object.getString("productType")); mapPost.put("notifyUrl" , "test"); // JSONObject object = new JSONObject(); // object.put("refuelPrice" , new BigDecimal(100)); // object.put("gasOilNo" , "92"); // object.put("gasGunNo" , "1"); // object.put("storeCode" , "54000"); mapPost.put("content" , object.toString()); System.out.println(mapPost); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("timetable" , mapPost.get("timetable").toString()); map.put("orderNo" , mapPost.get("orderNo")); map.put("productType" , object.getString("productType")); map.put("content" , object.toString()); 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/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 = "/phoneBillOrderError", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "话费订单错误") public ResponseData phoneBillOrderError() { try { log.info("处理话费订单定时任务开始"); Map map = new HashMap<>(); map.put("payStatus", String.valueOf(102)); map.put("rechargeStatus", String.valueOf(201)); List orderList = outRechargeOrderService.getListRechargeOrder(map); log.info("处理话费订单条数:" + orderList.size()); if (orderList.size() > 0) { for (OutRechargeOrder order : orderList) { // 查询子订单 HighOrder highOrder = highOrderService.getOrderByOrderNo(order.getOrderNo()); // 判断订单是否可以继续充值 1:满足继续充值条件 2:订单满足退款条件 3:订单不可以退款不可以继续充值 4:订单异常 5:订单充值完成 int orderStatus = outRechargeOrderService.orderWhetherRecharge(order); log.info("处理话费订单:" + orderStatus + "订单号" + order.getOrderNo()); if (orderStatus == 2 && highOrder.getOrderStatus() == 4) { order.setRechargeStatus(203); order.setPayStatus(105); } if (orderStatus == 5 && highOrder.getOrderStatus() == 3) { order.setRechargeStatus(202); order.setPayStatus(100); } outRechargeOrderService.updateOrder(order); } } return ResponseMsgUtil.success(""); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/mobileChildOrderByOrderNo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据订单号修改话费订单状态") public ResponseData mobileChildOrderByOrderNo(@RequestParam(name = "orderNo", required = true) String orderNo) { try { OutRechargeOrder order = outRechargeOrderService.findByOrderNo(orderNo); // 查询子订单 HighOrder highOrder = highOrderService.getOrderByOrderNo(order.getOrderNo()); // 判断订单是否可以继续充值 1:满足继续充值条件 2:订单满足退款条件 3:订单不可以退款不可以继续充值 4:订单异常 5:订单充值完成 int orderStatus = outRechargeOrderService.orderWhetherRecharge(order); log.info("处理话费订单:" + orderStatus + "订单号" + order.getOrderNo()); if (orderStatus == 2 && highOrder.getOrderStatus() == 4) { order.setRechargeStatus(203); order.setPayStatus(105); } if (orderStatus == 5 && highOrder.getOrderStatus() == 3) { order.setRechargeStatus(202); order.setPayStatus(100); } outRechargeOrderService.updateOrder(order); return ResponseMsgUtil.success(""); } 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(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 = "/mobileDw", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "话费订单下载") public ResponseData mobileDw(@RequestParam(name = "createTimeS", required = true) String createTimeS, @RequestParam(name = "createTimeE", required = true) String createTimeE) { try { Map map = new HashMap<>(); map.put("productType" , 9); map.put("createTimeS" , createTimeS); map.put("createTimeE" , createTimeE); List order = highOrderService.getOrderListNotChild(map); List list = new ArrayList<>(); ExportOrderMobileModel model; for (HighOrder highOrder : order) { model = new ExportOrderMobileModel(); OutRechargeOrder rechargeOrder = outRechargeOrderService.findByOrderNoNotChild(highOrder.getOrderNo()); if (rechargeOrder != null) { OutRechargeChildOrder childOrder = mobileChildOrderHandle(highOrder,rechargeOrder); model.setRechargeOrderNo(rechargeOrder.getOrderNo()); if (childOrder != null) { model.setChildOrderNo(childOrder.getOrderNo()); if (childOrder.getRechargePlatform() != null) { model.setRechargePlatform(RechargePlatformType.getDataByType(childOrder.getRechargePlatform()).getName()); } model.setRemark(childOrder.getExt1()); } } model.setFinishTime(highOrder.getFinishTime()); model.setOrderStatus(OrderStatus.getDataByType(highOrder.getOrderStatus()).getName()); model.setMemPhone(highOrder.getMemPhone()); model.setCreateTime(highOrder.getCreateTime()); model.setTitle(highOrder.getTitle()); model.setPayablePrice(highOrder.getPayablePrice()); model.setRefundTime(highOrder.getRefundTime()); model.setPayPrice(highOrder.getPayPrice()); model.setOrderNo(highOrder.getOrderNo()); model.setMemCardNo(highOrder.getMemCardNo()); if (highOrder.getPayType() != null) { model.setPayType(OrderPayType.getDataByType(highOrder.getPayType()).getName()); } list.add(model); } String fileUrl = SysConst.getSysConfig().getFileUrl() + "temporary/"; String pathName = System.currentTimeMillis()+".xlsx"; File file = new File(fileUrl); if (!file.exists()) { file.mkdirs(); } EasyExcel.write(fileUrl+pathName) .head(ExportOrderMobileModel.class) .sheet("话费交易订单") .doWrite(list); return ResponseMsgUtil.success(pathName); } catch (Exception e) { log.error("HighUserCardController --> oilCardRefund() error!", e); return ResponseMsgUtil.exception(e); } } public OutRechargeChildOrder mobileChildOrderHandle(HighOrder highOrder , OutRechargeOrder outRechargeOrder) { // 组装查询子订单数据 Map childOrderMap101 = new HashMap<>(); childOrderMap101.put("parent_order_id", outRechargeOrder.getId()); childOrderMap101.put("status", "101,102"); // 查询充值订单 List childOrders = childOrderService.getListRechargeChildOrder(childOrderMap101); OutRechargeChildOrder childOrder; // 判读是否存在多个充值中的订单 if (childOrders.size() > 0) { childOrder = childOrders.get(0); if (childOrders.size() > 1) { childOrder.setExt1("当前订单存在多个充值订单"); } } else { childOrder = childOrderService.findByOrderId(outRechargeOrder.getId()); if (childOrder != null && highOrder != null && childOrder.getStatus() != null && highOrder.getOrderStatus() != null) { if (highOrder.getOrderStatus() == 2 && childOrder.getStatus() != 102) { childOrder.setExt1("主订单充值中,但是充值订单状态不为充值中"); } if (highOrder.getOrderStatus() == 3 && childOrder.getStatus() != 101) { childOrder.setExt1("主订单充值成功,但是充值订单状态不为充值成功"); } if (highOrder.getOrderStatus() == 4 && !(childOrder.getStatus() == 103 || childOrder.getStatus() == 104)) { childOrder.setExt1("主订单退款,但是充值订单状态不为退款"); } } } return childOrder; } @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); } } } \ No newline at end of file + package com.bweb.controller; import com.alibaba.excel.EasyExcel; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.alipay.api.domain.ForbbidenTime; import com.alipay.api.domain.OfferObject; import com.bweb.config.SysConst; 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.*; import com.hai.config.*; import com.hai.entity.*; import com.hai.model.OrderRefundModel; import com.hai.model.ResponseData; import com.hai.order.model.ExportOrderMobileModel; import com.hai.order.model.OrderThirdPartyModel; import com.hai.order.service.OrderRefundService; import com.hai.order.service.OrderService; import com.hai.order.type.*; import com.hai.order.utils.OrderUtil; 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.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.io.File; import java.math.BigDecimal; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * @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 OutRechargeOrderService outRechargeOrderService; @Autowired private OutRechargeChildOrderService childOrderService; @Resource private HighOrderService highOrderService; @Autowired private RedisTemplate redisTemplate; @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 = "/getStationStores", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取油站") public ResponseData getStationStores() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); 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/refuelOnline/getStationStore" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getRechargeProduct", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取充值产品") public ResponseData getRechargeProduct() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); 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/mobileRecharge/getMobileProduct" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getAllCities", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询可用城市") public ResponseData getAllCities() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); 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/apiMerchants/getAllCities" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/starbucksStore", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询星巴克门店") public ResponseData starbucksStore() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("lat" , "29.56900"); mapPost.put("lon" , "106.55843"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("lat" , "29.56900"); map.put("lon" , "106.55843"); 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/starbucks/starbucksStore" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/starbucksProducts", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询星巴克商品") public ResponseData starbucksProducts() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); 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/starbucks/starbucksProducts" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/kfcStoresList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询肯德基门店") public ResponseData kfcStoresList() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); 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/kfc/kfcStoresList" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/kfcProductByStoreCode", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据门店编码查询KFC产品") public ResponseData kfcProductByStoreCode(@RequestParam(name = "storeCode", required = true) String storeCode) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("storeCode" , storeCode); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("storeCode" , storeCode); 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/kfc/kfcProductByStoreCode" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/memberProducts", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询会员产品") public ResponseData memberProducts() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); 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/memberRecharge/memberProducts" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() 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("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("timetable" , new Date().getTime()); mapPost.put("orderNo" , "TEST" + OrderUtil.generateOrderNo()); mapPost.put("productType" , object.getString("productType")); mapPost.put("notifyUrl" , "test"); mapPost.put("content" , object.toString()); System.out.println(mapPost); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("timetable" , mapPost.get("timetable").toString()); map.put("orderNo" , mapPost.get("orderNo")); map.put("productType" , object.getString("productType")); map.put("content" , object.toString()); 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/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 = "/phoneBillOrderError", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "话费订单错误") public ResponseData phoneBillOrderError() { try { log.info("处理话费订单定时任务开始"); Map map = new HashMap<>(); map.put("payStatus", String.valueOf(102)); map.put("rechargeStatus", String.valueOf(201)); List orderList = outRechargeOrderService.getListRechargeOrder(map); log.info("处理话费订单条数:" + orderList.size()); if (orderList.size() > 0) { for (OutRechargeOrder order : orderList) { // 查询子订单 HighOrder highOrder = highOrderService.getOrderByOrderNo(order.getOrderNo()); // 判断订单是否可以继续充值 1:满足继续充值条件 2:订单满足退款条件 3:订单不可以退款不可以继续充值 4:订单异常 5:订单充值完成 int orderStatus = outRechargeOrderService.orderWhetherRecharge(order); log.info("处理话费订单:" + orderStatus + "订单号" + order.getOrderNo()); if (orderStatus == 2 && highOrder.getOrderStatus() == 4) { order.setRechargeStatus(203); order.setPayStatus(105); } if (orderStatus == 5 && highOrder.getOrderStatus() == 3) { order.setRechargeStatus(202); order.setPayStatus(100); } outRechargeOrderService.updateOrder(order); } } return ResponseMsgUtil.success(""); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/mobileChildOrderByOrderNo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据订单号修改话费订单状态") public ResponseData mobileChildOrderByOrderNo(@RequestParam(name = "orderNo", required = true) String orderNo) { try { OutRechargeOrder order = outRechargeOrderService.findByOrderNo(orderNo); // 查询子订单 HighOrder highOrder = highOrderService.getOrderByOrderNo(order.getOrderNo()); // 判断订单是否可以继续充值 1:满足继续充值条件 2:订单满足退款条件 3:订单不可以退款不可以继续充值 4:订单异常 5:订单充值完成 int orderStatus = outRechargeOrderService.orderWhetherRecharge(order); log.info("处理话费订单:" + orderStatus + "订单号" + order.getOrderNo()); if (orderStatus == 2 && highOrder.getOrderStatus() == 4) { order.setRechargeStatus(203); order.setPayStatus(105); } if (orderStatus == 5 && highOrder.getOrderStatus() == 3) { order.setRechargeStatus(202); order.setPayStatus(100); } outRechargeOrderService.updateOrder(order); return ResponseMsgUtil.success(""); } 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(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 = "/mobileDw", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "话费订单下载") public ResponseData mobileDw(@RequestParam(name = "createTimeS", required = false) String createTimeS, @RequestParam(name = "createTimeE", required = false) String createTimeE, @RequestParam(name = "refundTimeS", required = false) String refundTimeS, @RequestParam(name = "refundTimeE", required = false) String refundTimeE ) { try { Map map = new HashMap<>(); map.put("productType" , 9); map.put("createTimeS" , createTimeS); map.put("createTimeE" , createTimeE); map.put("refundTimeS" , refundTimeS); map.put("refundTimeE" , refundTimeE); List order = highOrderService.getOrderListNotChild(map); List list = new ArrayList<>(); ExportOrderMobileModel model; for (HighOrder highOrder : order) { model = new ExportOrderMobileModel(); OutRechargeOrder rechargeOrder = outRechargeOrderService.findByOrderNoNotChild(highOrder.getOrderNo()); if (rechargeOrder != null) { OutRechargeChildOrder childOrder = mobileChildOrderHandle(highOrder,rechargeOrder); model.setRechargeOrderNo(rechargeOrder.getOrderNo()); if (childOrder != null) { model.setChildOrderNo(childOrder.getOrderNo()); if (childOrder.getRechargePlatform() != null) { model.setRechargePlatform(RechargePlatformType.getDataByType(childOrder.getRechargePlatform()).getName()); } model.setRemark(childOrder.getExt1()); } } model.setFinishTime(highOrder.getFinishTime()); model.setOrderStatus(OrderStatus.getDataByType(highOrder.getOrderStatus()).getName()); model.setMemPhone(highOrder.getMemPhone()); model.setCreateTime(highOrder.getCreateTime()); model.setTitle(highOrder.getTitle()); model.setPayablePrice(highOrder.getPayablePrice()); model.setRefundTime(highOrder.getRefundTime()); model.setPayPrice(highOrder.getPayPrice()); model.setOrderNo(highOrder.getOrderNo()); model.setMemCardNo(highOrder.getMemCardNo()); if (highOrder.getPayType() != null) { model.setPayType(OrderPayType.getDataByType(highOrder.getPayType()).getName()); } list.add(model); } String fileUrl = SysConst.getSysConfig().getFileUrl() + "temporary/"; String pathName = System.currentTimeMillis()+".xlsx"; File file = new File(fileUrl); if (!file.exists()) { file.mkdirs(); } EasyExcel.write(fileUrl+pathName) .head(ExportOrderMobileModel.class) .sheet("话费交易订单") .doWrite(list); return ResponseMsgUtil.success(pathName); } catch (Exception e) { log.error("HighUserCardController --> oilCardRefund() error!", e); return ResponseMsgUtil.exception(e); } } public OutRechargeChildOrder mobileChildOrderHandle(HighOrder highOrder , OutRechargeOrder outRechargeOrder) { // 组装查询子订单数据 Map childOrderMap101 = new HashMap<>(); childOrderMap101.put("parent_order_id", outRechargeOrder.getId()); childOrderMap101.put("status", "101,102"); // 查询充值订单 List childOrders = childOrderService.getListRechargeChildOrder(childOrderMap101); OutRechargeChildOrder childOrder; // 判读是否存在多个充值中的订单 if (childOrders.size() > 0) { childOrder = childOrders.get(0); if (childOrders.size() > 1) { childOrder.setExt1("当前订单存在多个充值订单"); } } else { childOrder = childOrderService.findByOrderId(outRechargeOrder.getId()); if (childOrder != null && highOrder != null && childOrder.getStatus() != null && highOrder.getOrderStatus() != null) { if (highOrder.getOrderStatus() == 2 && childOrder.getStatus() != 102) { childOrder.setExt1("主订单充值中,但是充值订单状态不为充值中"); } if (highOrder.getOrderStatus() == 3 && childOrder.getStatus() != 101) { childOrder.setExt1("主订单充值成功,但是充值订单状态不为充值成功"); } if (highOrder.getOrderStatus() == 4 && !(childOrder.getStatus() == 103 || childOrder.getStatus() == 104)) { childOrder.setExt1("主订单退款,但是充值订单状态不为退款"); } } } return childOrder; } @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); } } } \ No newline at end of file diff --git a/hai-cweb/src/main/java/com/cweb/controller/CmsContentController.java b/hai-cweb/src/main/java/com/cweb/controller/CmsContentController.java index a472e76f..5b51a182 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/CmsContentController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/CmsContentController.java @@ -60,8 +60,15 @@ public class CmsContentController { @RequestParam(name = "categoryCode", required = true) String categoryCode, HttpServletRequest request) { try { + Boolean dataWhetherNull = true; + + List cmsContent; + SessionObject sessionObject = userCenter.getSessionObjectByCms(request); HighUserModel userInfoModel = new HighUserModel(); + + System.out.println("sessionObject============" + sessionObject); + if (sessionObject != null) { // 用户 userInfoModel = (HighUserModel) sessionObject.getObject(); @@ -88,14 +95,19 @@ public class CmsContentController { object.put("name" , cmsCategory.getName()); object.put("sort" , cmsCategory.getSort()); object.put("code" , cmsCategory.getCode()); - object.put("childCategory" , cmsContentService.getListCmsContentByCategoryId(cmsCategory.getId() , companyId , platform)); + cmsContent = cmsContentService.getListCmsContentByCategoryId(cmsCategory.getId() , companyId , platform); + if (cmsContent.size() > 0) { + dataWhetherNull = false; + } + object.put("childCategory" , cmsContent); } else if(cmsCategory.getType() == 6 || cmsCategory.getType() == 9) { object.put("type" , cmsCategory.getType()); object.put("name" , cmsCategory.getName()); object.put("sort" , cmsCategory.getSort()); object.put("code" , cmsCategory.getCode()); - List cmsContent = cmsContentService.getListCmsContentByCategoryId(cmsCategory.getId() , companyId , platform); + cmsContent = cmsContentService.getListCmsContentByCategoryId(cmsCategory.getId() , companyId , platform); if (cmsContent.size() > 0) { + dataWhetherNull = false; object.put("jumpType" , cmsContent.get(0).getJumpType()); object.put("jumpUrl" , cmsContent.get(0).getJumpUrl()); object.put("detailJumpUrl" , cmsContent.get(0).getExt1()); @@ -106,8 +118,9 @@ public class CmsContentController { object.put("name" , cmsCategory.getName()); object.put("sort" , cmsCategory.getSort()); object.put("code" , cmsCategory.getCode()); - List cmsContent = cmsContentService.getListCmsContentByCategoryId(cmsCategory.getId() , companyId , platform); + cmsContent = cmsContentService.getListCmsContentByCategoryId(cmsCategory.getId() , companyId , platform); if (cmsContent.size() > 0) { + dataWhetherNull = false; object.put("jumpType" , cmsContent.get(0).getJumpType()); object.put("jumpUrl" , cmsContent.get(0).getJumpUrl()); } @@ -149,7 +162,7 @@ public class CmsContentController { } - return ResponseMsgUtil.success(objectList); + return ResponseMsgUtil.success(dataWhetherNull ? null:objectList); } else { JSONObject object = new JSONObject(); object.put("type" , category.getType()); diff --git a/hai-service/src/main/java/com/hai/common/exception/ErrorCode.java b/hai-service/src/main/java/com/hai/common/exception/ErrorCode.java index 62afae9e..a56aec35 100644 --- a/hai-service/src/main/java/com/hai/common/exception/ErrorCode.java +++ b/hai-service/src/main/java/com/hai/common/exception/ErrorCode.java @@ -116,7 +116,7 @@ public enum ErrorCode { NOT_ENTER_USER_PAY_PWD("2131","未输入支付密码"), USER_PAY_PWD_ERROR("2132","支付密码错误"), NO_BIND_PHONE("2133","未设置手机号"), - title_("2134","名称已存在"), + TITLE_("2134","名称已存在"), ADD_REPEATEDLY("2135","重复添加"), NOT_FOUND_TOW_PWD("2136","未设置二级密码"), @@ -138,7 +138,7 @@ public enum ErrorCode { PRODUCT_ERROR("6009","商品错误"), MERCHANT_NOT_AUTHORIZED("6010","帐户无权限"), TIME_OUT("6011","请求时间超时"), - + PAY_FAIL("6012","支付失败"), //////////////////订单异常///////////// ORDER_UNKNOWN_ERROR("90000","哦豁,订单未知错误,请稍后重试!"), diff --git a/hai-service/src/main/java/com/hai/common/security/UserCenter.java b/hai-service/src/main/java/com/hai/common/security/UserCenter.java index 5a75ed12..eb550776 100644 --- a/hai-service/src/main/java/com/hai/common/security/UserCenter.java +++ b/hai-service/src/main/java/com/hai/common/security/UserCenter.java @@ -123,7 +123,9 @@ public class UserCenter { } public SessionObject getSessionObjectByCms(HttpServletRequest request) { + String token = request.getHeader("Authorization"); + System.out.println("token====" + token); if (StringUtils.isBlank(token)) { if (StringUtils.isNotBlank(read(request))) { token = read(request); diff --git a/hai-service/src/main/java/com/hai/config/DataUtilConfig.java b/hai-service/src/main/java/com/hai/config/DataUtilConfig.java new file mode 100644 index 00000000..1da3a383 --- /dev/null +++ b/hai-service/src/main/java/com/hai/config/DataUtilConfig.java @@ -0,0 +1,50 @@ +package com.hai.config; + +import com.alibaba.fastjson.JSONObject; +import org.springframework.context.annotation.Configuration; + +import java.util.Objects; + +/** + * @serviceName DataUtilConfig.java + * @author Sum1Dream + * @version 1.0.0 + * @Description // 数据工具类 + * @createTime 16:07 2023/4/4 + **/ +@Configuration +public class DataUtilConfig { + + /** + * @Author Sum1Dream + * @Name dataFindByKfc + * @Description // 根据产品id 查询对应内容 + * @Date 16:09 2023/4/4 + * @Param object 数据内容 + * @Param productId 产品id + * @Return com.alibaba.fastjson.JSONObject + */ + public static JSONObject dataFindByKfc(JSONObject kfcObject , String productId) { + if (kfcObject.getJSONArray("products") != null) { + for (Object products : kfcObject.getJSONArray("products")) { + JSONObject productsObject = (JSONObject) products; + if (Objects.equals(productsObject.getString("productId"), productId)) { + return productsObject; + } + + if (productsObject.getJSONArray("specGroups") != null) { + for (Object specGroups : productsObject.getJSONArray("specGroups")) { + JSONObject specGroupsObject = (JSONObject) specGroups; + if (Objects.equals(specGroupsObject.getString("productId"), productId)) { + return specGroupsObject; + } + + } + } + } + } + + return null; + } + +} diff --git a/hai-service/src/main/java/com/hai/config/WeChatQrcodeUtils.java b/hai-service/src/main/java/com/hai/config/WeChatQrcodeUtils.java index 6d5f94ef..adfda565 100644 --- a/hai-service/src/main/java/com/hai/config/WeChatQrcodeUtils.java +++ b/hai-service/src/main/java/com/hai/config/WeChatQrcodeUtils.java @@ -13,10 +13,13 @@ import com.hai.common.utils.RedisUtil; import com.hai.common.utils.ResponseMsgUtil; import com.hai.enum_type.ActionNameEnum; import com.hai.model.TextMessage; +import com.hai.service.impl.OutRechargeOrderServiceImpl; import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.bean.result.WxMpQrCodeTicket; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -42,10 +45,12 @@ import static org.apache.catalina.manager.Constants.CHARSET; * @Description // 生成带参数的二维码 * @createTime 16:11 2022/9/2 **/ -@Slf4j @Component public class WeChatQrcodeUtils { + private static final Logger log = LoggerFactory.getLogger(OutRechargeOrderServiceImpl.class); + + @Autowired private WxMpService wxMpService; @@ -114,26 +119,64 @@ public class WeChatQrcodeUtils { object.put("action_name" , actionName); object.put("expire_seconds" , 2592000); object.put("action_info" , objectActionInfo); - return HttpsUtils.doPost("https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=" + getWxToken(), object); + return HttpsUtils.doPost("https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=" + getWxToken(false), object); } // 获取微信Token存入redis - public String getWxToken() { - Object token = redisUtil.get("WxToken"); - if (null != token) { - return token.toString(); - }; + public String getWxToken(Boolean whetherRedis) { + + if (!whetherRedis) { + Object token = redisUtil.get("WxToken"); + if (null != token) { + return token.toString(); + } + } + + log.info("获取最新微信token"); + // 获取access_token - Map params = new HashMap<>(); + JSONObject params = new JSONObject(); params.put("appid", CommonSysConst.getSysConfig().getWxH5AppId()); params.put("secret", CommonSysConst.getSysConfig().getWxH5AppSecret()); params.put("grant_type", "client_credential"); - JSONObject accessTokenObject = HttpsUtils.doGet("https://api.weixin.qq.com/cgi-bin/token", params); - redisUtil.set("WxToken" , accessTokenObject.getString("access_token") , 5000); + JSONObject accessTokenObject = HttpsUtils.doPost("https://api.weixin.qq.com/cgi-bin/stable_token", params); + redisUtil.set("WxToken" , accessTokenObject.getString("access_token") , 7000); return accessTokenObject.getString("access_token"); } + + // 获取签名 + public JSONObject getTicket(Boolean whetherRedis) { + + int WxTokenRequestNum = Integer.parseInt(redisUtil.get("WxTokenRequestNum") == null ? "1" :redisUtil.get("WxTokenRequestNum").toString()); + + redisUtil.set("WxTokenRequestNum" , WxTokenRequestNum + 1 , 1000); + + String token = getWxToken(whetherRedis);; + + log.info("获取微信token次数: " + WxTokenRequestNum); + log.info("获取微信token-回调参数: " + token); + + JSONObject jsapiTicket; + + // 获取ticket + Map ticketParams = new HashMap<>(); + ticketParams.put("access_token", token); + ticketParams.put("type", "jsapi"); + jsapiTicket = HttpsUtils.doGet("https://api.weixin.qq.com/cgi-bin/ticket/getticket", ticketParams); + + log.info("获取ticket-回调参数: " + jsapiTicket); + + if (jsapiTicket != null && jsapiTicket.getInteger("errcode") != 0 && WxTokenRequestNum < 6) { + jsapiTicket = getTicket(true); + } + + redisUtil.del("WxTokenRequestNum"); + return jsapiTicket; + + } + /** *
      * 换取二维码图片文件,jpg格式
diff --git a/hai-service/src/main/java/com/hai/openApi/config/PriceComputeConfig.java b/hai-service/src/main/java/com/hai/openApi/config/PriceComputeConfig.java
index 121d3a11..936dc74c 100644
--- a/hai-service/src/main/java/com/hai/openApi/config/PriceComputeConfig.java
+++ b/hai-service/src/main/java/com/hai/openApi/config/PriceComputeConfig.java
@@ -1,9 +1,6 @@
 package com.hai.openApi.config;
 
-import com.hai.entity.ApiAmountRecord;
-import com.hai.entity.ApiMerchants;
-import com.hai.entity.ApiOrder;
-import com.hai.entity.HighOrder;
+import com.hai.entity.*;
 import com.hai.openApi.service.ApiOrderService;
 import com.hai.order.type.OrderProductType;
 import com.hai.service.ApiAmountRecordService;
@@ -89,8 +86,60 @@ public class PriceComputeConfig {
 
     }
 
+    /**
+     * @Author Sum1Dream
+     * @Name computationPriceCost
+     * @Description // 计算成本价加上我们赚的利润
+     * @Date 18:11 2023/4/3
+     * @Param [discount, price, costPrice]
+     * @Return java.math.BigDecimal
+     */
     public BigDecimal computationPriceCost(BigDecimal discount , BigDecimal price , BigDecimal costPrice) {
         return  costPrice.add(price.multiply(discount.divide(new BigDecimal(100)))).setScale(2, RoundingMode.HALF_UP);
 
     }
+
+    /**
+     * @Author Sum1Dream
+     * @Name getStarbucksCpuSizePriceMarket
+     * @Description // 查询市场价 不同杯型不同的价格
+     * @Date 18:48 2023/4/4
+     * @Param starbucksProducts 星巴克对象
+     * @Param cpuSize 杯型
+     * @Return java.math.BigDecimal
+     */
+    public BigDecimal getStarbucksCpuSizePriceMarket(ApiStarbucksProducts starbucksProducts , String cpuSize) {
+        switch (cpuSize) {
+            case "中杯":
+                return starbucksProducts.getMarketTallPrice();
+            case "大杯":
+                return starbucksProducts.getMarketGrandePrice();
+            case "超大杯":
+                return starbucksProducts.getMarketVentiPrice();
+            default:
+                return  null;
+        }
+    }
+
+    /**
+     * @Author Sum1Dream
+     * @Name getStarbucksCpuSizePriceMarket
+     * @Description // 查询销售价格 不同杯型不同的价格
+     * @Date 18:48 2023/4/4
+     * @Param starbucksProducts 星巴克对象
+     * @Param cpuSize 杯型
+     * @Return java.math.BigDecimal
+     */
+    public BigDecimal getStarbucksCpuSizePriceSales(ApiStarbucksProducts starbucksProducts , String cpuSize) {
+        switch (cpuSize) {
+            case "中杯":
+                return starbucksProducts.getSalesTallPrice();
+            case "大杯":
+                return starbucksProducts.getSalesGrandePrice();
+            case "超大杯":
+                return starbucksProducts.getSalesVentiPrice();
+            default:
+                return  null;
+        }
+    }
 }
diff --git a/hai-service/src/main/java/com/hai/openApi/service/ApiOrderCreateHandleService.java b/hai-service/src/main/java/com/hai/openApi/service/ApiOrderCreateHandleService.java
index 4622424a..8fd6bd55 100644
--- a/hai-service/src/main/java/com/hai/openApi/service/ApiOrderCreateHandleService.java
+++ b/hai-service/src/main/java/com/hai/openApi/service/ApiOrderCreateHandleService.java
@@ -58,4 +58,14 @@ public interface ApiOrderCreateHandleService {
      */
     ApiOrder kfcHandle(JSONObject object) throws Exception;
 
+    /**
+     * @Author Sum1Dream
+     * @Name starbucksHandle
+     * @Description // 星巴克操作
+     * @Date 17:58 2023/4/4
+     * @Param [object]
+     * @Return com.hai.entity.ApiOrder
+     */
+    ApiOrder starbucksHandle(JSONObject object) throws Exception;
+
 }
diff --git a/hai-service/src/main/java/com/hai/openApi/service/impl/ApiOrderCreateHandleServiceImpl.java b/hai-service/src/main/java/com/hai/openApi/service/impl/ApiOrderCreateHandleServiceImpl.java
index c8894658..85639311 100644
--- a/hai-service/src/main/java/com/hai/openApi/service/impl/ApiOrderCreateHandleServiceImpl.java
+++ b/hai-service/src/main/java/com/hai/openApi/service/impl/ApiOrderCreateHandleServiceImpl.java
@@ -5,6 +5,7 @@ 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.config.DataUtilConfig;
 import com.hai.config.QianZhuConfig;
 import com.hai.entity.*;
 import com.hai.openApi.config.PriceComputeConfig;
@@ -17,9 +18,7 @@ import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.*;
 
 @Service("apiOrderCreateHandleService")
 public class ApiOrderCreateHandleServiceImpl implements ApiOrderCreateHandleService {
@@ -45,6 +44,9 @@ public class ApiOrderCreateHandleServiceImpl implements ApiOrderCreateHandleServ
     @Resource
     private OutRechargePriceService rechargePriceService;
 
+    @Resource
+    private ApiProductService apiProductService;
+
     @Override
     public ApiOrder oilHandle(JSONObject object) throws Exception {
 
@@ -218,16 +220,11 @@ public class ApiOrderCreateHandleServiceImpl implements ApiOrderCreateHandleServ
         //  获取下单内容
         JSONObject dataObject = JSONObject.parseObject(object.getString("content"));
 
+        JSONArray dataArray = dataObject.getJSONArray("data");
+
         // 查询api商户
         ApiMerchants apiMerchants = apiMerchantsService.findByMchId(object.getString("merchId"));
 
-
-        // 查询折扣比例
-        Map mchProductMap = new HashMap<>();
-        mchProductMap.put("productType" , object.getString("productType"));
-        mchProductMap.put("mchId" , object.getString("merchId"));
-        ApiMchProduct mchProduct = apiMchProductService.findByMap(mchProductMap);
-
         // 查询肯德基门店菜单
         JSONObject jsonObject = QianZhuConfig.listByStoreCode(dataObject.getString("storeCode"));
         JSONArray array = jsonObject.getJSONArray("data");
@@ -235,36 +232,109 @@ public class ApiOrderCreateHandleServiceImpl implements ApiOrderCreateHandleServ
             throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "门店编码错误");
         }
 
+        // 查询折扣比例
         Map mapProduct = new HashMap<>();
         mapProduct.put("mchId" , object.getString("merchId"));
         mapProduct.put("productType" , OrderProductType.PRODUCT_TYPE2.getNumber());
 
         ApiMchProduct apiMchProducts = apiMchProductService.findByMap(mapProduct);
 
+        StringBuffer orderItems = new StringBuffer();
+
+        BigDecimal priceTotal = new BigDecimal(0);
+        BigDecimal facePrice = new BigDecimal(0);
 
-        for (Object data : array) {
-            JSONObject kfcObject = (JSONObject) data;
-            if (kfcObject.getJSONArray("products") != null) {
-                for (Object products : kfcObject.getJSONArray("products")) {
-                    JSONObject productsObject = (JSONObject) products;
-                    productsObject.put("taxOriginalPrice" , null);
-                    productsObject.put("taxOriginalTotalPrice" , null);
-                    productsObject.put("price" , priceComputeConfig.computationPriceCost(apiMchProducts.getDiscount() , productsObject.getBigDecimal("originalPrice") , productsObject.getBigDecimal("price")));
-                    productsObject.put("taxPrice" , null);
-
-                    if (productsObject.getJSONArray("specGroups") != null) {
-                        for (Object specGroups : productsObject.getJSONArray("specGroups")) {
-                            JSONObject specGroupsObject = (JSONObject) specGroups;
-                            specGroupsObject.put("taxOriginalPrice" , null);
-                            specGroupsObject.put("taxOriginalTotalPrice" , null);
-                            specGroupsObject.put("price" , priceComputeConfig.computationPriceCost(apiMchProducts.getDiscount() , specGroupsObject.getBigDecimal("originalPrice") , specGroupsObject.getBigDecimal("price")));
-                            specGroupsObject.put("taxPrice" , null);
-                        }
+        Map map = new HashMap<>();
+
+        for (Object o : dataArray) {
+            JSONObject itemData = (JSONObject) o;
+
+            orderItems.append(itemData.getString("productId")).append("|").append(itemData.getInteger("num")).append(",");
+            for (Object data : array) {
+                JSONObject kfcObject = (JSONObject) data;
+                JSONObject kfcData = DataUtilConfig.dataFindByKfc(kfcObject , itemData.getString("productId"));
+                if (kfcData != null) {
+                    if (map.containsKey(itemData.getString("productId"))) {
+                        break;
                     }
+                    map.put(itemData.getString("productId") , itemData.getString("productId"));
+                    priceTotal = priceTotal.add(priceComputeConfig.computationPriceCost(apiMchProducts.getDiscount() , kfcData.getBigDecimal("originalPrice") , kfcData.getBigDecimal("price")).multiply(itemData.getBigDecimal("num")));
+                    facePrice = facePrice.add(kfcData.getBigDecimal("originalPrice").multiply(itemData.getBigDecimal("num")));
                 }
             }
+
+        }
+
+        dataObject.put("orderItems" , orderItems);
+
+        // 组装api订单
+        ApiOrder apiOrder = new ApiOrder();
+        apiOrder.setCreateTime(new Date());
+        apiOrder.setTitle(apiMerchants.getMerchantName() + "|" + OrderProductType.PRODUCT_TYPE2.getName() + "|扣款" + priceTotal);
+        apiOrder.setFacePrice(facePrice);
+        apiOrder.setCostPrice(priceTotal);
+        apiOrder.setMchId(object.getString("merchId"));
+        apiOrder.setMchName(apiMerchants.getMerchantName());
+        apiOrder.setUpdateTime(new Date());
+        apiOrder.setProductType(object.getInteger("productType"));
+        apiOrder.setMchOrderNo(object.getString("orderNo"));
+        apiOrder.setOrderPrice(facePrice);
+        apiOrder.setNotifyUrl(object.getString("notifyUrl"));
+        apiOrder.setContent(dataObject.toJSONString());
+        return apiOrder;
+    }
+
+    @Override
+    public ApiOrder starbucksHandle(JSONObject object) throws Exception {
+
+        //  获取下单内容
+        JSONObject dataObject = JSONObject.parseObject(object.getString("content"));
+
+        JSONArray dataArray = dataObject.getJSONArray("data");
+
+        // 查询api商户
+        ApiMerchants apiMerchants = apiMerchantsService.findByMchId(object.getString("merchId"));
+
+        // 查询折扣比例
+        Map mapProduct = new HashMap<>();
+        mapProduct.put("mchId" , object.getString("merchId"));
+        mapProduct.put("productType" , OrderProductType.PRODUCT_TYPE2.getNumber());
+
+        ApiMchProduct apiMchProducts = apiMchProductService.findByMap(mapProduct);
+
+        BigDecimal priceTotal = new BigDecimal(0);
+        BigDecimal facePrice = new BigDecimal(0);
+
+
+        for (Object starbucksObject : dataArray) {
+
+            JSONObject starbucksData = (JSONObject) starbucksObject;
+            ApiStarbucksProducts starbucksProducts = apiProductService.findStarbucksProductsByGoodsId(starbucksData.getLong("productId"));
+
+            BigDecimal marketPrice = priceComputeConfig.getStarbucksCpuSizePriceMarket(starbucksProducts , starbucksData.getString("cupSize"));
+            BigDecimal salesPrice = priceComputeConfig.getStarbucksCpuSizePriceSales(starbucksProducts , starbucksData.getString("cupSize"));
+
+            priceTotal = priceTotal.add(priceComputeConfig.computationPriceCost(apiMchProducts.getDiscount() , marketPrice , salesPrice).multiply(starbucksData.getBigDecimal("num")));
+            facePrice = facePrice.add(marketPrice.multiply(starbucksData.getBigDecimal("num")));
+
         }
 
-        return null;
+        // 组装api订单
+        ApiOrder apiOrder = new ApiOrder();
+        apiOrder.setCreateTime(new Date());
+        apiOrder.setTitle(apiMerchants.getMerchantName() + "|" + OrderProductType.PRODUCT_TYPE1.getName() + "|扣款" + priceTotal);
+        apiOrder.setFacePrice(facePrice);
+        apiOrder.setCostPrice(priceTotal);
+        apiOrder.setMchId(object.getString("merchId"));
+        apiOrder.setMchName(apiMerchants.getMerchantName());
+        apiOrder.setUpdateTime(new Date());
+        apiOrder.setProductType(object.getInteger("productType"));
+        apiOrder.setMchOrderNo(object.getString("orderNo"));
+        apiOrder.setOrderPrice(facePrice);
+        apiOrder.setNotifyUrl(object.getString("notifyUrl"));
+        apiOrder.setContent(dataObject.toJSONString());
+        return apiOrder;
+
+
     }
 }
diff --git a/hai-service/src/main/java/com/hai/openApi/service/impl/ApiOrderServiceImpl.java b/hai-service/src/main/java/com/hai/openApi/service/impl/ApiOrderServiceImpl.java
index 3756e736..b2acd714 100644
--- a/hai-service/src/main/java/com/hai/openApi/service/impl/ApiOrderServiceImpl.java
+++ b/hai-service/src/main/java/com/hai/openApi/service/impl/ApiOrderServiceImpl.java
@@ -57,7 +57,7 @@ public class ApiOrderServiceImpl implements ApiOrderService {
     private ApiOrderService apiOrderService;
 
     @Override
-    @Transactional(rollbackFor=Exception.class,isolation = Isolation.SERIALIZABLE,propagation= Propagation.REQUIRES_NEW)
+    @Transactional(rollbackFor=Exception.class,propagation= Propagation.REQUIRES_NEW)
     public ApiOrder createOrder(JSONObject object) throws Exception {
 
         ApiOrder apiOrder = new ApiOrder();
@@ -87,6 +87,55 @@ public class ApiOrderServiceImpl implements ApiOrderService {
             throw ErrorHelp.genException(SysCode.System, ErrorCode.ORDER_ALREADY_EXISTS);
         }
 
+        // 处理星巴克订单
+        if (OrderProductType.PRODUCT_TYPE1.getNumber().equals(object.getInteger("productType"))) {
+            apiOrder = orderCreateHandleService.starbucksHandle(object);
+
+            // 组装子订单内容
+            CreateOrderChildModel createOrderChildModel = new CreateOrderChildModel();
+            createOrderChildModel.setMemName(apiMerchants.getMerchantName());
+            createOrderChildModel.setMemPhone(apiMerchants.getPhone());
+            createOrderChildModel.setCompanyId(2L);
+            createOrderChildModel.setGoodsType(OrderChildGoodsType.TYPE9.getNumber());
+            createOrderChildModel.setCustomerMobile(dataObject.getString("customerMobile"));
+            createOrderChildModel.setOrderItems(dataObject.getJSONArray("data"));
+            createOrderChildModel.setStoreCode(dataObject.getString("storeCode"));
+            createOrderChildModel.setSaleCount(1);
+            createOrderChildModel.setIsTyAgent(false);
+            createOrderChildModel.setGoodsPrice(apiOrder.getOrderPrice());
+            // 组装订单
+            createOrderModel.getChildOrderList().add(createOrderChildModel);
+            orderService.createOrder(createOrderModel);
+        }
+
+
+
+        // 处理肯德基订单
+        if (OrderProductType.PRODUCT_TYPE2.getNumber().equals(object.getInteger("productType"))) {
+            apiOrder = orderCreateHandleService.kfcHandle(object);
+
+            String orderItems = JSONObject.parseObject(apiOrder.getContent()).getString("orderItems");
+
+            orderItems = orderItems.substring(0 , orderItems.length() - 1);
+
+            // 组装子订单内容
+            CreateOrderChildModel createOrderChildModel = new CreateOrderChildModel();
+            createOrderChildModel.setMemName(apiMerchants.getMerchantName());
+            createOrderChildModel.setMemPhone(apiMerchants.getPhone());
+            createOrderChildModel.setCompanyId(2L);
+            createOrderChildModel.setGoodsType(OrderChildGoodsType.TYPE4.getNumber());
+            createOrderChildModel.setCustomerMobile(dataObject.getString("customerMobile"));
+            createOrderChildModel.setEatType(dataObject.getInteger("eatType"));
+            createOrderChildModel.setStoreCode(dataObject.getString("storeCode"));
+            createOrderChildModel.setOrderItems(orderItems);
+            createOrderChildModel.setSaleCount(1);
+            createOrderChildModel.setIsTyAgent(false);
+            createOrderChildModel.setGoodsPrice(apiOrder.getOrderPrice());
+            // 组装订单
+            createOrderModel.getChildOrderList().add(createOrderChildModel);
+            orderService.createOrder(createOrderModel);
+        }
+
         // 处理会员充值订单
         if (OrderProductType.PRODUCT_TYPE3.getNumber().equals(object.getInteger("productType"))) {
             apiOrder = orderCreateHandleService.memberRechargeHandle(object);
@@ -99,6 +148,7 @@ public class ApiOrderServiceImpl implements ApiOrderService {
             createOrderChildModel.setGoodsType(OrderChildGoodsType.TYPE10.getNumber());
             createOrderChildModel.setGoodsId(Long.valueOf(apiOrder.getExt1()));
             createOrderChildModel.setRechargeContent(dataObject.getString("mobile"));
+            createOrderChildModel.setCustomerMobile(dataObject.getString("mobile"));
             createOrderChildModel.setSaleCount(1);
             createOrderChildModel.setIsTyAgent(false);
             createOrderChildModel.setGoodsPrice(apiOrder.getOrderPrice());
@@ -155,6 +205,12 @@ public class ApiOrderServiceImpl implements ApiOrderService {
 
         apiOrder.setOrderNo(createOrderModel.getOrderNo());
         apiOrder.setStatus(1);
+
+        // 当前账号余额是否可以充值当前金额
+        if (apiMerchants.getAmounts().compareTo(apiOrder.getCostPrice()) < 0) {
+            throw ErrorHelp.genException(SysCode.System, ErrorCode.INSUFFICIENT_BALANCE);
+        }
+
         apiOrderMapper.insert(apiOrder);
 
         return apiOrder;
@@ -163,8 +219,8 @@ public class ApiOrderServiceImpl implements ApiOrderService {
 
 
     @Override
-    @Transactional(rollbackFor=Exception.class,isolation = Isolation.SERIALIZABLE,propagation= Propagation.REQUIRES_NEW)
-    public ApiOrder payOrder(JSONObject object) {
+    @Transactional(rollbackFor=Exception.class,propagation= Propagation.REQUIRES_NEW)
+    public ApiOrder payOrder(JSONObject object)  throws Exception{
 
         ApiMerchants apiMerchants = apiMerchantsService.findByMchId(object.getString("merchId"));
 
@@ -181,9 +237,18 @@ public class ApiOrderServiceImpl implements ApiOrderService {
         orderPayBeforeService.payOrderCheck(order);
 
         // 处理订单
-        HighOrder highOrder = orderPayService.apiMchAmount(order , apiMerchants , apiOrder);
+        HighOrder highOrder = orderPayService.apiMchAmount(order.getOrderNo() , apiMerchants , apiOrder);
+
+        if (highOrder == null) {
+            throw ErrorHelp.genException(SysCode.System, ErrorCode.PAY_FAIL, "");
+        }
+
+        if (highOrder.getExceptionStatus()) {
+            apiOrder.setWhetherException(true);
+            apiOrder.setRemark("当前订单存在异常请联系客服!");
+        }
 
-        if (highOrder.getOrderStatus() != OrderStatus.STATUS1.getNumber()) {
+        if (!Objects.equals(highOrder.getOrderStatus(), OrderStatus.STATUS1.getNumber())) {
             apiOrder.setStatus(highOrder.getOrderStatus());
             apiOrder.setUpdateTime(new Date());
             apiOrderMapper.updateByPrimaryKey(apiOrder);
diff --git a/hai-service/src/main/java/com/hai/order/service/OrderPayService.java b/hai-service/src/main/java/com/hai/order/service/OrderPayService.java
index ce3e977b..ffda7e69 100644
--- a/hai-service/src/main/java/com/hai/order/service/OrderPayService.java
+++ b/hai-service/src/main/java/com/hai/order/service/OrderPayService.java
@@ -45,6 +45,6 @@ public interface OrderPayService {
      * @Param [order, apiMerchants]
      * @Return com.hai.entity.HighOrder
      */
-    HighOrder apiMchAmount(HighOrder order , ApiMerchants apiMerchants , ApiOrder apiOrder);
+    HighOrder apiMchAmount(String orderNo , ApiMerchants apiMerchants , ApiOrder apiOrder) throws Exception;
 
 }
diff --git a/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java b/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java
index 57dbbf72..a9c3d1e5 100644
--- a/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java
+++ b/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java
@@ -735,7 +735,7 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService {
                 throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请选择就餐方式!");
             }
             // 下单
-            jsonObject = QianZhuConfig.createKfcOrder(object.getInteger("eatType"), object.getString("storeCode"), object.getString("customerMobile"), object.getString("orderItems"), object.getString("userId"));
+            jsonObject = QianZhuConfig.createKfcOrder(object.getInteger("eatType"), object.getString("storeCode"), object.getString("customerMobile"), object.getString("orderItems"), "19940218");
 
             // 判断下单是否成功
             if (!Objects.equals(jsonObject.getString("code"), "10000")) {
diff --git a/hai-service/src/main/java/com/hai/order/service/impl/OrderPayServiceImpl.java b/hai-service/src/main/java/com/hai/order/service/impl/OrderPayServiceImpl.java
index 60e08aa7..1c8bc899 100644
--- a/hai-service/src/main/java/com/hai/order/service/impl/OrderPayServiceImpl.java
+++ b/hai-service/src/main/java/com/hai/order/service/impl/OrderPayServiceImpl.java
@@ -13,11 +13,12 @@ import com.hai.order.service.OrderPaySuccessService;
 import com.hai.order.service.OrderService;
 import com.hai.order.type.OrderPayType;
 import com.hai.order.type.OrderProductType;
-import com.hai.service.HighFleetOilCardService;
-import com.hai.service.HighGasOrderService;
-import com.hai.service.HighOilCardService;
-import com.hai.service.HighUserCardService;
+import com.hai.order.type.OrderStatus;
+import com.hai.service.*;
+import org.apache.commons.io.filefilter.IOFileFilter;
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -44,8 +45,8 @@ public class OrderPayServiceImpl implements OrderPayService {
     @Resource
     private HighFleetOilCardService fleetOilCardService;
 
-    @Resource
-    private OrderService orderService;
+    @Autowired
+    private RedisTemplate redisTemplate;
 
     @Resource
     private HighGasOrderService gasOrderService;
@@ -53,6 +54,9 @@ public class OrderPayServiceImpl implements OrderPayService {
     @Resource
     private PriceComputeConfig priceComputeConfig;
 
+    @Resource
+    private HighOrderService highOrderService;
+
     @Override
     public HighOrder hltCardPay(HighOrder order, HighUserCard userCard) throws Exception {
         String goodsDesc = "";
@@ -156,21 +160,38 @@ public class OrderPayServiceImpl implements OrderPayService {
     }
 
     @Override
-    public HighOrder apiMchAmount(HighOrder order, ApiMerchants apiMerchants , ApiOrder apiOrder) {
+    public HighOrder apiMchAmount(String orderNo, ApiMerchants apiMerchants , ApiOrder apiOrder) throws Exception {
+
+        String key = "apiMerchant" + apiMerchants.getMchId();
 
+        // 分布式锁占坑
+        Boolean lock = redisTemplate.opsForValue().setIfAbsent(key, apiOrder.getOrderNo());
 
-        // 判断金额是否充足
-        if (!priceComputeConfig.mchBalance(apiMerchants , apiOrder.getCostPrice() , apiOrder.getMchOrderNo())) {
-            throw ErrorHelp.genException(SysCode.System, ErrorCode.INSUFFICIENT_BALANCE);
+        HighOrder order = highOrderService.getOrderByOrderNo(orderNo);
+
+        if(!order.getOrderStatus().equals(OrderStatus.STATUS1.getNumber())) {
+            throw ErrorHelp.genException(SysCode.System, ErrorCode.ORDER_NO_STAY_PAY, "");
         }
 
-        // 处理订单业务
-        return orderPaySuccessService.orderPaySuccessHandle(
-                order.getOrderNo(),
-                OrderPayType.PAY_TYPE9,
-                null,
-                order.getPayPrice(),
-                null);
+        if(Boolean.TRUE.equals(lock)) {
 
+            // 判断金额是否充足
+            if (!priceComputeConfig.mchBalance(apiMerchants , apiOrder.getCostPrice() , apiOrder.getMchOrderNo())) {
+                throw ErrorHelp.genException(SysCode.System, ErrorCode.INSUFFICIENT_BALANCE);
+            }
+
+            // 处理订单业务
+            return orderPaySuccessService.orderPaySuccessHandle(
+                    order.getOrderNo(),
+                    OrderPayType.PAY_TYPE9,
+                    null,
+                    order.getPayPrice(),
+                    null);
+        } else {
+            // 加锁失败,重试
+            Thread.sleep(100);
+            apiMchAmount(orderNo , apiMerchants , apiOrder);
+        }
+        return null;
     }
 }
diff --git a/hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageServiceImpl.java
index d5d1093d..25bc2d92 100644
--- a/hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageServiceImpl.java
+++ b/hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageServiceImpl.java
@@ -212,6 +212,10 @@ public class HighDiscountPackageServiceImpl implements HighDiscountPackageServic
                 HighDiscountAgentRel discountAgentRel = highDiscountAgentRelService.getRelByDiscountAgent(detailsList.getDiscountId().longValue(), detailsList.getAgentId());
                 List discountAgentCodeList = highDiscountAgentCodeService.getDiscountAgentCodByLimit(discountAgentRel.getId() , detailsList.getNum().longValue());
 
+                System.out.println(discountAgentCodeList.size() < detailsList.getNum());
+                System.out.println(discountAgentCodeList.size());
+                System.out.println(detailsList.getNum());
+
                 if (discountAgentCodeList.size() < detailsList.getNum()) {
                     throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , detailsList.getDiscountName() +"优惠券库存不足");
                 }
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 eda3b737..3b65dfc7 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
@@ -865,6 +865,12 @@ public class HighOrderServiceImpl implements HighOrderService {
                     DateUtil.format(MapUtils.getString(map, "createTimeE"), "yyyy-MM-dd HH:mm:ss"));
         }
 
+        if (StringUtils.isNotBlank(MapUtils.getString(map, "refundTimeS")) && StringUtils.isNotBlank(MapUtils.getString(map, "refundTimeE"))) {
+            criteria.andRefundTimeBetween(
+                    DateUtil.format(MapUtils.getString(map, "refundTimeS"), "yyyy-MM-dd HH:mm:ss"),
+                    DateUtil.format(MapUtils.getString(map, "refundTimeE"), "yyyy-MM-dd HH:mm:ss"));
+        }
+
 //        example.setOrderByClause("create_time desc");
 
 
diff --git a/hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java
index 07d3be72..49a5e72d 100644
--- a/hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java
+++ b/hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java
@@ -770,25 +770,31 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
 
         // 没有充值中的订单 查询所有订单中最新的一条订单状态
         if (childOrders102.size() == 0) {
-            // -1 取消,0充值中 ,1充值成功,2充值失败,3部分成功
-            Integer status = getRechargeOrderLegality(childOrderList.get(0));
-            if (status == 2 || status == -1) {
-                // 修改充值订单状态
-                rechargeChildOrderHandle(childOrderList.get(0) , 103);
-                // 如果订单记录超过5条退款 反之继续充值
-                if (childOrderList.size() > 4) {
-                    return 2;
-                } else {
-                    // 如果订单记录超过71小时 反之继续充值
-                    return hours > 71 ? 2 : 1;
-                }
+            if (childOrderList.size() > 0) {
+                // -1 取消,0充值中 ,1充值成功,2充值失败,3部分成功
+                Integer status = getRechargeOrderLegality(childOrderList.get(0));
+                if (status == 2 || status == -1) {
+                    // 修改充值订单状态
+                    rechargeChildOrderHandle(childOrderList.get(0) , 103);
+                    // 如果订单记录超过5条退款 反之继续充值
+                    if (childOrderList.size() > 4) {
+                        return 2;
+                    } else {
+                        // 如果订单记录超过71小时 反之继续充值
+                        return hours > 71 ? 2 : 1;
+                    }
 
+                }
+                if (status == 1) {
+                    // 修改充值订单状态
+                    rechargeChildOrderHandle(childOrderList.get(0) , 101);
+                    return 5;
+                }
+            } else {
+                // 如果订单记录超过71小时 反之继续充值
+                return hours > 71 ? 2 : 1;
             }
-            if (status == 1) {
-                // 修改充值订单状态
-                rechargeChildOrderHandle(childOrderList.get(0) , 101);
-                return 5;
-            }
+
 
         }
         return 3;
diff --git a/v1/src/main/java/com/v1/controller/WxMsgController.java b/v1/src/main/java/com/v1/controller/WxMsgController.java
index b4015acf..5adfe57f 100644
--- a/v1/src/main/java/com/v1/controller/WxMsgController.java
+++ b/v1/src/main/java/com/v1/controller/WxMsgController.java
@@ -25,6 +25,7 @@ import com.hai.model.HighMerchantStoreModel;
 import com.hai.model.ResponseData;
 import com.hai.service.HighMerchantStoreService;
 import com.hai.service.HighUserService;
+import com.hai.service.impl.OutRechargeOrderServiceImpl;
 import com.v1.config.SysConst;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -59,7 +60,9 @@ import static org.apache.catalina.manager.Constants.CHARSET;
 @Api(value = "微信")
 public class WxMsgController {
 
-    private static Logger log = LoggerFactory.getLogger(WxMsgController.class);
+    private static final Logger log = LoggerFactory.getLogger(OutRechargeOrderServiceImpl.class);
+
+
 
     @Autowired
     private WeChatQrcodeUtils weChatQrcodeUtils;
@@ -319,7 +322,7 @@ public class WxMsgController {
     public ResponseData getWxToken() {
         try {
 
-            return ResponseMsgUtil.success(weChatQrcodeUtils.getWxToken());
+            return ResponseMsgUtil.success(weChatQrcodeUtils.getWxToken(false));
 
         } catch (Exception e) {
             return ResponseMsgUtil.exception(e);
@@ -401,11 +404,9 @@ public class WxMsgController {
     public ResponseData verifyWx(@RequestParam(value = "url", required = true) String url)  {
 
         try {
-            // 获取ticket
-            Map ticketParams = new HashMap<>();
-            ticketParams.put("access_token", weChatQrcodeUtils.getWxToken());
-            ticketParams.put("type", "jsapi");
-            JSONObject jsapiTicket = HttpsUtils.doGet("https://api.weixin.qq.com/cgi-bin/ticket/getticket", ticketParams);
+
+            JSONObject jsapiTicket = weChatQrcodeUtils.getTicket(false);
+            log.info("获取jsapiTicket"+ jsapiTicket);
             // 拼接签名
             Map map = new HashMap<>();
             map.put("noncestr", WxUtils.makeNonStr());
@@ -413,12 +414,16 @@ public class WxMsgController {
             map.put("timestamp", new Date().getTime());
             map.put("url",url);
 
+            log.info("拼接map"+ map);
+
             Map objectMap = new HashMap<>();
             objectMap.put("appId" , SysConst.getSysConfig().getWxH5AppId());
             objectMap.put("timestamp" , map.get("timestamp"));
             objectMap.put("nonceStr" , map.get("noncestr"));
             objectMap.put("signature" , WxUtils.getSHA1(map));
 
+            log.info("拼接objectMap"+ objectMap);
+
             return ResponseMsgUtil.success(objectMap);
         } catch (Exception e) {
             return null;
@@ -436,7 +441,7 @@ public class WxMsgController {
             JSONObject postObject = new JSONObject();
             postObject.put("expire_type" ,1);
             postObject.put("expire_interval" ,30);
-            JSONObject object = HttpsUtils.doPost("https://api.weixin.qq.com/wxa/generate_urllink?access_token=" + weChatQrcodeUtils.getWxToken(), postObject);
+            JSONObject object = HttpsUtils.doPost("https://api.weixin.qq.com/wxa/generate_urllink?access_token=" + weChatQrcodeUtils.getWxToken(false), postObject);
             return ResponseMsgUtil.success(object);
         } catch (Exception e) {
             return null;
@@ -444,6 +449,7 @@ public class WxMsgController {
 
     }
 
+
 //    @RequestMapping(value = "/verifyWx", method = RequestMethod.GET)
 //    @ResponseBody
 //    @ApiOperation(value = "微信签名")
diff --git a/v1/src/main/java/com/v1/controller/orderController.java b/v1/src/main/java/com/v1/controller/orderController.java
index 038c6f09..5bcae0be 100644
--- a/v1/src/main/java/com/v1/controller/orderController.java
+++ b/v1/src/main/java/com/v1/controller/orderController.java
@@ -21,6 +21,8 @@ import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -46,6 +48,9 @@ public class orderController {
     @Resource
     private SecConfigService secConfigService;
 
+    @Autowired
+    private RedisTemplate redisTemplate;
+
     @Resource
     private ApiOrderService orderService;
 
@@ -128,8 +133,9 @@ public class orderController {
                     throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未填写加油信息;加油金额、油号、抢号");
                 }
             }
+            JSONObject dataObject = JSONObject.parseObject(object.getString("content"));
+
             if (object.getInteger("productType").equals(OrderProductType.PRODUCT_TYPE9.getNumber()) || object.getInteger("productType").equals(OrderProductType.PRODUCT_TYPE3.getNumber())) {
-                JSONObject dataObject = JSONObject.parseObject(object.getString("content"));
                 if (StringUtils.isBlank(dataObject.getString("productId"))
                         || StringUtils.isBlank(dataObject.getString("mobile"))
                 ) {
@@ -138,6 +144,24 @@ public class orderController {
                 }
             }
 
+            if (object.getInteger("productType").equals(OrderProductType.PRODUCT_TYPE1.getNumber())) {
+                if (StringUtils.isBlank(dataObject.getString("customerMobile"))
+                ) {
+                    log.error("OrderController -> create() error!","");
+                    throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未填写下单手机号");
+                }
+            }
+
+            if (object.getInteger("productType").equals(OrderProductType.PRODUCT_TYPE2.getNumber())) {
+                if (dataObject.getJSONArray("data") == null
+                        || StringUtils.isBlank(dataObject.getString("customerMobile"))
+                        || StringUtils.isBlank(dataObject.getString("storeCode"))
+                        || dataObject.getInteger("eatType") == null
+                ) {
+                    log.error("OrderController -> create() error!","");
+                    throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未填写下单手机号,就餐方式,下单信息,门店编码");
+                }
+            }
             return ResponseMsgUtil.success(orderService.createOrder(object));
 
         } catch (Exception e) {
@@ -201,11 +225,16 @@ public class orderController {
 
             object.put("orderNo" , apiOrder.getOrderNo());
 
-            return ResponseMsgUtil.success(orderService.payOrder(object));
+            ApiOrder order = orderService.payOrder(object);
+
+            return ResponseMsgUtil.success(order);
 
         } catch (Exception e) {
             log.error("HighOpenApiController --> createOrder() error!", e);
             return ResponseMsgUtil.exception(e);
+        } finally {
+            // 删除key,释放锁
+            redisTemplate.delete( "apiMerchant" + object.getString("merchId"));
         }
     }
 
diff --git a/v1/src/main/resources/dev/application.yml b/v1/src/main/resources/dev/application.yml
index 57d3a763..87ac408e 100644
--- a/v1/src/main/resources/dev/application.yml
+++ b/v1/src/main/resources/dev/application.yml
@@ -28,7 +28,7 @@ spring:
     poolPreparedStatements: true
     maxOpenPreparedStatements: 20
   redis:
-    database: 0
+    database: 1
     host: 139.9.154.68
     port: 36379
     password: HF123456.Redis