From 9f48149490146953cbb2d8f41636fefe08c15db5 Mon Sep 17 00:00:00 2001 From: Sum1Dream <418471657@qq.com> Date: Fri, 2 Feb 2024 10:52:53 +0800 Subject: [PATCH] Merge branch 'new-dev' into 2.0-dev # Conflicts: # hai-service/src/main/java/com/hai/openApi/service/impl/ApiOrderCreateHandleServiceImpl.java # hai-service/src/main/java/com/hai/openApi/service/impl/ApiOrderServiceImpl.java --- .../bweb/controller/ApiCouponController.java | 61 ++-- .../bweb/controller/ApiProductController.java | 40 +++ .../bweb/controller/HighTestController.java | 2 +- .../OutRechargePriceController.java | 10 +- .../main/java/com/cweb/config/AuthConfig.java | 1 + .../HighCouponCodeOtherController.java | 90 +++++ .../main/java/com/web/config/AuthConfig.java | 1 + .../web/controller/OrderPayController.java | 25 ++ .../notify/PetroNotifyController.java | 58 ++++ .../com/hai/schedule/HighCouponSchedule.java | 49 ++- .../hai/common/utils/PetroEncryptUtil.java | 189 ++++++++++ .../java/com/hai/common/utils/WxUtils.java | 30 ++ .../java/com/hai/config/CommonSysConfig.java | 5 + .../main/java/com/hai/config/PetroConfig.java | 326 ++++++++++-------- .../java/com/hai/config/RechargeConfig.java | 77 ++++- .../java/com/hai/dao/ApiCouponMapper.java | 38 +- .../com/hai/dao/ApiCouponSqlProvider.java | 70 ++++ .../main/java/com/hai/entity/ApiCoupon.java | 81 +++++ .../java/com/hai/entity/ApiCouponExample.java | 301 ++++++++++++++++ .../com/hai/entity/HighCouponCodeOther.java | 2 +- .../impl/ApiOrderCreateHandleServiceImpl.java | 5 +- .../impl/OrderPaySuccessServiceImpl.java | 14 +- .../service/impl/ApiMerchantsServiceImpl.java | 1 + .../impl/HighCouponAgentServiceImpl.java | 12 +- .../impl/HighCouponCodeServiceImpl.java | 16 +- .../HighDiscountAgentCodeServiceImpl.java | 30 +- .../resources/dev/commonConfig.properties | 16 +- .../prod-9401/commonConfig.properties | 22 +- .../resources/prod/commonConfig.properties | 21 +- .../main/java/com/v1/config/AuthConfig.java | 1 + .../business/ApiCouponController.java | 97 +++++- 31 files changed, 1428 insertions(+), 263 deletions(-) create mode 100644 hai-order/src/main/java/com/web/controller/notify/PetroNotifyController.java create mode 100644 hai-service/src/main/java/com/hai/common/utils/PetroEncryptUtil.java diff --git a/hai-bweb/src/main/java/com/bweb/controller/ApiCouponController.java b/hai-bweb/src/main/java/com/bweb/controller/ApiCouponController.java index d372bb0d..a79fee9d 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/ApiCouponController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/ApiCouponController.java @@ -68,8 +68,8 @@ public class ApiCouponController { JSONObject jsonObject = petroConfig.synCouponRule(); - if (jsonObject.getString("code").equals("1")) { - String data = PetroConfig.decrypt(jsonObject.getString("biz_content")); + if (jsonObject.getString("resultCode").equals("0000")) { + String data = PetroConfig.decrypt(jsonObject.getString("jsonResult")); JSONArray jsonArray = JSONArray.parseArray(data); System.out.println(jsonArray); @@ -78,42 +78,41 @@ public class ApiCouponController { for (int i = 0; i < jsonArray.size(); i++) { JSONObject object = jsonArray.getJSONObject(i); - apiCoupon = apiCouponService.findCoupon(object.getString("request_code")); - - System.out.println(object); - System.out.println(object.getString("request_code")); - System.out.println(apiCoupon); - - + apiCoupon = apiCouponService.findCoupon(object.getString("alias")); if (apiCoupon == null ) { - if (object.getInteger("status") == 1 && object.getInteger("total_num") > 0) { - apiCoupon = new ApiCoupon(); - apiCoupon.setCode(object.getString("request_code")); - apiCoupon.setDesc(object.getString("ticket_desc")); - apiCoupon.setGoodsType(object.getString("goods_type")); - apiCoupon.setName(object.getString("ticket_name")); - apiCoupon.setEffectiveDays(object.getInteger("effective_days")); - apiCoupon.setImg(object.getString("img")); - apiCoupon.setCreateTime(new Date()); - apiCoupon.setUpdateTime(new Date()); - apiCoupon.setStatus(1); - apiCoupon.setType(type); - apiCoupon.setPrice(object.getInteger("face_amount")); - apiCouponService.insertCoupon(apiCoupon); + apiCoupon = new ApiCoupon(); + apiCoupon.setCode(object.getString("alias")); + apiCoupon.setDesc(object.getString("declare")); + apiCoupon.setGoodsType(object.getString("bizType")); + apiCoupon.setName(object.getString("title")); + apiCoupon.setValidType(object.getInteger("validType")); + if (object.getInteger("validType") == 1) { + apiCoupon.setValidDate(object.getDate("validDate")); } - + apiCoupon.setEffectiveDays(object.getInteger("validDate")); + apiCoupon.setImg(object.getString("img")); + apiCoupon.setCreateTime(new Date()); + apiCoupon.setUpdateTime(new Date()); + apiCoupon.setStatus(1); + apiCoupon.setType(type); + apiCoupon.setPrice(object.getInteger("faceValue")); + apiCouponService.insertCoupon(apiCoupon); } else { - apiCoupon.setCode(object.getString("request_code")); - apiCoupon.setDesc(object.getString("ticket_desc")); - apiCoupon.setName(object.getString("ticket_name")); - apiCoupon.setGoodsType(object.getString("goods_type")); - apiCoupon.setEffectiveDays(object.getInteger("effective_days")); + apiCoupon.setCode(object.getString("alias")); + apiCoupon.setDesc(object.getString("declare")); + apiCoupon.setGoodsType(object.getString("bizType")); + apiCoupon.setName(object.getString("title")); + apiCoupon.setValidType(object.getInteger("validType")); + if (object.getInteger("validType") == 1) { + apiCoupon.setValidDate(object.getDate("validDate")); + } + apiCoupon.setEffectiveDays(object.getInteger("validDate")); apiCoupon.setImg(object.getString("img")); apiCoupon.setUpdateTime(new Date()); - apiCoupon.setPrice(object.getInteger("face_amount")); + apiCoupon.setStatus(1); apiCoupon.setType(type); - apiCoupon.setStatus(object.getInteger("status")); + apiCoupon.setPrice(object.getInteger("faceValue")); apiCouponService.editCoupon(apiCoupon); } } diff --git a/hai-bweb/src/main/java/com/bweb/controller/ApiProductController.java b/hai-bweb/src/main/java/com/bweb/controller/ApiProductController.java index 85e63908..be685d57 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/ApiProductController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/ApiProductController.java @@ -1,5 +1,6 @@ package com.bweb.controller; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; @@ -10,6 +11,7 @@ import com.hai.common.security.SessionObject; import com.hai.common.security.UserCenter; import com.hai.common.utils.PageUtil; import com.hai.common.utils.ResponseMsgUtil; +import com.hai.config.RechargeConfig; import com.hai.entity.*; import com.hai.model.OutRechargePriceModel; import com.hai.model.ResponseData; @@ -342,5 +344,43 @@ public class ApiProductController { } } + @RequestMapping(value = "/jNiuGoodsList", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询简牛话费产品列表") + public ResponseData jNiuGoodsList() { + try { + JSONObject object = RechargeConfig.jNiuGoodsList(); + JSONArray array = object.getJSONArray("data"); + List list = new ArrayList<>(); + for (int i = 0; i < array.size(); i++) { + JSONObject jsonObject = array.getJSONObject(i); + JSONArray jsonArray = jsonObject.getJSONArray("goodsOption"); + for (int j = 0; j < jsonArray.size(); j++) { + JSONObject goodsOption = jsonArray.getJSONObject(j); + JSONArray childArray = goodsOption.getJSONArray("child"); + for (int t = 0; t < childArray.size(); t++) { + JSONObject child = childArray.getJSONObject(j); + JSONObject data = new JSONObject(); + data.put("title" , jsonObject.getString("sort_title") + goodsOption.getString("name")); + data.put("goodsId" , child.getString("goods_id")); + data.put("goodsOptionId" , child.getString("goods_option_id")); + data.put("platPrice" , child.getString("plat_price")); + data.put("officialPrice" , child.getString("official_price")); + list.add(data); + } + + } + + } + return ResponseMsgUtil.success(list); + + } catch (Exception e) { + log.error("ApiMerchantsController --> findById() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + + } 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 2d5d1423..e5e0b484 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java @@ -1 +1 @@ - package com.bweb.controller; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.utils.HttpsUtils; import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.WxUtils; import com.hai.config.*; import com.hai.entity.*; import com.hai.enum_type.GasOilPriceStatusEnum; import com.hai.model.HighMerchantModel; import com.hai.model.HighMerchantStoreModel; import com.hai.model.ResponseData; import com.hai.openApi.config.BlxConfig; import com.hai.order.service.OrderService; import com.hai.order.type.OrderProductType; import com.hai.order.type.OrderRefundOpUserType; import com.hai.order.utils.OrderUtil; import com.hai.pay.channel.huipay.config.HuiConfig; import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.bouncycastle.LICENSE; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.io.FileOutputStream; import java.io.InputStream; import java.math.BigDecimal; import java.net.URL; import java.net.URLConnection; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/test") @Api(value = "订单接口") public class HighTestController { private static Logger log = LoggerFactory.getLogger(HighTestController.class); @Resource private BsOrderRebateService bsOrderRebateService; @Resource private PetroConfig petroConfig; @Resource private HighGoldRecService highGoldRecService; @Resource private OrderService orderService; @Resource private HighUserCardService highUserCardService; @Resource private HighOrderService highOrderService; @Resource private HighUserService highUserService; @Resource private HighGasService gasService; @Resource private HighMerchantService highMerchantService; @Resource private HighMerchantStoreService highMerchantStoreService; @Resource private HighGasOilPriceService highGasOilPriceService; @Resource private HuiConfig huiConfig; @Resource private CommonService commonService; @Resource private HighOilCardOrderService highOilCardOrderService; @Resource private HighGasOrderService gasOrderService; @Resource private ShellGroupService shellGroupService; @Resource private HighMerchantStoreService merchantStoreService; @RequestMapping(value = "/gasSyncPayment", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "重庆壳牌推送") public ResponseData gasSyncPayment(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighGasOrder order = gasOrderService.getDetailByOrderNo(orderNo); if (order != null) { // 查询油站 HighMerchantStore store = merchantStoreService.getDetailById(order.getStoreId()); if (store == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到门店"); } return ResponseMsgUtil.success( // 推送加好油 shellGroupService.gasSyncPayment(order.getOrderNo(), store.getStoreKey(), order.getPayTime(), order.getGasRefuelPrice(), order.getGasOilNo(), order.getGasGunNo(), order.getPayPrice(), order.getTotalDeductionPrice() ) ); } return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("HighOrderController --> gasSyncPayment() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value="/resolveResponse",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "解析") public ResponseData resolveResponse( @RequestParam(name = "data", required = false) String data ) { try { JSONObject cardInfoObject = HuiLianTongUnionCardConfig.resolveResponse(data); return ResponseMsgUtil.success(cardInfoObject); } catch (Exception e) { log.error("getUserByTelephone",e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getHuiLianTongCardConsume", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询汇联通工会卡消费记录") public ResponseData getHuiLianTongCardConsume(@RequestParam(name = "businessType", required = true) String businessType, @RequestParam(name = "cardNo", required = true) String cardNo, @RequestParam(name = "sdate", required = true) Long sdate, @RequestParam(name = "edate", required = true) Long edate, @RequestParam(name = "pageNum", required = true) Integer pageNum, @RequestParam(name = "pageSize", required = true) Integer pageSize, HttpServletRequest request) { try { JSONObject consumptionRecord = HuiLianTongUnionCardConfig.queryConsumptionRecordByBusiness(businessType, cardNo, sdate, edate, pageNum, pageSize); if (StringUtils.isBlank(consumptionRecord.getString("data"))) { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQUEST_ERROR, ""); } JSONArray array = HuiLianTongUnionCardConfig.resolveResponse(consumptionRecord.getString("data")).getJSONArray("records"); return ResponseMsgUtil.success(array); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardConsume() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/createOrder", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "创建订单") public ResponseData createOrder(@RequestBody JSONObject object) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230394901"); mapPost.put("timetable" , new Date().getTime()); mapPost.put("orderNo" , "TEST" + OrderUtil.generateOrderNo()); mapPost.put("productType" , object.getString("productType")); mapPost.put("content" , object.getJSONObject("content").toString()); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "B94B5E62807FA56A7260AB581D8A1B48", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("https://hsg.dctpay.com/v1/order/createOrder" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/payOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "支付订单") public ResponseData payOrder(@RequestParam(name = "mchOrderNo", required = true) String mchOrderNo) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("mchOrderNo" , mchOrderNo); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("mchOrderNo" , mchOrderNo); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/order/orderPay" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryOrderDetail", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询订单详情") public ResponseData queryOrderDetail(@RequestParam(name = "mchOrderNo", required = true) String mchOrderNo) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("mchOrderNo" , mchOrderNo); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("mchOrderNo" , mchOrderNo); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/order/queryOrderDetail" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/deposit", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "工会卡充值") public ResponseData deposit(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); HighChildOrder highChildOrder = order.getHighChildOrderList().get(0); if (order.getOrderStatus() != 2) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单状态错误"); } // 汇联通充值 String goodsDesc = "汇联通充值"+order.getPayPrice()+"元"; String tranDesc = ""; String businessType = "ghk_deposit"; String orderNoAgain = OrderUtil.generateOrderNo(); order.setOrderStatus(Integer.valueOf(3)); order.setRemarks("工会卡再次充值订单号" + orderNoAgain); highOrderService.updateOrder(order); // 汇联通卡充值 JSONObject deposit = HuiLianTongUnionCardConfig.deposit(orderNoAgain, highChildOrder.getGoodsSpecName(), order.getPayPrice(), businessType, order.getPaySerialNo(), goodsDesc); return ResponseMsgUtil.success( HuiLianTongUnionCardConfig.resolveResponse(deposit.getString("data"))); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getHuiLianTongCardByCardNo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据卡号查询汇联通工会卡详情") public ResponseData getHuiLianTongCardByCardNo(@RequestParam(name = "cardNo", required = true) String cardNo) { try { // 查询工会卡 JSONObject cardInfo = HuiLianTongUnionCardConfig.queryBalance(cardNo); JSONObject resolveResponse = HuiLianTongUnionCardConfig.resolveResponse(cardInfo.getString("data")); return ResponseMsgUtil.success(resolveResponse); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardByCardNo() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/consumption", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "工会卡支付") public ResponseData consumption(@RequestParam(name = "payRealPrice", required = true) BigDecimal payRealPrice, @RequestParam(name = "cardNo", required = true) String cardNo) { try { String goodsDesc = ""; String tranDesc = ""; String instCode = "11101652"; String businessType = "hisen_consume"; // 工会卡支付 JSONObject consumption = HuiLianTongUnionCardConfig.consumption(OrderUtil.generateOrderNo(), cardNo, payRealPrice, businessType, instCode, goodsDesc, tranDesc); if (!consumption.getString("respCode").equals("0000")) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumption.getString("respMessage")); } // 响应参数 JSONObject consumptionResult = HuiLianTongUnionCardConfig.resolveResponse(consumption.getString("data")); if (consumptionResult.getBoolean("success") != true) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumptionResult.getString("message")); } return ResponseMsgUtil.success(consumptionResult); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardByCardNo() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/refundOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "工会卡退款") public ResponseData refundOrder(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); if (order.getOrderStatus() != 2) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单状态错误"); } orderService.refundOrder(order, OrderProductType.getDataByType(order.getProductType()).getName() + "退款",OrderRefundOpUserType.TYPE1, null, "系统自动退款"); if (order.getProductType().equals(4)) { HighUser user = highUserService.findByUserId(order.getMemId()); // 获取应退款积分 int integralNum = order.getTotalPrice().multiply(new BigDecimal(100)).intValue(); if ( integralNum> user.getGold()) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "积分数量不足"); } String remark = "订单" + order.getOrderNo() + "退还积分:" + integralNum; // 积分退款 highUserService.goldHandle(user.getId(), integralNum,2, 3, order.getId() , remark , order.getOrderNo()); } return ResponseMsgUtil.success("退款成功"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/externalOrderRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "对外订单退款") public ResponseData externalOrderRefund(@RequestParam(name = "paySerialNo", required = true) String paySerialNo, @RequestParam(name = "WxMchId", required = true) String WxMchId, @RequestParam(name = "payRealPrice", required = true) String payRealPrice) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "B94B5E62807FA56A7260AB581D8A1B48"); mapPost.put("merchId" , "20230394901"); mapPost.put("paySerialNo" , paySerialNo); mapPost.put("wxMchId" , WxMchId); mapPost.put("payRealPrice" , payRealPrice); mapPost.put("refundPrice" , payRealPrice); Map map = new HashMap<>(); map.put("apiKey" , "B94B5E62807FA56A7260AB581D8A1B48"); map.put("merchId" , "20230394901"); map.put("paySerialNo" , paySerialNo); map.put("wxMchId" , WxMchId); map.put("payRealPrice" , payRealPrice); map.put("refundPrice" , payRealPrice); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("https://hsg.dctpay.com/v1/order/externalOrderRefund" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getBlxCouponBalance", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询停车券") public ResponseData getBlxCouponBalance(@RequestParam(name = "phone", required = true) String phone) { try { highUserCardService.getBlxCouponBalance(phone); return ResponseMsgUtil.success("object"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryJsParking", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询捷顺停车场") public ResponseData queryJsParking(@RequestParam(name = "gps", required = true) String gps) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("gps" , gps); mapPost.put("range" , "1000"); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/queryJsParking" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getUserCouponPage", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询捷顺停车场") public ResponseData getUserCouponPage(@RequestParam(name = "phone", required = true) String phone) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("phone" , phone); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/getUserCouponPage" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryJsOrderList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询车牌订单列表信息") public ResponseData queryJsOrderList(@RequestParam(name = "carNo", required = true) String carNo, @RequestParam(name = "orderStatus", required = true) String orderStatus) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("orderStatus" , orderStatus); mapPost.put("carNo" , carNo); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/queryJsOrderList" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/sendCoupon", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "发放券") public ResponseData sendCoupon(@RequestParam(name = "couponCode", required = true) String couponCode, @RequestParam(name = "receiverCount", required = true) String receiverCount, @RequestParam(name = "receiverPhone", required = true) String receiverPhone) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/getCouponList" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/preorder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "发起支付") public ResponseData preorder() { try { JSONObject object = new JSONObject(); object.put("outTradeNo" , "HUI" + OrderUtil.generateOrderNo()); object.put("transType" , "JSAPI"); object.put("payMode" , "WECHAT"); object.put("totalAmount" , "0.01"); object.put("profitSharing" , 0); object.put("subject" , "测试"); object.put("userId" , "oUGn_4unIjp90MY-oEXluY4laDrQ"); return ResponseMsgUtil.success(huiConfig.preorder(object)); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryGasInfoListByPage", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询团油门店") public ResponseData queryGasInfoListByPage() { try { HighMerchantModel merchant = highMerchantService.getMerchantById(39L); if (merchant == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到商户"); } JSONObject jsonObjectP = TuanYouConfig.queryGasInfoListByPage(1, 1000); JSONObject resultObjectP = jsonObjectP.getObject("result", JSONObject.class); for (int i = 1; i <= resultObjectP.getInteger("totalPageNum").intValue();i++) { JSONObject jsonObject = TuanYouConfig.queryGasInfoListByPage(i, 1000); JSONObject resultObject = jsonObject.getObject("result", JSONObject.class); JSONArray jsonArray = resultObject.getJSONArray("gasInfoList"); HighMerchantStore highMerchantStore; HighGasOilPrice highGasOilPrice; for (Object gasObject : jsonArray) { JSONObject object = JSONObject.parseObject(JSONObject.toJSONString(gasObject)); HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreByKey(object.getString("gasId")); if (store != null) { store.setType(1); store.setSourceType(2); store.setMerchantId(merchant.getId()); store.setCompanyId(merchant.getCompanyId()); store.setStoreKey(object.getString("gasId")); store.setStoreName(object.getString("gasName")); store.setStoreLogo(object.getString("gasLogoSmall")); store.setRegionId(object.getLong("provinceCode")); store.setRegionName(object.getString("provinceName")); store.setAddress(object.getString("gasAddress")); store.setLongitude(object.getString("gasAddressLongitude")); store.setLatitude(object.getString("gasAddressLatitude")); store.setStatus(object.getInteger("gasStatus")); store.setPrestoreType(0); store.setOperatorId(0L); store.setOperatorName("系统创建"); store.setUpdateTime(new Date()); store.setExt1(object.getString("gasSourceId")); highMerchantStoreService.updateMerchantStoreDetail(store); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); // 查询门店油号 highGasOilPrice = highGasOilPriceService.getGasOilPriceByStoreAndOilNo(store.getId(), oilPriceObject.getString("oilNo")); if (highGasOilPrice == null) { highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getString("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); highGasOilPrice.setStatus(GasOilPriceStatusEnum.status1.getStatus()); } else { highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getString("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); } highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } else { highMerchantStore = new HighMerchantStore(); highMerchantStore.setType(1); highMerchantStore.setSourceType(2); highMerchantStore.setMerchantId(merchant.getId()); highMerchantStore.setCompanyId(merchant.getCompanyId()); highMerchantStore.setStoreKey(object.getString("gasId")); highMerchantStore.setStoreName(object.getString("gasName")); highMerchantStore.setStoreLogo(object.getString("gasLogoSmall")); highMerchantStore.setRegionId(object.getLong("provinceCode")); highMerchantStore.setRegionName(object.getString("provinceName")); highMerchantStore.setAddress(object.getString("gasAddress")); highMerchantStore.setLongitude(object.getString("gasAddressLongitude")); highMerchantStore.setLatitude(object.getString("gasAddressLatitude")); highMerchantStore.setStatus(1); highMerchantStore.setPrestoreType(0); highMerchantStore.setOperatorId(0L); highMerchantStore.setOperatorName("系统创建"); highMerchantStore.setCreateTime(new Date()); highMerchantStore.setUpdateTime(new Date()); highMerchantStore.setExt1(object.getString("gasSourceId")); HighMerchantStoreModel merchantStoreModel = new HighMerchantStoreModel(); BeanUtils.copyProperties(highMerchantStore, merchantStoreModel); highMerchantStoreService.insertMerchantStore(merchantStoreModel); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(merchantStoreModel.getId()); highGasOilPrice.setOilNo(oilPriceObject.getString("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } } } return ResponseMsgUtil.success("完成"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/test", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "测试") public ResponseData test(@RequestParam(name = "no", required = true) String no) { try { JSONObject jsonObject = DianConfig.getGasInfoByGasId(no); return ResponseMsgUtil.success(jsonObject); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getGasInfoAll", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取全量油站") public ResponseData getGasInfoAll() { try { HighMerchantModel merchant = highMerchantService.getMerchantById(39L); JSONObject jsonObject = DianConfig.getGasInfoAll(); JSONArray resultObject = jsonObject.getObject("result", JSONArray.class); for (int i = 0; i < resultObject.size();i++) { Object objectData = resultObject.get(i); JSONObject object = JSONObject.parseObject(JSONObject.toJSONString(objectData)); HighMerchantStore highMerchantStore; HighGasOilPrice highGasOilPrice; HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreByKey(object.getString("jyzid")); SecRegion region = commonService.getRegionsByName(object.getString("province")); if (store != null) { store.setType(1); store.setSourceType(6); store.setMerchantId(merchant.getId()); store.setCompanyId(merchant.getCompanyId()); store.setStoreKey(object.getString("jyzid")); store.setStoreName(object.getString("mingcheng")); store.setStoreLogo(object.getString("tupian")); store.setRegionId(region.getRegionId()); store.setRegionName(object.getString("province")); store.setAddress(object.getString("dizhi")); store.setLongitude(object.getString("lng")); store.setLatitude(object.getString("lat")); store.setStatus(object.getInteger("zhuangtai")); store.setPrestoreType(0); store.setOperatorId(0L); store.setOperatorName("系统创建"); store.setUpdateTime(new Date()); store.setExt1(object.getString("gasSourceId")); highMerchantStoreService.updateMerchantStoreDetail(store); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); // 查询门店油号 highGasOilPrice = highGasOilPriceService.getGasOilPriceByStoreAndOilNo(store.getId(), oilPriceObject.getString("youhao")); if (highGasOilPrice == null) { highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getString("youhao")); highGasOilPrice.setOilNoName(oilPriceObject.getString("youhao") + "#"); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oiltype")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oiltype").equals("1") ? "汽油": "柴油"); highGasOilPrice.setStatus(GasOilPriceStatusEnum.status1.getStatus()); } else { highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getString("youhao")); highGasOilPrice.setOilNoName( oilPriceObject.getString("youhao") + "#"); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oiltype")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oiltype").equals("1") ? "汽油": "柴油"); } highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } else { highMerchantStore = new HighMerchantStore(); highMerchantStore.setType(1); highMerchantStore.setSourceType(6); highMerchantStore.setMerchantId(merchant.getId()); highMerchantStore.setCompanyId(merchant.getCompanyId()); highMerchantStore.setStoreKey(object.getString("jyzid")); highMerchantStore.setStoreName(object.getString("mingcheng")); highMerchantStore.setStoreLogo(object.getString("tupian")); highMerchantStore.setRegionId(region.getRegionId()); highMerchantStore.setRegionName(object.getString("province")); highMerchantStore.setAddress(object.getString("dizhi")); highMerchantStore.setLongitude(object.getString("lng")); highMerchantStore.setLatitude(object.getString("lat")); highMerchantStore.setStatus(1); highMerchantStore.setPrestoreType(0); highMerchantStore.setOperatorId(0L); highMerchantStore.setOperatorName("系统创建"); highMerchantStore.setCreateTime(new Date()); highMerchantStore.setUpdateTime(new Date()); highMerchantStore.setExt1(object.getString("gasSourceId")); HighMerchantStoreModel merchantStoreModel = new HighMerchantStoreModel(); BeanUtils.copyProperties(highMerchantStore, merchantStoreModel); highMerchantStoreService.insertMerchantStore(merchantStoreModel); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(merchantStoreModel.getId()); highGasOilPrice.setOilNo(oilPriceObject.getString("youhao")); highGasOilPrice.setOilNoName(oilPriceObject.getString("youhao") + "#"); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oiltype")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oiltype").equals("1") ? "汽油": "柴油"); highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } } return ResponseMsgUtil.success(jsonObject); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getOrderPay", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "getOrderPay") public ResponseData getOrderPay(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOilCardOrder highOilCardOrder = highOilCardOrderService.findOrder(orderNo); highOilCardOrder.setStatus(2); JSONObject object = KytcService.getOrderPay(highOilCardOrder.getThirdOrderNo() , highOilCardOrder.getPrice() , highOilCardOrder.getCardNo()); highOilCardOrder.setExt1(object.toJSONString()); highOilCardOrderService.updateOilCardOrder(highOilCardOrder); return ResponseMsgUtil.success("成功"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getOrderInfo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "getOrderInfo") public ResponseData getOrderInfo(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOilCardOrder highOilCardOrder = highOilCardOrderService.findOrder(orderNo); JSONObject object = KytcService.getOrderInfo(highOilCardOrder.getThirdOrderNo()); highOilCardOrder.setExt2(object.toJSONString()); if (object.getBoolean("State") == true) { JSONObject jsonObject = object.getJSONObject("Data"); if (jsonObject.getInteger("OilOrderState") == 2) { highOilCardOrder.setStatus(3); HighOrder highOrder = highOrderService.getOrderByOrderNo(highOilCardOrder.getOrderNo()); highOrder.setOrderStatus(3); highOrder.getHighChildOrderList().get(0).setChildOrderStatus(3); highOrderService.updateOrder(highOrder); } } highOilCardOrderService.updateOilCardOrder(highOilCardOrder); return ResponseMsgUtil.success("成功"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getLogisticsMsg", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取物流") public ResponseData getLogisticsMsg(@RequestParam(name = "no", required = true) String no) { try { JSONObject jsonObjects = CommonConfig.getLogisticsMsg(no); return ResponseMsgUtil.success(jsonObjects); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } // @RequestMapping(value = "/synCouponRule", method = RequestMethod.GET) // @ResponseBody // @ApiOperation(value = "获取卡券") // public ResponseData synCouponRule() { // try { // return ResponseMsgUtil.success(PetroConfig.synCouponRule()); // } catch (Exception e) { // log.error("HighOrderController --> getBackendToken() error!", e); // return ResponseMsgUtil.exception(e); // } // } // @RequestMapping(value = "/getCoupon", method = RequestMethod.GET) // @ResponseBody // @ApiOperation(value = "卡券下单") // public ResponseData getCoupon() { // try { // // JSONObject jsonObject = PetroConfig.getCoupon("16000443991501" , "18090580471" , OrderUtil.generateOrderNo()); // String data = PetroConfig.decrypt(jsonObject.getString("biz_content")); // JSONObject object = JSONObject.parseObject(data); // // return ResponseMsgUtil.success(object); // } catch (Exception e) { // log.error("HighOrderController --> getBackendToken() error!", e); // return ResponseMsgUtil.exception(e); // } // } @RequestMapping(value = "/decrypt", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "解码") public ResponseData decrypt(@RequestParam(name = "content", required = true) String content) { try { String data = PetroConfig.decrypt(content); return ResponseMsgUtil.success(data); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/deleteOilNo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "删除油品") public ResponseData deleteOilNo() { try { gasService.deleteOilNo(); return ResponseMsgUtil.success("1231243"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getJiaHaoYouAllStation", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "加好油油站刷新") public ResponseData getJiaHaoYouAllStation() { try { gasService.getJiaHaoYouAllStation(); return ResponseMsgUtil.success("1231243"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getDianAllStation", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "点点网络") public ResponseData getDianAllStation() { try { gasService.getDianAllStation(); return ResponseMsgUtil.success("1231243"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() err1or!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/integralRebateOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "积分返利") public ResponseData integralRebateOrder() { try { // 查询满足初步返利条件订单 List order = highOrderService.integralRebateOrder(); for (HighOrder highOrder : order) { // 查询是否存在积分记录 Map map = new HashMap<>(); map.put("goldType", 1); map.put("resType", 4); map.put("userId", highOrder.getMemId()); map.put("resId", highOrder.getId()); List goldRecs = highGoldRecService.getGoldRec(map); // 判断是否重复赠送积分 if (goldRecs.size() == 0) { bsOrderRebateService.insertOrderRebate(highOrder); } highOrder.setWhetherRebate(true); highOrderService.updateOrderDetail(highOrder); } return ResponseMsgUtil.success("1231243"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() err1or!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getApiCoupon", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取卡券") public ResponseData getApiCoupon() { try { // 查询满足初步返利条件订单 List order = highOrderService.integralRebateOrder(); for (HighOrder highOrder : order) { // 查询是否存在积分记录 Map map = new HashMap<>(); map.put("goldType", 1); map.put("resType", 4); map.put("userId", highOrder.getMemId()); map.put("resId", highOrder.getId()); List goldRecs = highGoldRecService.getGoldRec(map); // 判断是否重复赠送积分 if (goldRecs.size() == 0) { bsOrderRebateService.insertOrderRebate(highOrder); } highOrder.setWhetherRebate(true); highOrderService.updateOrderDetail(highOrder); } return ResponseMsgUtil.success("1231243"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() err1or!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getCouponList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询车牌订单列表信息") public ResponseData getCouponList(@RequestParam(name = "mchOrderNo", required = true) String mchOrderNo) { try { PetroConfig.init(2); JSONObject jsonObject = petroConfig.couponDetail(mchOrderNo); if (!jsonObject.getString("code").equals("1")) { throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "当前订单未查询到!"); } String data = PetroConfig.decrypt(jsonObject.getString("biz_content")); JSONObject jsonData = JSONObject.parseObject(data); return ResponseMsgUtil.success(jsonData); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/refundApi", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "支付退款") public ResponseData refundApi(@RequestParam(name = "mchOrderNo", required = true) String mchOrderNo) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20240133101"); mapPost.put("mchOrderNo" , mchOrderNo); // mapPost.put("timetable" , new Date().getTime()); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "1F43EEC88D0F99FC201D81143F9EED85", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("https://hsg.dctpay.com/v1/order/refund" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/decryptPetroConfig", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "解码") public ResponseData decryptPetroConfig(@RequestParam(name = "content", required = true) String content) { try { PetroConfig.init(1); String data = PetroConfig.decrypt(content); JSONObject object = JSONObject.parseObject(data); return ResponseMsgUtil.success(object); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/resolveResponseMembership", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "解码") public ResponseData resolveResponseMembership(@RequestParam(name = "content", required = true) String content) { try { JSONObject cardInfoObject = HuiLianTongUnionCardConfig.resolveResponse(content); return ResponseMsgUtil.success(cardInfoObject); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/synCouponRule", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "synCouponRule") public ResponseData synCouponRule(@RequestParam(name = "orderid", required = true) String orderid) { try { JSONObject object = new JSONObject(); object.put("orderid" , orderid); JSONObject jsonObject = RechargeConfig.checkOrderByHg(object); return ResponseMsgUtil.success(jsonObject); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } } \ No newline at end of file + package com.bweb.controller; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.utils.HttpsUtils; import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.WxUtils; import com.hai.config.*; import com.hai.dao.HighCouponCodeOtherMapper; import com.hai.entity.*; import com.hai.enum_type.GasOilPriceStatusEnum; import com.hai.model.HighMerchantModel; import com.hai.model.HighMerchantStoreModel; import com.hai.model.ResponseData; import com.hai.openApi.config.BlxConfig; import com.hai.openApi.service.ApiCouponService; import com.hai.order.service.OrderService; import com.hai.order.type.OrderProductType; import com.hai.order.type.OrderRefundOpUserType; import com.hai.order.utils.OrderUtil; import com.hai.pay.channel.huipay.config.HuiConfig; import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.bouncycastle.LICENSE; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.io.FileOutputStream; import java.io.InputStream; import java.math.BigDecimal; import java.net.URL; import java.net.URLConnection; import java.util.*; /** * @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 BsOrderRebateService bsOrderRebateService; @Resource private PetroConfig petroConfig; @Resource private HighGoldRecService highGoldRecService; @Resource private OrderService orderService; @Resource private HighUserCardService highUserCardService; @Resource private HighOrderService highOrderService; @Resource private HighUserService highUserService; @Resource private HighGasService gasService; @Resource private HighMerchantService highMerchantService; @Resource private HighMerchantStoreService highMerchantStoreService; @Resource private HighGasOilPriceService highGasOilPriceService; @Resource private HighCouponCodeOtherMapper highCouponCodeOtherMapper; @Resource private ApiCouponService apiCouponService; @Resource private HuiConfig huiConfig; @Resource private CommonService commonService; @Resource private HighOilCardOrderService highOilCardOrderService; @Resource private HighGasOrderService gasOrderService; @Resource private ShellGroupService shellGroupService; @Resource private HighMerchantStoreService merchantStoreService; @RequestMapping(value = "/gasSyncPayment", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "重庆壳牌推送") public ResponseData gasSyncPayment(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighGasOrder order = gasOrderService.getDetailByOrderNo(orderNo); if (order != null) { // 查询油站 HighMerchantStore store = merchantStoreService.getDetailById(order.getStoreId()); if (store == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到门店"); } return ResponseMsgUtil.success( // 推送加好油 shellGroupService.gasSyncPayment(order.getOrderNo(), store.getStoreKey(), order.getPayTime(), order.getGasRefuelPrice(), order.getGasOilNo(), order.getGasGunNo(), order.getPayPrice(), order.getTotalDeductionPrice() ) ); } return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("HighOrderController --> gasSyncPayment() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value="/resolveResponse",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "解析") public ResponseData resolveResponse( @RequestParam(name = "data", required = false) String data ) { try { JSONObject cardInfoObject = HuiLianTongUnionCardConfig.resolveResponse(data); return ResponseMsgUtil.success(cardInfoObject); } catch (Exception e) { log.error("getUserByTelephone",e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getHuiLianTongCardConsume", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询汇联通工会卡消费记录") public ResponseData getHuiLianTongCardConsume(@RequestParam(name = "businessType", required = true) String businessType, @RequestParam(name = "cardNo", required = true) String cardNo, @RequestParam(name = "sdate", required = true) Long sdate, @RequestParam(name = "edate", required = true) Long edate, @RequestParam(name = "pageNum", required = true) Integer pageNum, @RequestParam(name = "pageSize", required = true) Integer pageSize, HttpServletRequest request) { try { JSONObject consumptionRecord = HuiLianTongUnionCardConfig.queryConsumptionRecordByBusiness(businessType, cardNo, sdate, edate, pageNum, pageSize); if (StringUtils.isBlank(consumptionRecord.getString("data"))) { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQUEST_ERROR, ""); } JSONArray array = HuiLianTongUnionCardConfig.resolveResponse(consumptionRecord.getString("data")).getJSONArray("records"); return ResponseMsgUtil.success(array); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardConsume() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/createOrder", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "创建订单") public ResponseData createOrder(@RequestBody JSONObject object) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("timetable" , new Date().getTime()); mapPost.put("orderNo" , OrderUtil.generateOrderNo()); mapPost.put("productType" , object.getString("productType")); mapPost.put("content" , object.getJSONObject("content").toString()); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("https://hsgcs.dctpay.com/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("https://hsgcs.dctpay.com/v1/order/orderPay" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryOrderDetail", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询订单详情") public ResponseData queryOrderDetail(@RequestParam(name = "mchOrderNo", required = true) String mchOrderNo) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("mchOrderNo" , mchOrderNo); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("mchOrderNo" , mchOrderNo); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/order/queryOrderDetail" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/deposit", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "工会卡充值") public ResponseData deposit(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); HighChildOrder highChildOrder = order.getHighChildOrderList().get(0); if (order.getOrderStatus() != 2) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单状态错误"); } // 汇联通充值 String goodsDesc = "汇联通充值"+order.getPayPrice()+"元"; String tranDesc = ""; String businessType = "ghk_deposit"; String orderNoAgain = OrderUtil.generateOrderNo(); order.setOrderStatus(Integer.valueOf(3)); order.setRemarks("工会卡再次充值订单号" + orderNoAgain); highOrderService.updateOrder(order); // 汇联通卡充值 JSONObject deposit = HuiLianTongUnionCardConfig.deposit(orderNoAgain, highChildOrder.getGoodsSpecName(), order.getPayPrice(), businessType, order.getPaySerialNo(), goodsDesc); return ResponseMsgUtil.success( HuiLianTongUnionCardConfig.resolveResponse(deposit.getString("data"))); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getHuiLianTongCardByCardNo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据卡号查询汇联通工会卡详情") public ResponseData getHuiLianTongCardByCardNo(@RequestParam(name = "cardNo", required = true) String cardNo) { try { // 查询工会卡 JSONObject cardInfo = HuiLianTongUnionCardConfig.queryBalance(cardNo); JSONObject resolveResponse = HuiLianTongUnionCardConfig.resolveResponse(cardInfo.getString("data")); return ResponseMsgUtil.success(resolveResponse); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardByCardNo() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/consumption", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "工会卡支付") public ResponseData consumption(@RequestParam(name = "payRealPrice", required = true) BigDecimal payRealPrice, @RequestParam(name = "cardNo", required = true) String cardNo) { try { String goodsDesc = ""; String tranDesc = ""; String instCode = "11101652"; String businessType = "hisen_consume"; // 工会卡支付 JSONObject consumption = HuiLianTongUnionCardConfig.consumption(OrderUtil.generateOrderNo(), cardNo, payRealPrice, businessType, instCode, goodsDesc, tranDesc); if (!consumption.getString("respCode").equals("0000")) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumption.getString("respMessage")); } // 响应参数 JSONObject consumptionResult = HuiLianTongUnionCardConfig.resolveResponse(consumption.getString("data")); if (consumptionResult.getBoolean("success") != true) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumptionResult.getString("message")); } return ResponseMsgUtil.success(consumptionResult); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardByCardNo() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/refundOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "工会卡退款") public ResponseData refundOrder(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); if (order.getOrderStatus() != 2) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单状态错误"); } orderService.refundOrder(order, OrderProductType.getDataByType(order.getProductType()).getName() + "退款",OrderRefundOpUserType.TYPE1, null, "系统自动退款"); if (order.getProductType().equals(4)) { HighUser user = highUserService.findByUserId(order.getMemId()); // 获取应退款积分 int integralNum = order.getTotalPrice().multiply(new BigDecimal(100)).intValue(); if ( integralNum> user.getGold()) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "积分数量不足"); } String remark = "订单" + order.getOrderNo() + "退还积分:" + integralNum; // 积分退款 highUserService.goldHandle(user.getId(), integralNum,2, 3, order.getId() , remark , order.getOrderNo()); } return ResponseMsgUtil.success("退款成功"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/externalOrderRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "对外订单退款") public ResponseData externalOrderRefund(@RequestParam(name = "paySerialNo", required = true) String paySerialNo, @RequestParam(name = "WxMchId", required = true) String WxMchId, @RequestParam(name = "payRealPrice", required = true) String payRealPrice) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "B94B5E62807FA56A7260AB581D8A1B48"); mapPost.put("merchId" , "20230394901"); mapPost.put("paySerialNo" , paySerialNo); mapPost.put("wxMchId" , WxMchId); mapPost.put("payRealPrice" , payRealPrice); mapPost.put("refundPrice" , payRealPrice); Map map = new HashMap<>(); map.put("apiKey" , "B94B5E62807FA56A7260AB581D8A1B48"); map.put("merchId" , "20230394901"); map.put("paySerialNo" , paySerialNo); map.put("wxMchId" , WxMchId); map.put("payRealPrice" , payRealPrice); map.put("refundPrice" , payRealPrice); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("https://hsg.dctpay.com/v1/order/externalOrderRefund" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getBlxCouponBalance", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询停车券") public ResponseData getBlxCouponBalance(@RequestParam(name = "phone", required = true) String phone) { try { highUserCardService.getBlxCouponBalance(phone); return ResponseMsgUtil.success("object"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryJsParking", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询捷顺停车场") public ResponseData queryJsParking(@RequestParam(name = "gps", required = true) String gps) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("gps" , gps); mapPost.put("range" , "1000"); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/queryJsParking" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getUserCouponPage", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询捷顺停车场") public ResponseData getUserCouponPage(@RequestParam(name = "phone", required = true) String phone) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("phone" , phone); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/getUserCouponPage" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryJsOrderList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询车牌订单列表信息") public ResponseData queryJsOrderList(@RequestParam(name = "carNo", required = true) String carNo, @RequestParam(name = "orderStatus", required = true) String orderStatus) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("orderStatus" , orderStatus); mapPost.put("carNo" , carNo); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/queryJsOrderList" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/sendCoupon", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "发放券") public ResponseData sendCoupon(@RequestParam(name = "couponCode", required = true) String couponCode, @RequestParam(name = "receiverCount", required = true) String receiverCount, @RequestParam(name = "receiverPhone", required = true) String receiverPhone) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/getCouponList" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/preorder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "发起支付") public ResponseData preorder() { try { JSONObject object = new JSONObject(); object.put("outTradeNo" , "HUI" + OrderUtil.generateOrderNo()); object.put("transType" , "JSAPI"); object.put("payMode" , "WECHAT"); object.put("totalAmount" , "0.01"); object.put("profitSharing" , 0); object.put("subject" , "测试"); object.put("userId" , "oUGn_4unIjp90MY-oEXluY4laDrQ"); return ResponseMsgUtil.success(huiConfig.preorder(object)); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryGasInfoListByPage", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询团油门店") public ResponseData queryGasInfoListByPage() { try { HighMerchantModel merchant = highMerchantService.getMerchantById(39L); if (merchant == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到商户"); } JSONObject jsonObjectP = TuanYouConfig.queryGasInfoListByPage(1, 1000); JSONObject resultObjectP = jsonObjectP.getObject("result", JSONObject.class); for (int i = 1; i <= resultObjectP.getInteger("totalPageNum").intValue();i++) { JSONObject jsonObject = TuanYouConfig.queryGasInfoListByPage(i, 1000); JSONObject resultObject = jsonObject.getObject("result", JSONObject.class); JSONArray jsonArray = resultObject.getJSONArray("gasInfoList"); HighMerchantStore highMerchantStore; HighGasOilPrice highGasOilPrice; for (Object gasObject : jsonArray) { JSONObject object = JSONObject.parseObject(JSONObject.toJSONString(gasObject)); HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreByKey(object.getString("gasId")); if (store != null) { store.setType(1); store.setSourceType(2); store.setMerchantId(merchant.getId()); store.setCompanyId(merchant.getCompanyId()); store.setStoreKey(object.getString("gasId")); store.setStoreName(object.getString("gasName")); store.setStoreLogo(object.getString("gasLogoSmall")); store.setRegionId(object.getLong("provinceCode")); store.setRegionName(object.getString("provinceName")); store.setAddress(object.getString("gasAddress")); store.setLongitude(object.getString("gasAddressLongitude")); store.setLatitude(object.getString("gasAddressLatitude")); store.setStatus(object.getInteger("gasStatus")); store.setPrestoreType(0); store.setOperatorId(0L); store.setOperatorName("系统创建"); store.setUpdateTime(new Date()); store.setExt1(object.getString("gasSourceId")); highMerchantStoreService.updateMerchantStoreDetail(store); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); // 查询门店油号 highGasOilPrice = highGasOilPriceService.getGasOilPriceByStoreAndOilNo(store.getId(), oilPriceObject.getString("oilNo")); if (highGasOilPrice == null) { highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getString("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); highGasOilPrice.setStatus(GasOilPriceStatusEnum.status1.getStatus()); } else { highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getString("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); } highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } else { highMerchantStore = new HighMerchantStore(); highMerchantStore.setType(1); highMerchantStore.setSourceType(2); highMerchantStore.setMerchantId(merchant.getId()); highMerchantStore.setCompanyId(merchant.getCompanyId()); highMerchantStore.setStoreKey(object.getString("gasId")); highMerchantStore.setStoreName(object.getString("gasName")); highMerchantStore.setStoreLogo(object.getString("gasLogoSmall")); highMerchantStore.setRegionId(object.getLong("provinceCode")); highMerchantStore.setRegionName(object.getString("provinceName")); highMerchantStore.setAddress(object.getString("gasAddress")); highMerchantStore.setLongitude(object.getString("gasAddressLongitude")); highMerchantStore.setLatitude(object.getString("gasAddressLatitude")); highMerchantStore.setStatus(1); highMerchantStore.setPrestoreType(0); highMerchantStore.setOperatorId(0L); highMerchantStore.setOperatorName("系统创建"); highMerchantStore.setCreateTime(new Date()); highMerchantStore.setUpdateTime(new Date()); highMerchantStore.setExt1(object.getString("gasSourceId")); HighMerchantStoreModel merchantStoreModel = new HighMerchantStoreModel(); BeanUtils.copyProperties(highMerchantStore, merchantStoreModel); highMerchantStoreService.insertMerchantStore(merchantStoreModel); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(merchantStoreModel.getId()); highGasOilPrice.setOilNo(oilPriceObject.getString("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } } } return ResponseMsgUtil.success("完成"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/test", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "测试") public ResponseData test(@RequestParam(name = "no", required = true) String no) { try { JSONObject jsonObject = DianConfig.getGasInfoByGasId(no); return ResponseMsgUtil.success(jsonObject); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getGasInfoAll", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取全量油站") public ResponseData getGasInfoAll() { try { HighMerchantModel merchant = highMerchantService.getMerchantById(39L); JSONObject jsonObject = DianConfig.getGasInfoAll(); JSONArray resultObject = jsonObject.getObject("result", JSONArray.class); for (int i = 0; i < resultObject.size();i++) { Object objectData = resultObject.get(i); JSONObject object = JSONObject.parseObject(JSONObject.toJSONString(objectData)); HighMerchantStore highMerchantStore; HighGasOilPrice highGasOilPrice; HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreByKey(object.getString("jyzid")); SecRegion region = commonService.getRegionsByName(object.getString("province")); if (store != null) { store.setType(1); store.setSourceType(6); store.setMerchantId(merchant.getId()); store.setCompanyId(merchant.getCompanyId()); store.setStoreKey(object.getString("jyzid")); store.setStoreName(object.getString("mingcheng")); store.setStoreLogo(object.getString("tupian")); store.setRegionId(region.getRegionId()); store.setRegionName(object.getString("province")); store.setAddress(object.getString("dizhi")); store.setLongitude(object.getString("lng")); store.setLatitude(object.getString("lat")); store.setStatus(object.getInteger("zhuangtai")); store.setPrestoreType(0); store.setOperatorId(0L); store.setOperatorName("系统创建"); store.setUpdateTime(new Date()); store.setExt1(object.getString("gasSourceId")); highMerchantStoreService.updateMerchantStoreDetail(store); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); // 查询门店油号 highGasOilPrice = highGasOilPriceService.getGasOilPriceByStoreAndOilNo(store.getId(), oilPriceObject.getString("youhao")); if (highGasOilPrice == null) { highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getString("youhao")); highGasOilPrice.setOilNoName(oilPriceObject.getString("youhao") + "#"); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oiltype")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oiltype").equals("1") ? "汽油": "柴油"); highGasOilPrice.setStatus(GasOilPriceStatusEnum.status1.getStatus()); } else { highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getString("youhao")); highGasOilPrice.setOilNoName( oilPriceObject.getString("youhao") + "#"); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oiltype")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oiltype").equals("1") ? "汽油": "柴油"); } highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } else { highMerchantStore = new HighMerchantStore(); highMerchantStore.setType(1); highMerchantStore.setSourceType(6); highMerchantStore.setMerchantId(merchant.getId()); highMerchantStore.setCompanyId(merchant.getCompanyId()); highMerchantStore.setStoreKey(object.getString("jyzid")); highMerchantStore.setStoreName(object.getString("mingcheng")); highMerchantStore.setStoreLogo(object.getString("tupian")); highMerchantStore.setRegionId(region.getRegionId()); highMerchantStore.setRegionName(object.getString("province")); highMerchantStore.setAddress(object.getString("dizhi")); highMerchantStore.setLongitude(object.getString("lng")); highMerchantStore.setLatitude(object.getString("lat")); highMerchantStore.setStatus(1); highMerchantStore.setPrestoreType(0); highMerchantStore.setOperatorId(0L); highMerchantStore.setOperatorName("系统创建"); highMerchantStore.setCreateTime(new Date()); highMerchantStore.setUpdateTime(new Date()); highMerchantStore.setExt1(object.getString("gasSourceId")); HighMerchantStoreModel merchantStoreModel = new HighMerchantStoreModel(); BeanUtils.copyProperties(highMerchantStore, merchantStoreModel); highMerchantStoreService.insertMerchantStore(merchantStoreModel); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(merchantStoreModel.getId()); highGasOilPrice.setOilNo(oilPriceObject.getString("youhao")); highGasOilPrice.setOilNoName(oilPriceObject.getString("youhao") + "#"); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oiltype")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oiltype").equals("1") ? "汽油": "柴油"); highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } } return ResponseMsgUtil.success(jsonObject); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getOrderPay", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "getOrderPay") public ResponseData getOrderPay(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOilCardOrder highOilCardOrder = highOilCardOrderService.findOrder(orderNo); highOilCardOrder.setStatus(2); JSONObject object = KytcService.getOrderPay(highOilCardOrder.getThirdOrderNo() , highOilCardOrder.getPrice() , highOilCardOrder.getCardNo()); highOilCardOrder.setExt1(object.toJSONString()); highOilCardOrderService.updateOilCardOrder(highOilCardOrder); return ResponseMsgUtil.success("成功"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getOrderInfo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "getOrderInfo") public ResponseData getOrderInfo(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOilCardOrder highOilCardOrder = highOilCardOrderService.findOrder(orderNo); JSONObject object = KytcService.getOrderInfo(highOilCardOrder.getThirdOrderNo()); highOilCardOrder.setExt2(object.toJSONString()); if (object.getBoolean("State") == true) { JSONObject jsonObject = object.getJSONObject("Data"); if (jsonObject.getInteger("OilOrderState") == 2) { highOilCardOrder.setStatus(3); HighOrder highOrder = highOrderService.getOrderByOrderNo(highOilCardOrder.getOrderNo()); highOrder.setOrderStatus(3); highOrder.getHighChildOrderList().get(0).setChildOrderStatus(3); highOrderService.updateOrder(highOrder); } } highOilCardOrderService.updateOilCardOrder(highOilCardOrder); return ResponseMsgUtil.success("成功"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getLogisticsMsg", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取物流") public ResponseData getLogisticsMsg(@RequestParam(name = "no", required = true) String no) { try { JSONObject jsonObjects = CommonConfig.getLogisticsMsg(no); return ResponseMsgUtil.success(jsonObjects); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } // @RequestMapping(value = "/synCouponRule", method = RequestMethod.GET) // @ResponseBody // @ApiOperation(value = "获取卡券") // public ResponseData synCouponRule() { // try { // return ResponseMsgUtil.success(PetroConfig.synCouponRule()); // } catch (Exception e) { // log.error("HighOrderController --> getBackendToken() error!", e); // return ResponseMsgUtil.exception(e); // } // } // @RequestMapping(value = "/getCoupon", method = RequestMethod.GET) // @ResponseBody // @ApiOperation(value = "卡券下单") // public ResponseData getCoupon() { // try { // // JSONObject jsonObject = PetroConfig.getCoupon("16000443991501" , "18090580471" , OrderUtil.generateOrderNo()); // String data = PetroConfig.decrypt(jsonObject.getString("biz_content")); // JSONObject object = JSONObject.parseObject(data); // // return ResponseMsgUtil.success(object); // } catch (Exception e) { // log.error("HighOrderController --> getBackendToken() error!", e); // return ResponseMsgUtil.exception(e); // } // } @RequestMapping(value = "/deleteOilNo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "删除油品") public ResponseData deleteOilNo() { try { gasService.deleteOilNo(); return ResponseMsgUtil.success("1231243"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getJiaHaoYouAllStation", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "加好油油站刷新") public ResponseData getJiaHaoYouAllStation() { try { gasService.getJiaHaoYouAllStation(); return ResponseMsgUtil.success("1231243"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getDianAllStation", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "点点网络") public ResponseData getDianAllStation() { try { gasService.getDianAllStation(); return ResponseMsgUtil.success("1231243"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() err1or!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/integralRebateOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "积分返利") public ResponseData integralRebateOrder() { try { // 查询满足初步返利条件订单 List order = highOrderService.integralRebateOrder(); for (HighOrder highOrder : order) { // 查询是否存在积分记录 Map map = new HashMap<>(); map.put("goldType", 1); map.put("resType", 4); map.put("userId", highOrder.getMemId()); map.put("resId", highOrder.getId()); List goldRecs = highGoldRecService.getGoldRec(map); // 判断是否重复赠送积分 if (goldRecs.size() == 0) { bsOrderRebateService.insertOrderRebate(highOrder); } highOrder.setWhetherRebate(true); highOrderService.updateOrderDetail(highOrder); } return ResponseMsgUtil.success("1231243"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() err1or!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getApiCoupon", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取卡券") public ResponseData getApiCoupon() { try { // 查询满足初步返利条件订单 List order = highOrderService.integralRebateOrder(); for (HighOrder highOrder : order) { // 查询是否存在积分记录 Map map = new HashMap<>(); map.put("goldType", 1); map.put("resType", 4); map.put("userId", highOrder.getMemId()); map.put("resId", highOrder.getId()); List goldRecs = highGoldRecService.getGoldRec(map); // 判断是否重复赠送积分 if (goldRecs.size() == 0) { bsOrderRebateService.insertOrderRebate(highOrder); } highOrder.setWhetherRebate(true); highOrderService.updateOrderDetail(highOrder); } return ResponseMsgUtil.success("1231243"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() err1or!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/couponDetail", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据订单号查询中石油卡券详情") public ResponseData couponDetail(@RequestParam(name = "mchOrderNo", required = true) String mchOrderNo) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("mchOrderNo" , mchOrderNo); mapPost.put("timetable" , new Date().getTime()); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/apiCoupon/getCheckCode" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/refundApi", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "支付退款") public ResponseData refundApi(@RequestParam(name = "mchOrderNo", required = true) String mchOrderNo) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20240133101"); mapPost.put("mchOrderNo" , mchOrderNo); // mapPost.put("timetable" , new Date().getTime()); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "1F43EEC88D0F99FC201D81143F9EED85", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("https://hsg.dctpay.com/v1/order/refund" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/checkAccountBalance", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询余额") public ResponseData checkAccountBalance() { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20240133101"); // mapPost.put("mchOrderNo" , mchOrderNo); mapPost.put("timetable" , new Date().getTime()); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "1F43EEC88D0F99FC201D81143F9EED85", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("https://hsg.dctpay.com/v1/apiMerchants/checkAccountBalance" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getStationStore", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询油站") public ResponseData getStationStore() { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20240133101"); // mapPost.put("mchOrderNo" , mchOrderNo); // mapPost.put("timetable" , new Date().getTime()); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "1F43EEC88D0F99FC201D81143F9EED85", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("https://hsg.dctpay.com/v1/refuelOnline/getStationStore" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/decryptPetroConfig", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "解码") public ResponseData decryptPetroConfig(@RequestParam(name = "content", required = true) String content) { try { PetroConfig.init(1); String data = PetroConfig.decrypt(content); JSONObject object = JSONObject.parseObject(data); return ResponseMsgUtil.success(object); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/synCouponRule", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "synCouponRule") public ResponseData synCouponRule() { try { PetroConfig.init(2); JSONObject jsonObject = petroConfig.synCouponRule(); String data = PetroConfig.decrypt(jsonObject.getString("jsonResult")); JSONArray jsonArray = JSONArray.parseArray(data); return ResponseMsgUtil.success(jsonArray); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getCoupon", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "getCoupon") public ResponseData getCoupon(@RequestParam(name = "code", required = true) String code) { try { PetroConfig.init(2); // 发放卡券 JSONObject jsonObject = petroConfig.getCoupon(code ,"18090580471"); String data = PetroConfig.decrypt(jsonObject.getString("jsonResult")); JSONObject object = JSONObject.parseObject(data); return ResponseMsgUtil.success(object); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/decrypt", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "decrypt") public ResponseData decrypt(@RequestParam(name = "jsonResult", required = true) String jsonResult) { try { PetroConfig.init(2); String data = PetroConfig.decrypt(jsonResult); JSONObject object = JSONObject.parseObject(data); return ResponseMsgUtil.success(object); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/jNiuGoodsList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "jNiuGoodsList") public ResponseData jNiuGoodsList() { try { JSONObject object = RechargeConfig.jNiuGoodsList(); JSONArray array = object.getJSONArray("data"); List list = new ArrayList<>(); for (int i = 0; i < array.size(); i++) { JSONObject jsonObject = array.getJSONObject(i); JSONArray jsonArray = jsonObject.getJSONArray("goodsOption"); for (int j = 0; j < jsonArray.size(); j++) { JSONObject goodsOption = jsonArray.getJSONObject(j); JSONArray childArray = goodsOption.getJSONArray("child"); for (int t = 0; t < childArray.size(); t++) { JSONObject child = childArray.getJSONObject(j); JSONObject data = new JSONObject(); data.put("title" , jsonObject.getString("sort_title") + goodsOption.getString("name")); data.put("goodsId" , child.getString("goods_id")); data.put("goodsOptionId" , child.getString("goods_option_id")); data.put("platPrice" , child.getString("plat_price")); data.put("officialPrice" , child.getString("official_price")); list.add(data); } } } return ResponseMsgUtil.success(list); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } } \ No newline at end of file diff --git a/hai-bweb/src/main/java/com/bweb/controller/OutRechargePriceController.java b/hai-bweb/src/main/java/com/bweb/controller/OutRechargePriceController.java index d6f1fd66..8d280862 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/OutRechargePriceController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/OutRechargePriceController.java @@ -260,21 +260,21 @@ public class OutRechargePriceController { map.put("sourceId" , outRechargePrice.getId()); List rechargeCodes = bsRechargeCodeService.getListRechargeCode(map); - if ((outRechargePrice.getRechargePlatform().contains("-2-") || outRechargePrice.getRechargePlatform().contains("-3-") || outRechargePrice.getRechargePlatform().contains("-4-") ) && rechargeCodes.size() == 0) { + if ((outRechargePrice.getRechargePlatform().contains("-2-") || outRechargePrice.getRechargePlatform().contains("-3-") || outRechargePrice.getRechargePlatform().contains("-4-") || outRechargePrice.getRechargePlatform().contains("-5-") ) && rechargeCodes.size() == 0) { log.error("OutRechargePriceController -> editPriceStatus() error!"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "龙阅,城宇,畅停平台需要输入商品编码!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "龙阅,城宇,畅停,简牛平台需要输入商品编码!"); } for (BsRechargeCode rechargeCode : rechargeCodes) { - if ((rechargeCode.getRechargePlatform() == 2 || rechargeCode.getRechargePlatform() == 3 || rechargeCode.getRechargePlatform() == 4) ){ + if ((rechargeCode.getRechargePlatform() == 2 || rechargeCode.getRechargePlatform() == 3 || rechargeCode.getRechargePlatform() == 4 || rechargeCode.getRechargePlatform() == 5) ){ if (rechargeCode.getGoodsId() == null) { log.error("OutRechargePriceController -> editPriceStatus() error!"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "龙阅,城宇,畅停平台需要输入商品编码!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "龙阅,城宇,畅停,简牛平台需要输入商品编码!"); } if (rechargeCode.getGoodsId().length() == 0) { log.error("OutRechargePriceController -> editPriceStatus() error!"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "龙阅,城宇,畅停平台需要输入商品编码!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "龙阅,城宇,畅停,简牛平台需要输入商品编码!"); } } diff --git a/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java b/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java index 9f2a80a1..9df59cb2 100644 --- a/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java +++ b/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java @@ -148,6 +148,7 @@ public class AuthConfig implements WebMvcConfigurer { .excludePathPatterns("/userDiscount/*") .excludePathPatterns("/highThirdParty/*") .excludePathPatterns("/group/*") + .excludePathPatterns("/couponCodeOther/*") ; } diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighCouponCodeOtherController.java b/hai-cweb/src/main/java/com/cweb/controller/HighCouponCodeOtherController.java index a7111937..de826e05 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighCouponCodeOtherController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighCouponCodeOtherController.java @@ -1,9 +1,16 @@ package com.cweb.controller; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.hai.common.exception.ErrorCode; +import com.hai.common.exception.ErrorHelp; +import com.hai.common.exception.SysCode; import com.hai.common.security.SessionObject; import com.hai.common.security.UserCenter; import com.hai.common.utils.ResponseMsgUtil; +import com.hai.config.PetroConfig; import com.hai.entity.HighCouponCodeOther; +import com.hai.entity.HighOrder; import com.hai.entity.HighUser; import com.hai.model.HighUserModel; import com.hai.model.ResponseData; @@ -22,6 +29,7 @@ import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.util.HashMap; +import java.util.List; import java.util.Map; @Controller @@ -34,6 +42,12 @@ public class HighCouponCodeOtherController { @Resource private HighCouponCodeOtherService highCouponCodeOtherService; + @Resource + private HighOrderService highOrderService; + + @Resource + private PetroConfig petroConfig; + @RequestMapping(value = "/getList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询卡券码列表") @@ -54,4 +68,80 @@ public class HighCouponCodeOtherController { return ResponseMsgUtil.exception(e); } } + + @RequestMapping(value = "/unusedCoupons", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "获取核销码") + public ResponseData unusedCoupons(@RequestParam(name = "orderId", required = false) Long orderId) { + try { + + Map map = new HashMap<>(); + map.put("orderId", orderId); + + List highCouponCodeOtherServiceList = highCouponCodeOtherService.getList(map); + + if (highCouponCodeOtherServiceList.isEmpty()) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到核销码!"); + } + + HighCouponCodeOther couponCodeOther = highCouponCodeOtherServiceList.get(0); + + HighOrder highOrder = highOrderService.getOrderById(orderId); + PetroConfig.init(2); + JSONObject jsonObject = petroConfig.getCheckCode(couponCodeOther.getCouNo() , highOrder.getMemPhone()); + String data = PetroConfig.decrypt(jsonObject.getString("jsonResult")); + JSONObject object = JSONObject.parseObject(data); + return ResponseMsgUtil.success(object); + + } catch (Exception e) { + log.error("HighCouponCodeOtherController --> getList() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/cancelCouponsYt", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "撤销电子券") + public ResponseData cancelCouponsYt(@RequestParam(name = "orderId", required = false) Long orderId) { + try { + + Map map = new HashMap<>(); + map.put("orderId", orderId); + + List highCouponCodeOtherServiceList = highCouponCodeOtherService.getList(map); + + HighCouponCodeOther couponCodeOther = highCouponCodeOtherServiceList.get(0); + + HighOrder highOrder = highOrderService.getOrderById(orderId); + PetroConfig.init(2); + JSONObject jsonObject = petroConfig.cancelCouponsYt(couponCodeOther.getCouNo() , highOrder.getMemPhone()); + String data = PetroConfig.decrypt(jsonObject.getString("jsonResult")); + return ResponseMsgUtil.success(data); + + } catch (Exception e) { + log.error("HighCouponCodeOtherController --> getList() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + + @RequestMapping(value = "/cancelCouponsYtApi", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "撤销电子券") + public ResponseData cancelCouponsYtApi(@RequestParam(name = "orderId", required = false) Long orderId) { + try { + + HighOrder highOrder = highOrderService.getOrderById(orderId); + PetroConfig.init(2); + JSONObject jsonObject = petroConfig.cancelCouponsYt(highOrder.getHighChildOrderList().get(0).getExt6() , highOrder.getMemPhone()); + String data = PetroConfig.decrypt(jsonObject.getString("jsonResult")); + return ResponseMsgUtil.success(data); + + } catch (Exception e) { + log.error("HighCouponCodeOtherController --> getList() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + } diff --git a/hai-order/src/main/java/com/web/config/AuthConfig.java b/hai-order/src/main/java/com/web/config/AuthConfig.java index b500ae65..406c2006 100644 --- a/hai-order/src/main/java/com/web/config/AuthConfig.java +++ b/hai-order/src/main/java/com/web/config/AuthConfig.java @@ -99,6 +99,7 @@ public class AuthConfig implements WebMvcConfigurer { .excludePathPatterns("/telChargeCallback/*") .excludePathPatterns("/huiPayNotify/*") .excludePathPatterns("/groupOrder/*") + .excludePathPatterns("/petroNotify/*") ; } diff --git a/hai-order/src/main/java/com/web/controller/OrderPayController.java b/hai-order/src/main/java/com/web/controller/OrderPayController.java index d80d346a..d6d171ee 100644 --- a/hai-order/src/main/java/com/web/controller/OrderPayController.java +++ b/hai-order/src/main/java/com/web/controller/OrderPayController.java @@ -743,4 +743,29 @@ public class OrderPayController { return ResponseMsgUtil.success(""); } + @RequestMapping(value = "counterPay" , method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "聚合收银台") + public ResponseData counterPay(@RequestBody JSONObject body, HttpServletRequest request) { + + if (body == null + || StringUtils.isBlank(body.getString("combineOrderNo")) + || StringUtils.isBlank(body.getString("openId")) + ) { + log.error("wechatCombinePay error!", "参数错误"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + Map map = new HashMap<>(); + map.put("combineOrderNo" , body.getString("combineOrderNo")); + + List orders = orderService.getOrderList(map); + + CombineOrderModel combineOrderModel = new CombineOrderModel(); + + return ResponseMsgUtil.success(""); + } + + + } diff --git a/hai-order/src/main/java/com/web/controller/notify/PetroNotifyController.java b/hai-order/src/main/java/com/web/controller/notify/PetroNotifyController.java new file mode 100644 index 00000000..929f154f --- /dev/null +++ b/hai-order/src/main/java/com/web/controller/notify/PetroNotifyController.java @@ -0,0 +1,58 @@ +package com.web.controller.notify; + +import com.alibaba.fastjson.JSONObject; +import com.hai.config.PetroConfig; +import com.hai.service.impl.OutRechargeOrderServiceImpl; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.PrintWriter; + +@Controller +@RequestMapping(value = "/petroNotify") +@Api(value = "中石油业务通知") +public class PetroNotifyController { + + private static Logger log = LoggerFactory.getLogger(PetroConfig.class); + + + + @RequestMapping(value = "/petroCallback", method = RequestMethod.POST) + @ApiOperation(value = "中石油回调") + @ResponseBody + public void rechargeCallbackByJj(@RequestBody JSONObject jsonObject, HttpServletResponse response) { + try { + + + log.info("============回调任务Start============="); + log.info("尖椒订单充值-回调参数: " + jsonObject); + log.info("============回调任务End============="); + + + response.setCharacterEncoding("UTF-8"); + response.setContentType("text/html;charset=utf-8"); + PrintWriter writer= response.getWriter(); + + JSONObject postJson = new JSONObject(); + postJson.put("resultCode" ,"0000"); + postJson.put("errMsg" ,""); + writer.write(postJson.toJSONString()); + writer.flush(); + writer.close(); + + + } catch (Exception e) { + log.error("WechatPayController --> wechatNotify() error!", e); + } + } + +} diff --git a/hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java b/hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java index d7cb08b9..4a397172 100644 --- a/hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java +++ b/hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java @@ -7,10 +7,13 @@ import com.hai.common.exception.SysCode; import com.hai.common.utils.ResponseMsgUtil; import com.hai.config.HuiLianTongConfig; import com.hai.config.HuiLianTongUnionCardConfig; +import com.hai.config.PetroConfig; import com.hai.dao.HighCouponAgentCodeMapper; import com.hai.dao.HighCouponCodeOtherMapper; import com.hai.dao.HighUserCouponMapper; import com.hai.entity.*; +import com.hai.openApi.service.ApiCouponService; +import com.hai.service.HighCouponService; import com.hai.service.HighOrderService; import com.hai.service.HighUserCouponService; import org.slf4j.Logger; @@ -48,7 +51,10 @@ public class HighCouponSchedule { private HighOrderService highOrderService; @Resource - private HuiLianTongConfig huiLianTongConfig; + private ApiCouponService apiCouponService; + + @Resource + private PetroConfig petroConfig; /** * @Author 胡锐 @@ -125,4 +131,45 @@ public class HighCouponSchedule { } } + + @Scheduled(cron="0 0/15 * * * ?") //每30分钟执行一次 + public void handlePetroCouponStatus() throws Exception { + HighCouponCodeOtherExample example = new HighCouponCodeOtherExample(); + example.createCriteria().andStatusEqualTo(20).andTypeEqualTo(6); + List otherList = highCouponCodeOtherMapper.selectByExample(example); + + for (HighCouponCodeOther couponCodeOther : otherList) { + HighOrder highOrder = highOrderService.getOrderById(couponCodeOther.getOrderId()); + ApiCoupon apiCoupon = apiCouponService.findCoupon(couponCodeOther.getCouTypeCode()); + + PetroConfig.init(apiCoupon.getType()); + JSONObject jsonObject = petroConfig.couponDetail(couponCodeOther.getCouNo() , highOrder.getMemPhone()); + + if (!jsonObject.getString("resultCode").equals("0000")) { + throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "当前订单未查询到!"); + } + + String data = PetroConfig.decrypt(jsonObject.getString("jsonResult")); + + JSONObject jsonData = JSONObject.parseObject(data); + + if (jsonData.getInteger("state") == 40) { + couponCodeOther.setStatus(jsonData.getInteger("state")); + couponCodeOther.setStationCode(jsonData.getString("station")); + couponCodeOther.setStationName(jsonData.getString("stationName")); + couponCodeOther.setUseTime(jsonData.getDate("usedTime")); + + highOrder.setOrderStatus(3); + highOrder.setFinishTime(new Date()); + highOrder.getHighChildOrderList().get(0).setChildOrderStatus(3); + highOrder.getHighChildOrderList().get(0).setFinishTime(new Date()); + + highOrderService.updateOrder(highOrder); + + } + + } + + } + } diff --git a/hai-service/src/main/java/com/hai/common/utils/PetroEncryptUtil.java b/hai-service/src/main/java/com/hai/common/utils/PetroEncryptUtil.java new file mode 100644 index 00000000..fc44f57a --- /dev/null +++ b/hai-service/src/main/java/com/hai/common/utils/PetroEncryptUtil.java @@ -0,0 +1,189 @@ +package com.hai.common.utils; + +import java.io.ByteArrayOutputStream; +import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; +import java.security.MessageDigest; +import java.util.Map; +import java.util.TreeMap; + +public class PetroEncryptUtil { + + + /** + * 生成签名 + * + * @param signMaps + * @return + * @throws Exception + */ + public static String generateSign(Map signMaps) { + StringBuilder sb = new StringBuilder(); + TreeMap sortedMap = new TreeMap<>(signMaps); + // 字典序 + for (Map.Entry entry : sortedMap.entrySet()) { + String key = entry.getKey(); + String value = (String) entry.getValue(); + + // 为空不参与签名、参数名区分大小写 + if (!"sign".equals(key)) { + sb.append(key).append("=").append(value).append("&"); + } + + } + sb = new StringBuilder(sb.substring(0, sb.length() - 1)); + // MD5加密 + return md532(sb.toString()); + } + + /*** + * MD5加码 生成32位md5码 + */ + public static String md532(String inStr) { + MessageDigest md5; + try { + md5 = MessageDigest.getInstance("MD5"); + + } catch (Exception e) { + System.out.println(e); + e.printStackTrace(); + return ""; + } + char[] charArray = inStr.toCharArray(); + byte[] byteArray = new byte[charArray.length]; + + for (int i = 0; i < charArray.length; i++) + byteArray[i] = (byte) charArray[i]; + byte[] md5Bytes = md5.digest(byteArray); + StringBuilder hexValue = new StringBuilder(); + for (byte md5Byte : md5Bytes) { + int val = ((int) md5Byte) & 0xff; + if (val < 16) + hexValue.append("0"); + hexValue.append(Integer.toHexString(val)); + } + return hexValue.toString(); + } + + + /** + * 加密解密算法 + * + * @param inStr 加密字符串 + * @param secretKey 秘钥 + * 算法: + * 1:加密字符串和秘钥转换成字符数组; + * 2:秘钥去重复 + * 3:循环一(秘钥字符串数组){ 循环二(加密字符串数组){ + * 秘钥字符的ASC码 与 加密字符的ASC码 进行二进制异或运算 + * } + * } + * 4:把字符串转为16进制 + */ + private static String convert(String inStr, String secretKey) { + char[] a = inStr.toCharArray(); + char[] s = rmRepeated(secretKey).toCharArray(); + for (int i = 0; i < s.length; i++) { + for (int j = 0; j < a.length; j++) { + a[j] = (char) (a[j] ^ s[i]); + } + } + return new String(a); + } + + /** + * 清除字符串中重复字母算法 + * + * @param s + * @return + */ + private static String rmRepeated(String s) { + int len = s.length(); + int k = 0; + int count = 0; + String str = ""; + char[] c = new char[len]; + for (int i = 0; i < len; i++) { + c[i] = s.charAt(i); + } + for (int i = 0; i < len; i++) { + k = i + 1; + while (k < len - count) { + if (c[i] == c[k]) { + for (int j = k; j < len - 1; j++) { + c[j] = c[j + 1];// 出现重复字母,从k位置开始将数组往前挪位 + } + count++;// 重复字母出现的次数 + k--; + } + k++; + } + } + for (int i = 0; i < len - count; i++) { + str += String.valueOf(c[i]); + } + return str; + } + + /* + * 将字符串编码成16进制数字,适用于所有字符(包括中文) + */ + private static String hexString = "0123456789ABCDEF"; + + public static String encode(String str) { + // 根据默认编码获取字节数组 + String r; + byte[] bytes = str.getBytes(StandardCharsets.UTF_8); + StringBuilder sb = new StringBuilder(bytes.length * 2); + // 将字节数组中每个字节拆解成2位16进制整数 + for (byte aByte : bytes) { + sb.append(hexString.charAt((aByte & 0xf0) >> 4)); + sb.append(hexString.charAt((aByte & 0x0f))); + } + r = sb.toString(); + return r; + } + + /* + * 将16进制数字解码成字符串,适用于所有字符(包括中文) + */ + public static String decode(String bytes) { + String r = ""; + try { + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(bytes.length() / 2); + // 将每2位16进制整数组装成一个字节 + for (int i = 0; i < bytes.length(); i += 2) { + byteArrayOutputStream.write((hexString.indexOf(bytes.charAt(i)) << 4 | hexString.indexOf(bytes.charAt(i + 1)))); + } + r = byteArrayOutputStream.toString("UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + return r; + } + + /** + * 加密 + * + * @param inStr 原字符串 + * @param secretKey 秘钥 + * @return + */ + public static String encrypt(String inStr, String secretKey) { + String hexStr = convert(inStr, secretKey); + return encode(hexStr); + } + + /** + * 解密 + * + * @param inStr 原字符串 + * @param secretKey 秘钥 + * @return + */ + public static String decrypt(String inStr, String secretKey) { + String hexStr = decode(inStr); + return convert(hexStr, secretKey); + } + +} diff --git a/hai-service/src/main/java/com/hai/common/utils/WxUtils.java b/hai-service/src/main/java/com/hai/common/utils/WxUtils.java index cd1c160c..e940e9b7 100644 --- a/hai-service/src/main/java/com/hai/common/utils/WxUtils.java +++ b/hai-service/src/main/java/com/hai/common/utils/WxUtils.java @@ -21,6 +21,7 @@ import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import java.io.StringWriter; +import java.net.URLEncoder; import java.security.MessageDigest; import java.security.SecureRandom; import java.util.*; @@ -533,6 +534,35 @@ public class WxUtils { } } + public static String generateSignApi(final Map data, String key, WXPayConstants.SignType signType , Boolean isUpperCase) throws Exception { + Set keySet = data.keySet(); + String[] keyArray = keySet.toArray(new String[keySet.size()]); + Arrays.sort(keyArray); + StringBuilder sb = new StringBuilder(); + for (String k : keyArray) { + if (k.equals(WXPayConstants.FIELD_SIGN) || k.equals("app_secret")) { + continue; + } + if (k.equals("notify_url")) { + k = URLEncoder.encode(k, "UTF-8"); + } + if (data.get(k) != null) // 参数值为空,则不参与签名 + { + sb.append(k).append("=").append(data.get(k)).append("&"); + } + } + sb.append("app_secret=").append(key); + if (WXPayConstants.SignType.MD5.equals(signType)) { + return MD5(sb.toString() , isUpperCase); + } + else if (WXPayConstants.SignType.HMACSHA256.equals(signType)) { + return HMACSHA256(sb.toString(), key); + } + else { + throw new Exception(String.format("Invalid sign_type: %s", signType)); + } + } + /** * 用SHA1算法生成安全签名 * @param token 票据 diff --git a/hai-service/src/main/java/com/hai/config/CommonSysConfig.java b/hai-service/src/main/java/com/hai/config/CommonSysConfig.java index 049c747f..feab4bd2 100644 --- a/hai-service/src/main/java/com/hai/config/CommonSysConfig.java +++ b/hai-service/src/main/java/com/hai/config/CommonSysConfig.java @@ -116,6 +116,11 @@ public class CommonSysConfig { private String CyAppSecret; private String CyPostUrl; + private String JnApiKey; + private String JnNotifyUrl; + private String JnAppSecret; + private String JnPostUrl; + private String unionAppId; private String unionSecret; private String unionRsaKey; diff --git a/hai-service/src/main/java/com/hai/config/PetroConfig.java b/hai-service/src/main/java/com/hai/config/PetroConfig.java index 52285105..5abe4cb5 100644 --- a/hai-service/src/main/java/com/hai/config/PetroConfig.java +++ b/hai-service/src/main/java/com/hai/config/PetroConfig.java @@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.hai.common.utils.DateUtil; import com.hai.common.utils.HttpsUtils; +import com.hai.common.utils.PetroEncryptUtil; import com.hai.enum_type.TripartiteReqLogReqType; import com.hai.enum_type.TripartiteReqLogType; import com.hai.service.BsTripartiteReqLogService; @@ -67,38 +68,38 @@ public class PetroConfig { * @return com.alibaba.fastjson.JSONObject */ - public JSONObject synCouponRule() throws Exception{ + public JSONObject synCouponRule() { + log.info("========================请求任务Start========================="); Map req = new HashMap<>(); - req.put("version", version); - req.put("appid", petroAppid); - req.put("signtype", "MD5"); - req.put("timestamp", DateUtil.date2String(new Date(), DateUtil.Y_M_D_HMS)); + req.put("appId", petroAppid); + req.put("appKey", petroAppKey); + req.put("jsonData" , ""); + req.put("timestamp", new Date().getTime() + ""); + req.put("nonce" , generateRandomString(16)); - // 业务数据 - JSONObject billBizContent = new JSONObject(); - billBizContent.put("pageSize" , 100); - - //业务内容加密 - String bizContent = JSONObject.toJSONString(billBizContent); - bizContent = encrypt(bizContent, petroAesKey); - - //加密的内容放到参数中 - req.put("biz_content", bizContent); //生成签名 - String sign = createSign(req, petroAppKey); + String sign = PetroEncryptUtil.generateSign(req); + + Map postData = new HashMap<>(); + postData.put("sign" , sign); + postData.put("timestamp" , req.get("timestamp")); + postData.put("jsonData" , ""); + postData.put("nonce" , req.get("nonce")); + postData.put("appId", petroAppid); //签名放到参数中 - req.put("sign", sign); - JSONObject object = HttpsUtils.doPost(reqUrl + "syn-coupon-rule/v1", req , new HashMap<>()); + log.info("获取券列表-请求参数: " + JSON.toJSONString(req)); + JSONObject object = HttpsUtils.doPost(reqUrl + "/outapi/getCouTypesYt", postData); reqLogService.insert( TripartiteReqLogType.type18, req.get("timestamp").toString(), TripartiteReqLogReqType.type1, - reqUrl + "syn-coupon-rule/v1", + reqUrl + "/outapi/getCouTypesYt", req.toString(), object.toString() ); - + log.info("购买加油券充值订单-回调参数: " + JSON.toJSONString(object)); + log.info("========================请求任务End========================="); // 请求接口 return object; } @@ -114,39 +115,48 @@ public class PetroConfig { * @Param orderNo * @return com.alibaba.fastjson.JSONObject */ - public JSONObject getCoupon(String code , String phone , String orderNo) throws Exception{ - + public JSONObject getCoupon(String code , String phone) { + log.info("========================请求任务Start========================="); Map req = new HashMap<>(); - req.put("version", version); - req.put("appid", petroAppid); - req.put("signtype", "MD5"); - req.put("timestamp", DateUtil.date2String(new Date(), DateUtil.Y_M_D_HMS)); + req.put("appId", petroAppid); + req.put("appKey", petroAppKey); + req.put("timestamp", new Date().getTime() + ""); + req.put("nonce" , generateRandomString(16)); // 业务数据 - JSONObject billBizContent = new JSONObject(); - billBizContent.put("request_code" , code); - billBizContent.put("user_code" , phone); - billBizContent.put("out_trade_no" , orderNo); + JSONObject jsonData = new JSONObject(); + jsonData.put("alias" , code); + jsonData.put("businessId" , phone); //业务内容加密 - String bizContent = JSONObject.toJSONString(billBizContent); - bizContent = encrypt(bizContent, petroAesKey); + String bizContent = JSONObject.toJSONString(jsonData); + bizContent = encrypt(bizContent); //加密的内容放到参数中 - req.put("biz_content", bizContent); + req.put("jsonData", bizContent); //生成签名 - String sign = createSign(req, petroAppKey); - //签名放到参数中 - req.put("sign", sign); - JSONObject object = HttpsUtils.doPost(reqUrl + "get-coupon", req , new HashMap<>()); + String sign = PetroEncryptUtil.generateSign(req); + + + Map postData = new HashMap<>(); + postData.put("sign" , sign); + postData.put("timestamp" , req.get("timestamp")); + postData.put("jsonData" , bizContent); + postData.put("nonce" , req.get("nonce")); + postData.put("appId", petroAppid); + log.info("获取电子券-请求参数: " + JSON.toJSONString(req)); + JSONObject object = HttpsUtils.doPost(reqUrl + "/outapi/getCouponYt", postData); + reqLogService.insert( TripartiteReqLogType.type18, req.get("timestamp").toString(), TripartiteReqLogReqType.type1, - reqUrl + "get-coupon", + reqUrl + "/outapi/getCouponYt", req.toString(), object.toString() ); + log.info("获取电子券-回调参数: " + JSON.toJSONString(object)); + log.info("========================请求任务End========================="); // 请求接口 return object; } @@ -154,39 +164,46 @@ public class PetroConfig { /** * @Author Sum1Dream * @Name couponDetail - * @Description // 获取静态码 + * @Description // 查询电子券状态 * @Date 11:20 2023/11/17 * @Param ticketNum * @return com.alibaba.fastjson.JSONObject */ - public JSONObject couponDetail(String ticketNum) throws Exception{ + public JSONObject couponDetail(String ticketNum , String phone) throws Exception{ + log.info("========================请求任务Start========================="); Map req = new HashMap<>(); - req.put("version", version); - req.put("appid", petroAppid); - req.put("signtype", "MD5"); - req.put("timestamp", DateUtil.date2String(new Date(), DateUtil.Y_M_D_HMS)); + req.put("appId", petroAppid); + req.put("appKey", petroAppKey); + req.put("timestamp", new Date().getTime() + ""); + req.put("nonce" , generateRandomString(16)); // 业务数据 - JSONObject billBizContent = new JSONObject(); - billBizContent.put("ticket_num" , ticketNum); + JSONObject jsonData = new JSONObject(); + jsonData.put("voucher" , ticketNum); + jsonData.put("businessId" , phone); //业务内容加密 - String bizContent = JSONObject.toJSONString(billBizContent); - bizContent = encrypt(bizContent, petroAesKey); + String bizContent = JSONObject.toJSONString(jsonData); + bizContent = encrypt(bizContent); //加密的内容放到参数中 - req.put("biz_content", bizContent); + req.put("jsonData", bizContent); //生成签名 - String sign = createSign(req, petroAppKey); + String sign = PetroEncryptUtil.generateSign(req); //签名放到参数中 req.put("sign", sign); - log.info("============请求任务Start============="); - log.info("购买加油券充值订单-请求参数: " + JSON.toJSONString(req)); + Map postData = new HashMap<>(); + postData.put("sign" , sign); + postData.put("timestamp" , req.get("timestamp")); + postData.put("jsonData" , bizContent); + postData.put("nonce" , req.get("nonce")); + postData.put("appId", petroAppid); + log.info("查询电子券状态-请求参数: " + JSON.toJSONString(req)); // 请求接口 - JSONObject object = HttpsUtils.doPost(reqUrl + "couponDetail", req , new HashMap<>()); + JSONObject object = HttpsUtils.doPost(reqUrl + "/outapi/getStateYt", postData); - log.info("购买加油券充值订单-回调参数: " + JSON.toJSONString(object)); + log.info("查询电子券状态-回调参数: " + JSON.toJSONString(object)); reqLogService.insert( TripartiteReqLogType.type18, @@ -202,123 +219,154 @@ public class PetroConfig { /** * @Author Sum1Dream - * @Name cancelCoupon - * @Description // 作废下单 - * @Date 11:21 2023/11/17 + * @Name unusedCoupons + * @Description // 获取核销码 + * @Date 14:32 2024/1/31 * @Param ticketNum + * @Param phone * @return com.alibaba.fastjson.JSONObject */ - public static JSONObject cancelCoupon(String ticketNum) throws Exception{ + public JSONObject getCheckCode(String ticketNum , String phone) throws Exception{ + log.info("========================请求任务Start========================="); Map req = new HashMap<>(); - req.put("version", version); - req.put("appid", petroAppid); - req.put("signtype", "MD5"); - req.put("timestamp", DateUtil.date2String(new Date(), DateUtil.Y_M_D_HMS)); + req.put("appId", petroAppid); + req.put("appKey", petroAppKey); + req.put("timestamp", new Date().getTime() + ""); + req.put("nonce" , generateRandomString(16)); // 业务数据 - JSONObject billBizContent = new JSONObject(); - billBizContent.put("ticket_num" , ticketNum); + JSONObject jsonData = new JSONObject(); + jsonData.put("voucher" , ticketNum); + jsonData.put("businessId" , phone); //业务内容加密 - String bizContent = JSONObject.toJSONString(billBizContent); - bizContent = encrypt(bizContent, petroAesKey); + String bizContent = JSONObject.toJSONString(jsonData); + bizContent = encrypt(bizContent); //加密的内容放到参数中 - req.put("biz_content", bizContent); + req.put("jsonData", bizContent); //生成签名 - String sign = createSign(req, petroAppKey); + String sign = PetroEncryptUtil.generateSign(req); //签名放到参数中 req.put("sign", sign); + Map postData = new HashMap<>(); + postData.put("sign" , sign); + postData.put("timestamp" , req.get("timestamp")); + postData.put("jsonData" , bizContent); + postData.put("nonce" , req.get("nonce")); + postData.put("appId", petroAppid); + log.info("查询电子券状态-请求参数: " + JSON.toJSONString(req)); // 请求接口 - return HttpsUtils.doPost(reqUrl + "cancelCoupon", req , new HashMap<>()); + JSONObject object = HttpsUtils.doPost(reqUrl + "/outapi/getCheckCode", postData); + + log.info("查询电子券状态-回调参数: " + JSON.toJSONString(object)); + + reqLogService.insert( + TripartiteReqLogType.type18, + req.get("timestamp").toString(), + TripartiteReqLogReqType.type1, + reqUrl + "get-coupon", + req.toString(), + object.toString() + ); + + return object; } /** - * @param params 签名params null和""不参与签名 - * @param key 密钥 - * @return 签名code - */ - public static String createSign(Map params, String key) { - if (StringUtils.isEmpty(key)) { - return null; - } - if (params == null || params.keySet() == null || params.keySet().isEmpty()) { - return null; - } - Object[] parKeys = params.keySet().toArray(); - Arrays.sort(parKeys); - StringBuffer temp = new StringBuffer(); - boolean first = true; - for (Object parKey : parKeys) { - String parKeyStr = null; - if(parKey != null){ - parKeyStr = parKey.toString(); - } - if ("sign".equals(parKeyStr)) { - continue; - } - if (first) { - first = false; - } else { - temp.append("&"); - } - Object value = params.get(parKey); - if (value != null) { - String v = value.toString(); - if (!"".equals(v)) { - temp.append(parKey).append("=").append(value.toString()); - } - } - } - temp.append("&").append("key").append("=").append(key); - return DigestUtils.md5Hex(temp.toString()); + * @Author Sum1Dream + * @Name cancelCouponsYt + * @Description // 注销电子券 + * @Date 15:19 2024/1/31 + * @Param ticketNum + * @Param phone + * @return com.alibaba.fastjson.JSONObject + */ + public JSONObject cancelCouponsYt(String ticketNum , String phone) throws Exception{ + log.info("========================请求任务Start========================="); + Map req = new HashMap<>(); + req.put("appId", petroAppid); + req.put("appKey", petroAppKey); + req.put("timestamp", new Date().getTime() + ""); + req.put("nonce" , generateRandomString(16)); + + String [] vouchers = {ticketNum}; + + // 业务数据 + JSONObject jsonData = new JSONObject(); + jsonData.put("vouchers" , vouchers); + jsonData.put("businessId" , phone); + + + //业务内容加密 + String bizContent = JSONObject.toJSONString(jsonData); + bizContent = encrypt(bizContent); + + //加密的内容放到参数中 + req.put("jsonData", bizContent); + //生成签名 + String sign = PetroEncryptUtil.generateSign(req); + //签名放到参数中 + req.put("sign", sign); + Map postData = new HashMap<>(); + postData.put("sign" , sign); + postData.put("timestamp" , req.get("timestamp")); + postData.put("jsonData" , bizContent); + postData.put("nonce" , req.get("nonce")); + postData.put("appId", petroAppid); + log.info("查询电子券状态-请求参数: " + JSON.toJSONString(req)); + // 请求接口 + JSONObject object = HttpsUtils.doPost(reqUrl + "/outapi/cancelCouponsYt", postData); + + log.info("查询电子券状态-回调参数: " + JSON.toJSONString(object)); + + reqLogService.insert( + TripartiteReqLogType.type18, + req.get("timestamp").toString(), + TripartiteReqLogReqType.type1, + reqUrl + "get-coupon", + req.toString(), + object.toString() + ); + + return object; + } + + /** + * @Author Sum1Dream + * @Name generateRandomString + * @Description // 生成16位随机字符串 + * @Date 16:24 2024/1/15 + * @Param length 长度 + * @return java.lang.String + */ + private static String generateRandomString(Integer length) { + UUID uuid = UUID.randomUUID(); + return uuid.toString().replaceAll("-", "").substring(0, length); } /** * @param content AES加密前的明文 - * @param key 秘钥 * @return AES加密后的内容 */ - public static String encrypt(final String content,final String key) { - try { - byte[] raw = key.getBytes(charset); - SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES"); - //"算法/模式/补码方式" - Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); - cipher.init(Cipher.ENCRYPT_MODE, skeySpec); - byte[] encrypted = cipher.doFinal(content.getBytes(charset)); - //此处使用Hex做转码功能,同时能起到2次加密的作用。 - return DatatypeConverter.printHexBinary(encrypted); - } catch (Exception e) { - e.printStackTrace(); - return null; - } + public static String encrypt(final String content) { + return PetroEncryptUtil.encrypt(content , petroAesKey); } /** - * @Author Sum1Dream - * @Name decrypt - * @Description // 解密 - * @Date 16:19 2023/11/15 - * @Param content + * @Author Sum1Dream + * @Name decrypt + * @Description // 解密 + * @Date 16:19 2023/11/15 + * @Param content * @Param key * @return java.lang.String - */ + */ public static String decrypt(final String content) { - try { - byte[] raw = petroAesKey.getBytes("UTF-8"); - SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES"); - Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); - cipher.init(2, skeySpec); - byte[] hexBinary = DatatypeConverter.parseHexBinary(content); - byte[] original = cipher.doFinal(hexBinary); - return new String(original, "UTF-8"); - } catch (Exception var7) { - return null; - } + return PetroEncryptUtil.decrypt(content , petroAesKey); } } diff --git a/hai-service/src/main/java/com/hai/config/RechargeConfig.java b/hai-service/src/main/java/com/hai/config/RechargeConfig.java index 277edac9..2b978978 100644 --- a/hai-service/src/main/java/com/hai/config/RechargeConfig.java +++ b/hai-service/src/main/java/com/hai/config/RechargeConfig.java @@ -245,9 +245,80 @@ public class RechargeConfig { * @Date 14:11 2024/1/5 * @return com.alibaba.fastjson.JSONObject */ -// public static JSONObject jNiuGoodsList() throws { -// -// } + public static JSONObject jNiuGoodsList() throws Exception{ + log.info("发起简牛快充查询产品列表"); + Map paramMap = new HashMap<>(); + paramMap.put("appid" , CommonSysConst.getSysConfig().getJnApiKey()); + paramMap.put("sign", WxUtils.generateSignApi(paramMap , CommonSysConst.getSysConfig().getJnAppSecret() , WXPayConstants.SignType.MD5 , false)); + log.info("发起简牛快充查询产品列表-请求参数: " + JSON.toJSONString(paramMap)); + JSONObject jsonObject = HttpsUtils.doPost(CommonSysConst.getSysConfig().getJnPostUrl()+ "/modules/api/open/goods-list", paramMap , new HashMap<>()); + log.info("发起简牛快充查询产品列表-响应参数: " + jsonObject.toJSONString()); + return jsonObject; + } + + /** + * @Author Sum1Dream + * @Name rechargeOrderByJn + * @Description // 简牛下单 + * @Date 14:33 2024/1/25 + * @Param object + * @return com.alibaba.fastjson.JSONObject + */ + public static JSONObject rechargeOrderByJn(JSONObject object) throws Exception{ + log.info("发起简牛下单表"); + Map paramMap = new HashMap<>(); + paramMap.put("appid" , CommonSysConst.getSysConfig().getJnApiKey()); + paramMap.put("account" , object.getBigDecimal("price")); + paramMap.put("goods_id" , object.getBigDecimal("goodsId")); + paramMap.put("order_no" , object.getBigDecimal("orderNo")); + paramMap.put("option_id" , object.getBigDecimal("optionId")); + paramMap.put("notify_url" , CommonSysConst.getSysConfig().getJnNotifyUrl()); + paramMap.put("sign", WxUtils.generateSignApi(paramMap , CommonSysConst.getSysConfig().getJnAppSecret() , WXPayConstants.SignType.MD5 , false)); + log.info("发起简牛下单-请求参数: " + JSON.toJSONString(paramMap)); + JSONObject jsonObject = HttpsUtils.doPost(CommonSysConst.getSysConfig().getJnPostUrl()+ "/modules/api/open/order-create", paramMap , new HashMap<>()); + log.info("发起简牛下单-响应参数: " + jsonObject.toJSONString()); + return jsonObject; + } + + /** + * @Author Sum1Dream + * @Name checkOrderByJn + * @Description // 简牛查询订单 + * @Date 14:33 2024/1/25 + * @Param object + * @return com.alibaba.fastjson.JSONObject + */ + public static JSONObject checkOrderByJn(JSONObject object) throws Exception { + log.info("发起简牛快充查询产品列表"); + Map paramMap = new HashMap<>(); + paramMap.put("appid" , CommonSysConst.getSysConfig().getJnApiKey()); + paramMap.put("order_no" , object.getString("orderNo")); + paramMap.put("sign", WxUtils.generateSignApi(paramMap , CommonSysConst.getSysConfig().getJnAppSecret() , WXPayConstants.SignType.MD5 , false)); + log.info("发起简牛查询订单-请求参数: " + JSON.toJSONString(paramMap)); + JSONObject jsonObject = HttpsUtils.doPost(CommonSysConst.getSysConfig().getJnPostUrl()+ "/modules/api/open/check-order", paramMap , new HashMap<>()); + log.info("发起简牛查询订单-响应参数: " + jsonObject.toJSONString()); + return jsonObject; + } + + /** + * @Author Sum1Dream + * @Name cancelOrderJn + * @Description // 取消订单简牛 + * @Date 14:38 2024/1/25 + * @Param object + * @return com.alibaba.fastjson.JSONObject + */ + public static JSONObject cancelOrderJn(JSONObject object) throws Exception { + log.info("发起简牛快充查询产品列表"); + Map paramMap = new HashMap<>(); + paramMap.put("appid" , CommonSysConst.getSysConfig().getJnApiKey()); + paramMap.put("out_order_no" , object.getString("orderNo")); + paramMap.put("sign", WxUtils.generateSignApi(paramMap , CommonSysConst.getSysConfig().getJnAppSecret() , WXPayConstants.SignType.MD5 , false)); + log.info("发起取消订单简牛-请求参数: " + JSON.toJSONString(paramMap)); + JSONObject jsonObject = HttpsUtils.doPost(CommonSysConst.getSysConfig().getJnPostUrl()+ "/modules/api/open/cancel-order", paramMap , new HashMap<>()); + log.info("发起取消订单简牛-响应参数: " + jsonObject.toJSONString()); + return jsonObject; + } private static String paramSort(final Map param) { diff --git a/hai-service/src/main/java/com/hai/dao/ApiCouponMapper.java b/hai-service/src/main/java/com/hai/dao/ApiCouponMapper.java index b0f012ab..0ac5ab20 100644 --- a/hai-service/src/main/java/com/hai/dao/ApiCouponMapper.java +++ b/hai-service/src/main/java/com/hai/dao/ApiCouponMapper.java @@ -39,15 +39,21 @@ public interface ApiCouponMapper extends ApiCouponMapperExt { int deleteByPrimaryKey(Long id); @Insert({ - "insert into api_coupon (`type`, goods_type, ", - "`name`, code, `desc`, ", - "price, img, effective_days, ", + "insert into api_coupon (cou_category, `type`, ", + "goods_type, `name`, ", + "code, `desc`, price, ", + "cou_discount_value, cou_discount_max_value, ", + "img, valid_type, ", + "effective_days, valid_date, ", "create_time, update_time, ", "`status`, op_id, op_name, ", "ext_1, ext_2, ext_3)", - "values (#{type,jdbcType=INTEGER}, #{goodsType,jdbcType=VARCHAR}, ", - "#{name,jdbcType=VARCHAR}, #{code,jdbcType=VARCHAR}, #{desc,jdbcType=VARCHAR}, ", - "#{price,jdbcType=INTEGER}, #{img,jdbcType=VARCHAR}, #{effectiveDays,jdbcType=INTEGER}, ", + "values (#{couCategory,jdbcType=INTEGER}, #{type,jdbcType=INTEGER}, ", + "#{goodsType,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, ", + "#{code,jdbcType=VARCHAR}, #{desc,jdbcType=VARCHAR}, #{price,jdbcType=INTEGER}, ", + "#{couDiscountValue,jdbcType=DECIMAL}, #{couDiscountMaxValue,jdbcType=DECIMAL}, ", + "#{img,jdbcType=VARCHAR}, #{validType,jdbcType=INTEGER}, ", + "#{effectiveDays,jdbcType=INTEGER}, #{validDate,jdbcType=TIMESTAMP}, ", "#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, ", "#{status,jdbcType=INTEGER}, #{opId,jdbcType=BIGINT}, #{opName,jdbcType=VARCHAR}, ", "#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" @@ -62,14 +68,19 @@ public interface ApiCouponMapper extends ApiCouponMapperExt { @SelectProvider(type=ApiCouponSqlProvider.class, method="selectByExample") @Results({ @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), + @Result(column="cou_category", property="couCategory", jdbcType=JdbcType.INTEGER), @Result(column="type", property="type", jdbcType=JdbcType.INTEGER), @Result(column="goods_type", property="goodsType", jdbcType=JdbcType.VARCHAR), @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR), @Result(column="code", property="code", jdbcType=JdbcType.VARCHAR), @Result(column="desc", property="desc", jdbcType=JdbcType.VARCHAR), @Result(column="price", property="price", jdbcType=JdbcType.INTEGER), + @Result(column="cou_discount_value", property="couDiscountValue", jdbcType=JdbcType.DECIMAL), + @Result(column="cou_discount_max_value", property="couDiscountMaxValue", jdbcType=JdbcType.DECIMAL), @Result(column="img", property="img", jdbcType=JdbcType.VARCHAR), + @Result(column="valid_type", property="validType", jdbcType=JdbcType.INTEGER), @Result(column="effective_days", property="effectiveDays", jdbcType=JdbcType.INTEGER), + @Result(column="valid_date", property="validDate", jdbcType=JdbcType.TIMESTAMP), @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="status", property="status", jdbcType=JdbcType.INTEGER), @@ -83,21 +94,27 @@ public interface ApiCouponMapper extends ApiCouponMapperExt { @Select({ "select", - "id, `type`, goods_type, `name`, code, `desc`, price, img, effective_days, create_time, ", + "id, cou_category, `type`, goods_type, `name`, code, `desc`, price, cou_discount_value, ", + "cou_discount_max_value, img, valid_type, effective_days, valid_date, create_time, ", "update_time, `status`, op_id, op_name, ext_1, ext_2, ext_3", "from api_coupon", "where id = #{id,jdbcType=BIGINT}" }) @Results({ @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), + @Result(column="cou_category", property="couCategory", jdbcType=JdbcType.INTEGER), @Result(column="type", property="type", jdbcType=JdbcType.INTEGER), @Result(column="goods_type", property="goodsType", jdbcType=JdbcType.VARCHAR), @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR), @Result(column="code", property="code", jdbcType=JdbcType.VARCHAR), @Result(column="desc", property="desc", jdbcType=JdbcType.VARCHAR), @Result(column="price", property="price", jdbcType=JdbcType.INTEGER), + @Result(column="cou_discount_value", property="couDiscountValue", jdbcType=JdbcType.DECIMAL), + @Result(column="cou_discount_max_value", property="couDiscountMaxValue", jdbcType=JdbcType.DECIMAL), @Result(column="img", property="img", jdbcType=JdbcType.VARCHAR), + @Result(column="valid_type", property="validType", jdbcType=JdbcType.INTEGER), @Result(column="effective_days", property="effectiveDays", jdbcType=JdbcType.INTEGER), + @Result(column="valid_date", property="validDate", jdbcType=JdbcType.TIMESTAMP), @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="status", property="status", jdbcType=JdbcType.INTEGER), @@ -120,14 +137,19 @@ public interface ApiCouponMapper extends ApiCouponMapperExt { @Update({ "update api_coupon", - "set `type` = #{type,jdbcType=INTEGER},", + "set cou_category = #{couCategory,jdbcType=INTEGER},", + "`type` = #{type,jdbcType=INTEGER},", "goods_type = #{goodsType,jdbcType=VARCHAR},", "`name` = #{name,jdbcType=VARCHAR},", "code = #{code,jdbcType=VARCHAR},", "`desc` = #{desc,jdbcType=VARCHAR},", "price = #{price,jdbcType=INTEGER},", + "cou_discount_value = #{couDiscountValue,jdbcType=DECIMAL},", + "cou_discount_max_value = #{couDiscountMaxValue,jdbcType=DECIMAL},", "img = #{img,jdbcType=VARCHAR},", + "valid_type = #{validType,jdbcType=INTEGER},", "effective_days = #{effectiveDays,jdbcType=INTEGER},", + "valid_date = #{validDate,jdbcType=TIMESTAMP},", "create_time = #{createTime,jdbcType=TIMESTAMP},", "update_time = #{updateTime,jdbcType=TIMESTAMP},", "`status` = #{status,jdbcType=INTEGER},", diff --git a/hai-service/src/main/java/com/hai/dao/ApiCouponSqlProvider.java b/hai-service/src/main/java/com/hai/dao/ApiCouponSqlProvider.java index 934b55bd..2014968e 100644 --- a/hai-service/src/main/java/com/hai/dao/ApiCouponSqlProvider.java +++ b/hai-service/src/main/java/com/hai/dao/ApiCouponSqlProvider.java @@ -28,6 +28,10 @@ public class ApiCouponSqlProvider { SQL sql = new SQL(); sql.INSERT_INTO("api_coupon"); + if (record.getCouCategory() != null) { + sql.VALUES("cou_category", "#{couCategory,jdbcType=INTEGER}"); + } + if (record.getType() != null) { sql.VALUES("`type`", "#{type,jdbcType=INTEGER}"); } @@ -52,14 +56,30 @@ public class ApiCouponSqlProvider { sql.VALUES("price", "#{price,jdbcType=INTEGER}"); } + if (record.getCouDiscountValue() != null) { + sql.VALUES("cou_discount_value", "#{couDiscountValue,jdbcType=DECIMAL}"); + } + + if (record.getCouDiscountMaxValue() != null) { + sql.VALUES("cou_discount_max_value", "#{couDiscountMaxValue,jdbcType=DECIMAL}"); + } + if (record.getImg() != null) { sql.VALUES("img", "#{img,jdbcType=VARCHAR}"); } + if (record.getValidType() != null) { + sql.VALUES("valid_type", "#{validType,jdbcType=INTEGER}"); + } + if (record.getEffectiveDays() != null) { sql.VALUES("effective_days", "#{effectiveDays,jdbcType=INTEGER}"); } + if (record.getValidDate() != null) { + sql.VALUES("valid_date", "#{validDate,jdbcType=TIMESTAMP}"); + } + if (record.getCreateTime() != null) { sql.VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}"); } @@ -102,14 +122,19 @@ public class ApiCouponSqlProvider { } else { sql.SELECT("id"); } + sql.SELECT("cou_category"); sql.SELECT("`type`"); sql.SELECT("goods_type"); sql.SELECT("`name`"); sql.SELECT("code"); sql.SELECT("`desc`"); sql.SELECT("price"); + sql.SELECT("cou_discount_value"); + sql.SELECT("cou_discount_max_value"); sql.SELECT("img"); + sql.SELECT("valid_type"); sql.SELECT("effective_days"); + sql.SELECT("valid_date"); sql.SELECT("create_time"); sql.SELECT("update_time"); sql.SELECT("`status`"); @@ -139,6 +164,10 @@ public class ApiCouponSqlProvider { sql.SET("id = #{record.id,jdbcType=BIGINT}"); } + if (record.getCouCategory() != null) { + sql.SET("cou_category = #{record.couCategory,jdbcType=INTEGER}"); + } + if (record.getType() != null) { sql.SET("`type` = #{record.type,jdbcType=INTEGER}"); } @@ -163,14 +192,30 @@ public class ApiCouponSqlProvider { sql.SET("price = #{record.price,jdbcType=INTEGER}"); } + if (record.getCouDiscountValue() != null) { + sql.SET("cou_discount_value = #{record.couDiscountValue,jdbcType=DECIMAL}"); + } + + if (record.getCouDiscountMaxValue() != null) { + sql.SET("cou_discount_max_value = #{record.couDiscountMaxValue,jdbcType=DECIMAL}"); + } + if (record.getImg() != null) { sql.SET("img = #{record.img,jdbcType=VARCHAR}"); } + if (record.getValidType() != null) { + sql.SET("valid_type = #{record.validType,jdbcType=INTEGER}"); + } + if (record.getEffectiveDays() != null) { sql.SET("effective_days = #{record.effectiveDays,jdbcType=INTEGER}"); } + if (record.getValidDate() != null) { + sql.SET("valid_date = #{record.validDate,jdbcType=TIMESTAMP}"); + } + if (record.getCreateTime() != null) { sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); } @@ -212,14 +257,19 @@ public class ApiCouponSqlProvider { sql.UPDATE("api_coupon"); sql.SET("id = #{record.id,jdbcType=BIGINT}"); + sql.SET("cou_category = #{record.couCategory,jdbcType=INTEGER}"); sql.SET("`type` = #{record.type,jdbcType=INTEGER}"); sql.SET("goods_type = #{record.goodsType,jdbcType=VARCHAR}"); sql.SET("`name` = #{record.name,jdbcType=VARCHAR}"); sql.SET("code = #{record.code,jdbcType=VARCHAR}"); sql.SET("`desc` = #{record.desc,jdbcType=VARCHAR}"); sql.SET("price = #{record.price,jdbcType=INTEGER}"); + sql.SET("cou_discount_value = #{record.couDiscountValue,jdbcType=DECIMAL}"); + sql.SET("cou_discount_max_value = #{record.couDiscountMaxValue,jdbcType=DECIMAL}"); sql.SET("img = #{record.img,jdbcType=VARCHAR}"); + sql.SET("valid_type = #{record.validType,jdbcType=INTEGER}"); sql.SET("effective_days = #{record.effectiveDays,jdbcType=INTEGER}"); + sql.SET("valid_date = #{record.validDate,jdbcType=TIMESTAMP}"); sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); sql.SET("update_time = #{record.updateTime,jdbcType=TIMESTAMP}"); sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); @@ -238,6 +288,10 @@ public class ApiCouponSqlProvider { SQL sql = new SQL(); sql.UPDATE("api_coupon"); + if (record.getCouCategory() != null) { + sql.SET("cou_category = #{couCategory,jdbcType=INTEGER}"); + } + if (record.getType() != null) { sql.SET("`type` = #{type,jdbcType=INTEGER}"); } @@ -262,14 +316,30 @@ public class ApiCouponSqlProvider { sql.SET("price = #{price,jdbcType=INTEGER}"); } + if (record.getCouDiscountValue() != null) { + sql.SET("cou_discount_value = #{couDiscountValue,jdbcType=DECIMAL}"); + } + + if (record.getCouDiscountMaxValue() != null) { + sql.SET("cou_discount_max_value = #{couDiscountMaxValue,jdbcType=DECIMAL}"); + } + if (record.getImg() != null) { sql.SET("img = #{img,jdbcType=VARCHAR}"); } + if (record.getValidType() != null) { + sql.SET("valid_type = #{validType,jdbcType=INTEGER}"); + } + if (record.getEffectiveDays() != null) { sql.SET("effective_days = #{effectiveDays,jdbcType=INTEGER}"); } + if (record.getValidDate() != null) { + sql.SET("valid_date = #{validDate,jdbcType=TIMESTAMP}"); + } + if (record.getCreateTime() != null) { sql.SET("create_time = #{createTime,jdbcType=TIMESTAMP}"); } diff --git a/hai-service/src/main/java/com/hai/entity/ApiCoupon.java b/hai-service/src/main/java/com/hai/entity/ApiCoupon.java index 8f3fc113..14bba4df 100644 --- a/hai-service/src/main/java/com/hai/entity/ApiCoupon.java +++ b/hai-service/src/main/java/com/hai/entity/ApiCoupon.java @@ -1,6 +1,7 @@ package com.hai.entity; import java.io.Serializable; +import java.math.BigDecimal; import java.util.Date; /** @@ -18,6 +19,11 @@ public class ApiCoupon implements Serializable { */ private Long id; + /** + * 10、满减券 40 折扣券 + */ + private Integer couCategory; + /** * 类型:1,四川中石油 2.贵州中石油 */ @@ -48,16 +54,36 @@ public class ApiCoupon implements Serializable { */ private Integer price; + /** + * 折扣率 例:折扣为9.7折时,为0.97 + */ + private BigDecimal couDiscountValue; + + /** + * 当折扣计算后金额大余最大折扣金额时,以最大折扣金额为准 + */ + private BigDecimal couDiscountMaxValue; + /** * 卡券图片 */ private String img; + /** + * 券有效期类型: 1固定;2动态 + */ + private Integer validType; + /** * 有效天数 */ private Integer effectiveDays; + /** + * 有效期 + */ + private Date validDate; + /** * 创建时间 */ @@ -108,6 +134,14 @@ public class ApiCoupon implements Serializable { this.id = id; } + public Integer getCouCategory() { + return couCategory; + } + + public void setCouCategory(Integer couCategory) { + this.couCategory = couCategory; + } + public Integer getType() { return type; } @@ -156,6 +190,22 @@ public class ApiCoupon implements Serializable { this.price = price; } + public BigDecimal getCouDiscountValue() { + return couDiscountValue; + } + + public void setCouDiscountValue(BigDecimal couDiscountValue) { + this.couDiscountValue = couDiscountValue; + } + + public BigDecimal getCouDiscountMaxValue() { + return couDiscountMaxValue; + } + + public void setCouDiscountMaxValue(BigDecimal couDiscountMaxValue) { + this.couDiscountMaxValue = couDiscountMaxValue; + } + public String getImg() { return img; } @@ -164,6 +214,14 @@ public class ApiCoupon implements Serializable { this.img = img; } + public Integer getValidType() { + return validType; + } + + public void setValidType(Integer validType) { + this.validType = validType; + } + public Integer getEffectiveDays() { return effectiveDays; } @@ -172,6 +230,14 @@ public class ApiCoupon implements Serializable { this.effectiveDays = effectiveDays; } + public Date getValidDate() { + return validDate; + } + + public void setValidDate(Date validDate) { + this.validDate = validDate; + } + public Date getCreateTime() { return createTime; } @@ -249,14 +315,19 @@ public class ApiCoupon implements Serializable { } ApiCoupon other = (ApiCoupon) that; return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) + && (this.getCouCategory() == null ? other.getCouCategory() == null : this.getCouCategory().equals(other.getCouCategory())) && (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType())) && (this.getGoodsType() == null ? other.getGoodsType() == null : this.getGoodsType().equals(other.getGoodsType())) && (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName())) && (this.getCode() == null ? other.getCode() == null : this.getCode().equals(other.getCode())) && (this.getDesc() == null ? other.getDesc() == null : this.getDesc().equals(other.getDesc())) && (this.getPrice() == null ? other.getPrice() == null : this.getPrice().equals(other.getPrice())) + && (this.getCouDiscountValue() == null ? other.getCouDiscountValue() == null : this.getCouDiscountValue().equals(other.getCouDiscountValue())) + && (this.getCouDiscountMaxValue() == null ? other.getCouDiscountMaxValue() == null : this.getCouDiscountMaxValue().equals(other.getCouDiscountMaxValue())) && (this.getImg() == null ? other.getImg() == null : this.getImg().equals(other.getImg())) + && (this.getValidType() == null ? other.getValidType() == null : this.getValidType().equals(other.getValidType())) && (this.getEffectiveDays() == null ? other.getEffectiveDays() == null : this.getEffectiveDays().equals(other.getEffectiveDays())) + && (this.getValidDate() == null ? other.getValidDate() == null : this.getValidDate().equals(other.getValidDate())) && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())) && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime())) && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus())) @@ -272,14 +343,19 @@ public class ApiCoupon implements Serializable { final int prime = 31; int result = 1; result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); + result = prime * result + ((getCouCategory() == null) ? 0 : getCouCategory().hashCode()); result = prime * result + ((getType() == null) ? 0 : getType().hashCode()); result = prime * result + ((getGoodsType() == null) ? 0 : getGoodsType().hashCode()); result = prime * result + ((getName() == null) ? 0 : getName().hashCode()); result = prime * result + ((getCode() == null) ? 0 : getCode().hashCode()); result = prime * result + ((getDesc() == null) ? 0 : getDesc().hashCode()); result = prime * result + ((getPrice() == null) ? 0 : getPrice().hashCode()); + result = prime * result + ((getCouDiscountValue() == null) ? 0 : getCouDiscountValue().hashCode()); + result = prime * result + ((getCouDiscountMaxValue() == null) ? 0 : getCouDiscountMaxValue().hashCode()); result = prime * result + ((getImg() == null) ? 0 : getImg().hashCode()); + result = prime * result + ((getValidType() == null) ? 0 : getValidType().hashCode()); result = prime * result + ((getEffectiveDays() == null) ? 0 : getEffectiveDays().hashCode()); + result = prime * result + ((getValidDate() == null) ? 0 : getValidDate().hashCode()); result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode()); result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode()); @@ -298,14 +374,19 @@ public class ApiCoupon implements Serializable { sb.append(" ["); sb.append("Hash = ").append(hashCode()); sb.append(", id=").append(id); + sb.append(", couCategory=").append(couCategory); sb.append(", type=").append(type); sb.append(", goodsType=").append(goodsType); sb.append(", name=").append(name); sb.append(", code=").append(code); sb.append(", desc=").append(desc); sb.append(", price=").append(price); + sb.append(", couDiscountValue=").append(couDiscountValue); + sb.append(", couDiscountMaxValue=").append(couDiscountMaxValue); sb.append(", img=").append(img); + sb.append(", validType=").append(validType); sb.append(", effectiveDays=").append(effectiveDays); + sb.append(", validDate=").append(validDate); sb.append(", createTime=").append(createTime); sb.append(", updateTime=").append(updateTime); sb.append(", status=").append(status); diff --git a/hai-service/src/main/java/com/hai/entity/ApiCouponExample.java b/hai-service/src/main/java/com/hai/entity/ApiCouponExample.java index b39c6a81..6956861a 100644 --- a/hai-service/src/main/java/com/hai/entity/ApiCouponExample.java +++ b/hai-service/src/main/java/com/hai/entity/ApiCouponExample.java @@ -1,5 +1,6 @@ package com.hai.entity; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -185,6 +186,66 @@ public class ApiCouponExample { return (Criteria) this; } + public Criteria andCouCategoryIsNull() { + addCriterion("cou_category is null"); + return (Criteria) this; + } + + public Criteria andCouCategoryIsNotNull() { + addCriterion("cou_category is not null"); + return (Criteria) this; + } + + public Criteria andCouCategoryEqualTo(Integer value) { + addCriterion("cou_category =", value, "couCategory"); + return (Criteria) this; + } + + public Criteria andCouCategoryNotEqualTo(Integer value) { + addCriterion("cou_category <>", value, "couCategory"); + return (Criteria) this; + } + + public Criteria andCouCategoryGreaterThan(Integer value) { + addCriterion("cou_category >", value, "couCategory"); + return (Criteria) this; + } + + public Criteria andCouCategoryGreaterThanOrEqualTo(Integer value) { + addCriterion("cou_category >=", value, "couCategory"); + return (Criteria) this; + } + + public Criteria andCouCategoryLessThan(Integer value) { + addCriterion("cou_category <", value, "couCategory"); + return (Criteria) this; + } + + public Criteria andCouCategoryLessThanOrEqualTo(Integer value) { + addCriterion("cou_category <=", value, "couCategory"); + return (Criteria) this; + } + + public Criteria andCouCategoryIn(List values) { + addCriterion("cou_category in", values, "couCategory"); + return (Criteria) this; + } + + public Criteria andCouCategoryNotIn(List values) { + addCriterion("cou_category not in", values, "couCategory"); + return (Criteria) this; + } + + public Criteria andCouCategoryBetween(Integer value1, Integer value2) { + addCriterion("cou_category between", value1, value2, "couCategory"); + return (Criteria) this; + } + + public Criteria andCouCategoryNotBetween(Integer value1, Integer value2) { + addCriterion("cou_category not between", value1, value2, "couCategory"); + return (Criteria) this; + } + public Criteria andTypeIsNull() { addCriterion("`type` is null"); return (Criteria) this; @@ -585,6 +646,126 @@ public class ApiCouponExample { return (Criteria) this; } + public Criteria andCouDiscountValueIsNull() { + addCriterion("cou_discount_value is null"); + return (Criteria) this; + } + + public Criteria andCouDiscountValueIsNotNull() { + addCriterion("cou_discount_value is not null"); + return (Criteria) this; + } + + public Criteria andCouDiscountValueEqualTo(BigDecimal value) { + addCriterion("cou_discount_value =", value, "couDiscountValue"); + return (Criteria) this; + } + + public Criteria andCouDiscountValueNotEqualTo(BigDecimal value) { + addCriterion("cou_discount_value <>", value, "couDiscountValue"); + return (Criteria) this; + } + + public Criteria andCouDiscountValueGreaterThan(BigDecimal value) { + addCriterion("cou_discount_value >", value, "couDiscountValue"); + return (Criteria) this; + } + + public Criteria andCouDiscountValueGreaterThanOrEqualTo(BigDecimal value) { + addCriterion("cou_discount_value >=", value, "couDiscountValue"); + return (Criteria) this; + } + + public Criteria andCouDiscountValueLessThan(BigDecimal value) { + addCriterion("cou_discount_value <", value, "couDiscountValue"); + return (Criteria) this; + } + + public Criteria andCouDiscountValueLessThanOrEqualTo(BigDecimal value) { + addCriterion("cou_discount_value <=", value, "couDiscountValue"); + return (Criteria) this; + } + + public Criteria andCouDiscountValueIn(List values) { + addCriterion("cou_discount_value in", values, "couDiscountValue"); + return (Criteria) this; + } + + public Criteria andCouDiscountValueNotIn(List values) { + addCriterion("cou_discount_value not in", values, "couDiscountValue"); + return (Criteria) this; + } + + public Criteria andCouDiscountValueBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("cou_discount_value between", value1, value2, "couDiscountValue"); + return (Criteria) this; + } + + public Criteria andCouDiscountValueNotBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("cou_discount_value not between", value1, value2, "couDiscountValue"); + return (Criteria) this; + } + + public Criteria andCouDiscountMaxValueIsNull() { + addCriterion("cou_discount_max_value is null"); + return (Criteria) this; + } + + public Criteria andCouDiscountMaxValueIsNotNull() { + addCriterion("cou_discount_max_value is not null"); + return (Criteria) this; + } + + public Criteria andCouDiscountMaxValueEqualTo(BigDecimal value) { + addCriterion("cou_discount_max_value =", value, "couDiscountMaxValue"); + return (Criteria) this; + } + + public Criteria andCouDiscountMaxValueNotEqualTo(BigDecimal value) { + addCriterion("cou_discount_max_value <>", value, "couDiscountMaxValue"); + return (Criteria) this; + } + + public Criteria andCouDiscountMaxValueGreaterThan(BigDecimal value) { + addCriterion("cou_discount_max_value >", value, "couDiscountMaxValue"); + return (Criteria) this; + } + + public Criteria andCouDiscountMaxValueGreaterThanOrEqualTo(BigDecimal value) { + addCriterion("cou_discount_max_value >=", value, "couDiscountMaxValue"); + return (Criteria) this; + } + + public Criteria andCouDiscountMaxValueLessThan(BigDecimal value) { + addCriterion("cou_discount_max_value <", value, "couDiscountMaxValue"); + return (Criteria) this; + } + + public Criteria andCouDiscountMaxValueLessThanOrEqualTo(BigDecimal value) { + addCriterion("cou_discount_max_value <=", value, "couDiscountMaxValue"); + return (Criteria) this; + } + + public Criteria andCouDiscountMaxValueIn(List values) { + addCriterion("cou_discount_max_value in", values, "couDiscountMaxValue"); + return (Criteria) this; + } + + public Criteria andCouDiscountMaxValueNotIn(List values) { + addCriterion("cou_discount_max_value not in", values, "couDiscountMaxValue"); + return (Criteria) this; + } + + public Criteria andCouDiscountMaxValueBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("cou_discount_max_value between", value1, value2, "couDiscountMaxValue"); + return (Criteria) this; + } + + public Criteria andCouDiscountMaxValueNotBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("cou_discount_max_value not between", value1, value2, "couDiscountMaxValue"); + return (Criteria) this; + } + public Criteria andImgIsNull() { addCriterion("img is null"); return (Criteria) this; @@ -655,6 +836,66 @@ public class ApiCouponExample { return (Criteria) this; } + public Criteria andValidTypeIsNull() { + addCriterion("valid_type is null"); + return (Criteria) this; + } + + public Criteria andValidTypeIsNotNull() { + addCriterion("valid_type is not null"); + return (Criteria) this; + } + + public Criteria andValidTypeEqualTo(Integer value) { + addCriterion("valid_type =", value, "validType"); + return (Criteria) this; + } + + public Criteria andValidTypeNotEqualTo(Integer value) { + addCriterion("valid_type <>", value, "validType"); + return (Criteria) this; + } + + public Criteria andValidTypeGreaterThan(Integer value) { + addCriterion("valid_type >", value, "validType"); + return (Criteria) this; + } + + public Criteria andValidTypeGreaterThanOrEqualTo(Integer value) { + addCriterion("valid_type >=", value, "validType"); + return (Criteria) this; + } + + public Criteria andValidTypeLessThan(Integer value) { + addCriterion("valid_type <", value, "validType"); + return (Criteria) this; + } + + public Criteria andValidTypeLessThanOrEqualTo(Integer value) { + addCriterion("valid_type <=", value, "validType"); + return (Criteria) this; + } + + public Criteria andValidTypeIn(List values) { + addCriterion("valid_type in", values, "validType"); + return (Criteria) this; + } + + public Criteria andValidTypeNotIn(List values) { + addCriterion("valid_type not in", values, "validType"); + return (Criteria) this; + } + + public Criteria andValidTypeBetween(Integer value1, Integer value2) { + addCriterion("valid_type between", value1, value2, "validType"); + return (Criteria) this; + } + + public Criteria andValidTypeNotBetween(Integer value1, Integer value2) { + addCriterion("valid_type not between", value1, value2, "validType"); + return (Criteria) this; + } + public Criteria andEffectiveDaysIsNull() { addCriterion("effective_days is null"); return (Criteria) this; @@ -715,6 +956,66 @@ public class ApiCouponExample { return (Criteria) this; } + public Criteria andValidDateIsNull() { + addCriterion("valid_date is null"); + return (Criteria) this; + } + + public Criteria andValidDateIsNotNull() { + addCriterion("valid_date is not null"); + return (Criteria) this; + } + + public Criteria andValidDateEqualTo(Date value) { + addCriterion("valid_date =", value, "validDate"); + return (Criteria) this; + } + + public Criteria andValidDateNotEqualTo(Date value) { + addCriterion("valid_date <>", value, "validDate"); + return (Criteria) this; + } + + public Criteria andValidDateGreaterThan(Date value) { + addCriterion("valid_date >", value, "validDate"); + return (Criteria) this; + } + + public Criteria andValidDateGreaterThanOrEqualTo(Date value) { + addCriterion("valid_date >=", value, "validDate"); + return (Criteria) this; + } + + public Criteria andValidDateLessThan(Date value) { + addCriterion("valid_date <", value, "validDate"); + return (Criteria) this; + } + + public Criteria andValidDateLessThanOrEqualTo(Date value) { + addCriterion("valid_date <=", value, "validDate"); + return (Criteria) this; + } + + public Criteria andValidDateIn(List values) { + addCriterion("valid_date in", values, "validDate"); + return (Criteria) this; + } + + public Criteria andValidDateNotIn(List values) { + addCriterion("valid_date not in", values, "validDate"); + return (Criteria) this; + } + + public Criteria andValidDateBetween(Date value1, Date value2) { + addCriterion("valid_date between", value1, value2, "validDate"); + return (Criteria) this; + } + + public Criteria andValidDateNotBetween(Date value1, Date value2) { + addCriterion("valid_date not between", value1, value2, "validDate"); + return (Criteria) this; + } + public Criteria andCreateTimeIsNull() { addCriterion("create_time is null"); return (Criteria) this; diff --git a/hai-service/src/main/java/com/hai/entity/HighCouponCodeOther.java b/hai-service/src/main/java/com/hai/entity/HighCouponCodeOther.java index a3ac7751..50163d5c 100644 --- a/hai-service/src/main/java/com/hai/entity/HighCouponCodeOther.java +++ b/hai-service/src/main/java/com/hai/entity/HighCouponCodeOther.java @@ -341,4 +341,4 @@ public class HighCouponCodeOther implements Serializable { sb.append("]"); return sb.toString(); } -} +} \ No newline at end of file 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 f6b742a1..b4fa6218 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 @@ -503,9 +503,8 @@ public class ApiOrderCreateHandleServiceImpl implements ApiOrderCreateHandleServ ApiMchProduct mchProduct = apiMchProductService.findByMap(mapProduct); - // 计算成本价格 - BigDecimal price = priceComputeConfig.computationPriceCost(mchProduct.getDiscount() , new BigDecimal(apiCoupon.getPrice()/100)); + BigDecimal price = priceComputeConfig.computationPriceCost(mchProduct.getDiscount() , new BigDecimal(apiCoupon.getPrice())); // 判断金额是否充足 if (apiMerchants.getAmounts().compareTo(price) < 0) { @@ -522,7 +521,7 @@ public class ApiOrderCreateHandleServiceImpl implements ApiOrderCreateHandleServ ApiOrder apiOrder = new ApiOrder(); apiOrder.setCreateTime(new Date()); apiOrder.setTitle(apiMerchants.getMerchantName() + "|" + OrderProductType.PRODUCT_TYPE18.getName() + "|扣款" + price); - apiOrder.setFacePrice(new BigDecimal(apiCoupon.getPrice()/100)); + apiOrder.setFacePrice(new BigDecimal(apiCoupon.getPrice())); apiOrder.setCostPrice(price); apiOrder.setOrderPrice(price); apiOrder.setMchId(object.getString("merchId")); diff --git a/hai-service/src/main/java/com/hai/order/service/impl/OrderPaySuccessServiceImpl.java b/hai-service/src/main/java/com/hai/order/service/impl/OrderPaySuccessServiceImpl.java index e916ba4e..8d75e64d 100644 --- a/hai-service/src/main/java/com/hai/order/service/impl/OrderPaySuccessServiceImpl.java +++ b/hai-service/src/main/java/com/hai/order/service/impl/OrderPaySuccessServiceImpl.java @@ -701,21 +701,21 @@ public class OrderPaySuccessServiceImpl implements OrderPaySuccessService { } // 发放卡券 - JSONObject jsonObject = petroConfig.getCoupon(apiCoupon.getCode() , order.getMemPhone() , order.getOrderNo()); + JSONObject jsonObject = petroConfig.getCoupon(apiCoupon.getCode() , order.getMemPhone()); - if (!jsonObject.getString("code").equals("1")) { + if (!jsonObject.getString("resultCode").equals("0000")) { throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "当前卡券不可购买"); } - String data = PetroConfig.decrypt(jsonObject.getString("biz_content")); + String data = PetroConfig.decrypt(jsonObject.getString("jsonResult")); JSONObject object = JSONObject.parseObject(data); - Object ticketList = object.getJSONArray("ticket_list").get(0); - JSONObject ticketListObject = (JSONObject) ticketList;; order.setOrderStatus(OrderStatus.STATUS3.getNumber()); order.setFinishTime(new Date()); - order.getHighChildOrderList().get(0).setExt5(object.getString("request_code")); - order.getHighChildOrderList().get(0).setExt6(ticketListObject.getString("ticket_num")); + // 券类型别名 + order.getHighChildOrderList().get(0).setExt5(object.getString("alias")); + // 唯一标识 + order.getHighChildOrderList().get(0).setExt6(object.getString("voucher")); orderService.updateOrderData(order); } diff --git a/hai-service/src/main/java/com/hai/service/impl/ApiMerchantsServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/ApiMerchantsServiceImpl.java index 43a5f0df..af682ad1 100644 --- a/hai-service/src/main/java/com/hai/service/impl/ApiMerchantsServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/ApiMerchantsServiceImpl.java @@ -189,6 +189,7 @@ public class ApiMerchantsServiceImpl implements ApiMerchantsService { ApiAmountRecordExample example = new ApiAmountRecordExample(); example.createCriteria().andMchIdEqualTo(apiMerchants.getMchId()); + example.setOrderByClause("create_time desc"); return apiAmountRecordMapper.selectByExample(example); } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighCouponAgentServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighCouponAgentServiceImpl.java index fb125d1f..a562dbc3 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighCouponAgentServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighCouponAgentServiceImpl.java @@ -378,21 +378,19 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { couponCodeOther.setType(6); } // 发放卡券 - JSONObject jsonObject = petroConfig.getCoupon(coupon.getCouponKey() , phone , couponAgentCode.getConvertCode()); + JSONObject jsonObject = petroConfig.getCoupon(coupon.getCouponKey() , phone); - if (!jsonObject.getString("code").equals("1")) { + if (!jsonObject.getString("resultCode").equals("0000")) { throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "当前卡券不可购买"); } - String data = PetroConfig.decrypt(jsonObject.getString("biz_content")); + String data = PetroConfig.decrypt(jsonObject.getString("jsonResult")); JSONObject object = JSONObject.parseObject(data); - Object ticketList = object.getJSONArray("ticket_list").get(0); - JSONObject ticketListObject = (JSONObject) ticketList;; couponCodeOther.setCouponAgentCodeId(couponAgentCodeId); - couponCodeOther.setCouTypeCode(object.getString("request_code")); - couponCodeOther.setCouNo(ticketListObject.getString("ticket_num")); + couponCodeOther.setCouTypeCode(object.getString("alias")); + couponCodeOther.setCouNo(object.getString("voucher")); couponCodeOther.setActiveTime(new Date()); couponCodeOther.setValidStartDate(new Date()); couponCodeOther.setValidEndDate(coupon.getSalesEndTime()); diff --git a/hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java index b27c7c5d..b2060118 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java @@ -537,23 +537,19 @@ public class HighCouponCodeServiceImpl implements HighCouponCodeService { } // 发放卡券 - JSONObject jsonObject = petroConfig.getCoupon(coupon.getCouponKey() , order.getMemPhone() , order.getOrderNo()); + JSONObject jsonObject = petroConfig.getCoupon(coupon.getCouponKey() , order.getMemPhone()); - if (!jsonObject.getString("code").equals("1")) { - throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "当前卡券不可购买"); + if (!jsonObject.getString("resultCode").equals("0000")) { + throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , jsonObject.getString("errMsg")); } - String data = PetroConfig.decrypt(jsonObject.getString("biz_content")); + String data = PetroConfig.decrypt(jsonObject.getString("jsonResult")); JSONObject object = JSONObject.parseObject(data); - Object ticketList = object.getJSONArray("ticket_list").get(0); - JSONObject ticketListObject = (JSONObject) ticketList;; - - couponCodeOther.setOrderId(order.getId()); couponCodeOther.setChildOrderId(childOrder.getId()); - couponCodeOther.setCouTypeCode(object.getString("request_code")); - couponCodeOther.setCouNo(ticketListObject.getString("ticket_num")); + couponCodeOther.setCouTypeCode(object.getString("alias")); + couponCodeOther.setCouNo(object.getString("voucher")); couponCodeOther.setActiveTime(new Date()); couponCodeOther.setValidStartDate(new Date()); couponCodeOther.setValidEndDate(coupon.getSalesEndTime()); diff --git a/hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentCodeServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentCodeServiceImpl.java index 4b0270f1..7b558bb4 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentCodeServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentCodeServiceImpl.java @@ -316,21 +316,20 @@ public class HighDiscountAgentCodeServiceImpl implements HighDiscountAgentCodeSe } String tradeId = discountAgentCode.getId()+""+System.currentTimeMillis()+""; // 预发码 - JSONObject preSendCoupon = petroConfig.getCoupon(couponList.get(0).getHighCoupon().getCouponKey(), userModel.getHighUser().getPhone() , tradeId); - if (!preSendCoupon.getString("code").equals("1")) { - throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "系统维护中"); + JSONObject preSendCoupon = petroConfig.getCoupon(couponList.get(0).getHighCoupon().getCouponKey(), userModel.getHighUser().getPhone()); + + if (!preSendCoupon.getString("resultCode").equals("0000")) { + throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "当前卡券不可购买"); } - String data = PetroConfig.decrypt(preSendCoupon.getString("biz_content")); + String data = PetroConfig.decrypt(preSendCoupon.getString("jsonResult")); JSONObject object = JSONObject.parseObject(data); - Object ticketList = object.getJSONArray("ticket_list").get(0); - JSONObject ticketListObject = (JSONObject) ticketList;; HighCouponCodeOther couponCodeOther = new HighCouponCodeOther(); couponCodeOther.setType(3); couponCodeOther.setDiscountAgentCodeId(discountAgentCode.getId()); - couponCodeOther.setCouTypeCode(object.getString("request_code")); - couponCodeOther.setCouNo(ticketListObject.getString("ticket_num")); + couponCodeOther.setCouTypeCode(object.getString("alias")); + couponCodeOther.setCouNo(object.getString("voucher")); couponCodeOther.setActiveTime(new Date()); couponCodeOther.setValidStartDate(new Date()); couponCodeOther.setValidEndDate(discount.getSalesEndTime()); @@ -353,21 +352,20 @@ public class HighDiscountAgentCodeServiceImpl implements HighDiscountAgentCodeSe } String tradeId = discountAgentCode.getId()+""+System.currentTimeMillis()+""; // 预发码 - JSONObject preSendCoupon = petroConfig.getCoupon(couponList.get(0).getHighCoupon().getCouponKey(), userModel.getHighUser().getPhone() , tradeId); - if (!preSendCoupon.getString("code").equals("1")) { - throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "系统维护中"); + JSONObject preSendCoupon = petroConfig.getCoupon(couponList.get(0).getHighCoupon().getCouponKey(), userModel.getHighUser().getPhone()); + + if (!preSendCoupon.getString("resultCode").equals("0000")) { + throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "当前卡券不可购买"); } - String data = PetroConfig.decrypt(preSendCoupon.getString("biz_content")); + String data = PetroConfig.decrypt(preSendCoupon.getString("jsonResult")); JSONObject object = JSONObject.parseObject(data); - Object ticketList = object.getJSONArray("ticket_list").get(0); - JSONObject ticketListObject = (JSONObject) ticketList;; HighCouponCodeOther couponCodeOther = new HighCouponCodeOther(); couponCodeOther.setType(3); couponCodeOther.setDiscountAgentCodeId(discountAgentCode.getId()); - couponCodeOther.setCouTypeCode(object.getString("request_code")); - couponCodeOther.setCouNo(ticketListObject.getString("ticket_num")); + couponCodeOther.setCouTypeCode(object.getString("alias")); + couponCodeOther.setCouNo(object.getString("voucher")); couponCodeOther.setActiveTime(new Date()); couponCodeOther.setValidStartDate(new Date()); couponCodeOther.setValidEndDate(discount.getSalesEndTime()); diff --git a/hai-service/src/main/resources/dev/commonConfig.properties b/hai-service/src/main/resources/dev/commonConfig.properties index 5722bf1d..8228a13d 100644 --- a/hai-service/src/main/resources/dev/commonConfig.properties +++ b/hai-service/src/main/resources/dev/commonConfig.properties @@ -109,6 +109,12 @@ CyApiKey=cyMYLABWa2H2u CyAppSecret =cysslWXHnMHDMEvDEtwSWaJMGwl4dkcPLT CyPostUrl=http://120.24.83.85:8999/ +#JN +JnNotifyUrl = https://hsgcs.dctpay.com/order/mobileRechargeNotify/rechargeCallbackByJn +JnApiKey=k0e8y20qk7w36q +JnAppSecret =cd3c528482d67d5d56376db6fb97f561 +JnPostUrl=https://open.jnycc.com + unionAppId=7113783e75354df2a985efd3f31b9528 unionSecret=e2c731d2a026469aa6d218432f361653 unionRsaKey=891f6775fba7f12cc23df7c75e02b39b891f6775fba7f12c @@ -151,9 +157,7 @@ ScPetroAppid = 510000313181602615 ScPetroAppKey = 510000kA5kxtaDnx3V6HE ScPetroAesKey = AptFsUgpgAij3evH7rm4ubTKu5viSx9U -GzPetroUrl = http://43.136.176.177:8080/hd-api/out/ -GzPetroAppid = 520000990232626265 -GzPetroAppKey = 520000W4S3BRkFhaDsNMM -GzPetroAesKey = A8P2sUnM6PsKPwusiFEDFjMu8Hh8wB79 - -# +GzPetroUrl = http://140.143.82.223:1588/gz +GzPetroAppid = F0bdoJRwt +GzPetroAppKey = pIyhCbA61wwyyU371QUSnBKqbWvO8Q98 +GzPetroAesKey = pIyhCbA61wwyyU371QUSnBKqbWvO8Q98 diff --git a/hai-service/src/main/resources/prod-9401/commonConfig.properties b/hai-service/src/main/resources/prod-9401/commonConfig.properties index dbc63b3e..22e219d1 100644 --- a/hai-service/src/main/resources/prod-9401/commonConfig.properties +++ b/hai-service/src/main/resources/prod-9401/commonConfig.properties @@ -100,10 +100,18 @@ CyApiKey=cyMYLABWa2H2u CyAppSecret =cysslWXHnMHDMEvDEtwSWaJMGwl4dkcPLT CyPostUrl=http://120.24.83.85:8999/ +#JN +JnNotifyUrl = https://hsg.dctpay.com/order/mobileRechargeNotify/rechargeCallbackByJn +JnApiKey=k0e8y20qk7w36q +JnAppSecret =cd3c528482d67d5d56376db6fb97f561 +JnPostUrl=https://open.jnycc.com + + unionAppId=ced46392acfe42be863fdfdd3e61164a unionSecret=a0f380bb22cd4ce2a8d35f3bf437d6fa unionRsaKey=f2e6b6b95da445866194498c371a7c8af2e6b6b95da44586 + #url fileUrl=/home/project/hsg/filesystem/ @@ -131,17 +139,13 @@ diandianwAppSecret=msk48q5jinmpsfdgpcyryx6lhkoiii4s groupCode = https://pay.dctpay.com/cweb?accountId=0001&key= -#ScPetroUrl = http://43.136.176.177:8081/hd-api/out/ -#ScPetroAppid = 510000526745391907 -#ScPetroAppKey = 5100006xmbmM2NBpm5HXT -#ScPetroAesKey = AueRgSEVwPg87ebYhbYvfxMM3XAkvimu + ScPetroUrl = http://43.136.176.177:8081/hd-api/out/ ScPetroAppid = 510000313181602615 ScPetroAppKey = 510000kA5kxtaDnx3V6HE ScPetroAesKey = AptFsUgpgAij3evH7rm4ubTKu5viSx9U - -GzPetroUrl = http://43.136.176.177:8080/hd-api/out/ -GzPetroAppid = 520000325108579843 -GzPetroAppKey = 520000A3CVdd4vmcjtkDR -GzPetroAesKey = A39Yu3YcxtpM2UdiSMef6e7pcjmbkFi7 \ No newline at end of file +GzPetroUrl = http://140.143.82.223:1588/gz +GzPetroAppid = F0bdoJRwt +GzPetroAppKey = pIyhCbA61wwyyU371QUSnBKqbWvO8Q98 +GzPetroAesKey = pIyhCbA61wwyyU371QUSnBKqbWvO8Q98 \ No newline at end of file diff --git a/hai-service/src/main/resources/prod/commonConfig.properties b/hai-service/src/main/resources/prod/commonConfig.properties index a7c25b7e..622627c9 100644 --- a/hai-service/src/main/resources/prod/commonConfig.properties +++ b/hai-service/src/main/resources/prod/commonConfig.properties @@ -106,6 +106,12 @@ CyApiKey=cyMYLABWa2H2u CyAppSecret =cysslWXHnMHDMEvDEtwSWaJMGwl4dkcPLT CyPostUrl=http://120.24.83.85:8999/ +#JN +JnNotifyUrl = https://hsg.dctpay.com/order/mobileRechargeNotify/rechargeCallbackByJn +JnApiKey=k0e8y20qk7w36q +JnAppSecret =cd3c528482d67d5d56376db6fb97f561 +JnPostUrl=https://open.jnycc.com + unionAppId=ced46392acfe42be863fdfdd3e61164a unionSecret=a0f380bb22cd4ce2a8d35f3bf437d6fa unionRsaKey=f2e6b6b95da445866194498c371a7c8af2e6b6b95da44586 @@ -141,12 +147,9 @@ ScPetroUrl = http://43.136.176.177:8081/hd-api/out/ ScPetroAppid = 510000526745391907 ScPetroAppKey = 5100006xmbmM2NBpm5HXT ScPetroAesKey = AueRgSEVwPg87ebYhbYvfxMM3XAkvimu -#ScPetroUrl = http://43.136.176.177:8081/hd-api/out/ -#ScPetroAppid = 5100003131816026151 -#ScPetroAppKey = 510000kA5kxtaDnx3V6HE -#ScPetroAesKey = AptFsUgpgAij3evH7rm4ubTKu5viSx9U - -GzPetroUrl = http://43.136.176.177:8080/hd-api/out/ -GzPetroAppid = 520000325108579843 -GzPetroAppKey = 520000A3CVdd4vmcjtkDR -GzPetroAesKey = A39Yu3YcxtpM2UdiSMef6e7pcjmbkFi7 + + +GzPetroUrl = http://140.143.82.223:1588/gz +GzPetroAppid = F0bdoJRwt +GzPetroAppKey = pIyhCbA61wwyyU371QUSnBKqbWvO8Q98 +GzPetroAesKey = pIyhCbA61wwyyU371QUSnBKqbWvO8Q98 diff --git a/v1/src/main/java/com/v1/config/AuthConfig.java b/v1/src/main/java/com/v1/config/AuthConfig.java index 1b6620b6..806109fd 100644 --- a/v1/src/main/java/com/v1/config/AuthConfig.java +++ b/v1/src/main/java/com/v1/config/AuthConfig.java @@ -101,6 +101,7 @@ public class AuthConfig implements WebMvcConfigurer { .excludePathPatterns("/orderRebate/*") .excludePathPatterns("/refuelOnline/*") .excludePathPatterns("/apiCoupon/*") + .excludePathPatterns("/apiMerchants/*") ; } diff --git a/v1/src/main/java/com/v1/controller/business/ApiCouponController.java b/v1/src/main/java/com/v1/controller/business/ApiCouponController.java index db784121..16e19089 100644 --- a/v1/src/main/java/com/v1/controller/business/ApiCouponController.java +++ b/v1/src/main/java/com/v1/controller/business/ApiCouponController.java @@ -1,5 +1,6 @@ package com.v1.controller.business; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; @@ -186,11 +187,10 @@ public class ApiCouponController { ApiOrder apiOrder = apiOrderService.findByOrderNo(object.getString("mchOrderNo") , null); - HighOrder highOrder = highOrderService.getOrderByOrderNo(apiOrder.getOrderNo()); HighChildOrder childOrder = highOrder.getHighChildOrderList().get(0); - // 派发停车券 + // 查询卡券 ApiCoupon apiCoupon = apiCouponService.findCoupon(childOrder.getGoodsSpecName()); if (apiCoupon.getType().equals(1)) { @@ -199,16 +199,15 @@ public class ApiCouponController { PetroConfig.init(2); } - JSONObject jsonObject = petroConfig.couponDetail(apiOrder.getExt3()); + JSONObject jsonObject = petroConfig.couponDetail(apiOrder.getExt3() , highOrder.getMemPhone()); - if (!jsonObject.getString("code").equals("1")) { + if (!jsonObject.getString("resultCode").equals("0000")) { throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "当前订单未查询到!"); } - - String data = PetroConfig.decrypt(jsonObject.getString("biz_content")); + String data = PetroConfig.decrypt(jsonObject.getString("jsonResult")); JSONObject jsonData = JSONObject.parseObject(data); - jsonData.put("out_trade_no" , object.getString("mchOrderNo")); + jsonData.put("mchOrderNo" , object.getString("mchOrderNo")); return ResponseMsgUtil.success(jsonData); @@ -218,5 +217,89 @@ public class ApiCouponController { } } + @RequestMapping(value = "/getCheckCode", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "获取核销码") + public ResponseData getCheckCode(@RequestBody JSONObject object , HttpServletRequest request) { + try { + + String ip; + // 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for + if (request.getHeader("x-forwarded-for") == null) { + ip = request.getRemoteAddr(); + } else { + ip = request.getHeader("x-forwarded-for"); + } + + if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) { + log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!"); + } + + if ( + StringUtils.isBlank(object.getString("mchOrderNo")) || + StringUtils.isBlank(object.getString("sign")) || + StringUtils.isBlank(object.getString("timetable")) || + StringUtils.isBlank(object.getString("merchId")) + ) { + log.error("createOrder error!", "请求参数校验失败!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR); + } + + ApiMerchants apiMerchants = apiMerchantsService.findByMchId(object.getString("merchId")); + + if (apiMerchants == null) { + log.error("getRechargeProduct error!", "帐户错误!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_NOT_EXIST); + } + + if (!secConfigService.isConfig(OrderProductType.PRODUCT_TYPE18.getApiCode(), object.getString("merchId"))) { + log.error("getAllCities error!", "当前帐户无权限查询!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOT_AUTHORIZED, ""); + } + + if (!ToolConfig.timetableCheck(15L , object.getLong("timetable"))) { + log.error("getRechargeProduct error!", "请求时间超过15分钟!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.TIME_OUT); + } + + Map map = new HashMap<>(); + map.put("mchOrderNo" , object.getString("mchOrderNo")); + map.put("apiKey" , apiMerchants.getApiKey()); + map.put("timetable" , object.getString("timetable")); + map.put("merchId" , object.getString("merchId")); + + if (!secConfigService.isSignVerify(map, object.getString("sign"))) { + log.error("createOrder error!", "签名校验失败!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY); + } + + + ApiOrder apiOrder = apiOrderService.findByOrderNo(object.getString("mchOrderNo") , null); + + HighOrder highOrder = highOrderService.getOrderByOrderNo(apiOrder.getOrderNo()); + HighChildOrder childOrder = highOrder.getHighChildOrderList().get(0); + + // 查询卡券 + ApiCoupon apiCoupon = apiCouponService.findCoupon(childOrder.getGoodsSpecName()); + + if (apiCoupon.getType().equals(1)) { + PetroConfig.init(1); + } else { + PetroConfig.init(2); + } + + JSONObject jsonObject = petroConfig.getCheckCode(highOrder.getHighChildOrderList().get(0).getExt6() , highOrder.getMemPhone()); + String data = PetroConfig.decrypt(jsonObject.getString("jsonResult")); + + return ResponseMsgUtil.success(JSONObject.parseObject(data)); + + } catch (Exception e) { + log.error("HighOpenApiController --> createOrder() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + }