From 95f98b2a217e36a40aa41dae4b7313a4a7cec773 Mon Sep 17 00:00:00 2001 From: Sum1Dream <418471657@qq.com> Date: Mon, 16 Oct 2023 17:11:08 +0800 Subject: [PATCH] 1 --- .../bweb/controller/HighTestController.java | 2 +- .../cweb/controller/CmsContentController.java | 1 - .../cweb/controller/HighGasController.java | 98 ++++++- .../web/controller/OrderPayController.java | 12 +- .../com/hai/schedule/HighGasSchedule.java | 250 +++++++++--------- .../java/com/hai/config/CommonSysConfig.java | 4 + .../main/java/com/hai/config/DianConfig.java | 149 +++++++++++ .../com/hai/entity/HighGasChannelConfig.java | 2 +- .../java/com/hai/enum_type/GasChannel.java | 1 + .../enum_type/MerchantStoreSourceType.java | 1 + .../impl/OrderPayBeforeServiceImpl.java | 6 + .../impl/OrderPaySuccessServiceImpl.java | 11 + .../pay/channel/huipay/config/HuiConfig.java | 6 +- .../java/com/hai/service/HighGasService.java | 6 + .../HighGasDiscountOilPriceServiceImpl.java | 68 +++++ .../hai/service/impl/HighGasServiceImpl.java | 115 +++++++- .../resources/dev/commonConfig.properties | 5 + .../prod-9401/commonConfig.properties | 6 + .../resources/prod/commonConfig.properties | 6 + 19 files changed, 608 insertions(+), 141 deletions(-) create mode 100644 hai-service/src/main/java/com/hai/config/DianConfig.java 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 e178542f..f24d300e 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.HuiLianTongUnionCardConfig; import com.hai.config.TuanYouConfig; 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.math.BigDecimal; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/test") @Api(value = "订单接口") public class HighTestController { private static Logger log = LoggerFactory.getLogger(HighTestController.class); @Resource private OrderService orderService; @Resource private HighUserCardService highUserCardService; @Resource private HighOrderService highOrderService; @Resource private HighUserService highUserService; @Resource private HighMerchantService highMerchantService; @Resource private HighMerchantStoreService highMerchantStoreService; @Resource private HighGasOilPriceService highGasOilPriceService; @Resource private HuiConfig huiConfig; @RequestMapping(value="/resolveResponse",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "解析") public ResponseData resolveResponse( @RequestParam(name = "data", required = false) String data ) { try { JSONObject cardInfoObject = HuiLianTongUnionCardConfig.resolveResponse(data); return ResponseMsgUtil.success(cardInfoObject); } catch (Exception e) { log.error("getUserByTelephone",e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getHuiLianTongCardConsume", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询汇联通工会卡消费记录") public ResponseData getHuiLianTongCardConsume(@RequestParam(name = "businessType", required = true) String businessType, @RequestParam(name = "cardNo", required = true) String cardNo, @RequestParam(name = "sdate", required = true) Long sdate, @RequestParam(name = "edate", required = true) Long edate, @RequestParam(name = "pageNum", required = true) Integer pageNum, @RequestParam(name = "pageSize", required = true) Integer pageSize, HttpServletRequest request) { try { JSONObject consumptionRecord = HuiLianTongUnionCardConfig.queryConsumptionRecordByBusiness(businessType, cardNo, sdate, edate, pageNum, pageSize); if (StringUtils.isBlank(consumptionRecord.getString("data"))) { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQUEST_ERROR, ""); } JSONArray array = HuiLianTongUnionCardConfig.resolveResponse(consumptionRecord.getString("data")).getJSONArray("records"); return ResponseMsgUtil.success(array); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardConsume() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/createOrder", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "创建订单") public ResponseData createOrder(@RequestBody JSONObject object) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("timetable" , new Date().getTime()); mapPost.put("orderNo" , "TEST" + OrderUtil.generateOrderNo()); mapPost.put("productType" , object.getString("productType")); mapPost.put("content" , object.getJSONObject("content").toString()); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/order/createOrder" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/payOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "支付订单") public ResponseData payOrder(@RequestParam(name = "mchOrderNo", required = true) String mchOrderNo) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("mchOrderNo" , mchOrderNo); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("mchOrderNo" , mchOrderNo); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/order/orderPay" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryOrderDetail", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询订单详情") public ResponseData queryOrderDetail(@RequestParam(name = "mchOrderNo", required = true) String mchOrderNo) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("mchOrderNo" , mchOrderNo); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("mchOrderNo" , mchOrderNo); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/order/queryOrderDetail" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/deposit", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "工会卡充值") public ResponseData deposit(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); HighChildOrder highChildOrder = order.getHighChildOrderList().get(0); if (order.getOrderStatus() != 2) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单状态错误"); } // 汇联通充值 String goodsDesc = "汇联通充值"+order.getPayPrice()+"元"; String tranDesc = ""; String businessType = "ghk_deposit"; String orderNoAgain = OrderUtil.generateOrderNo(); order.setOrderStatus(Integer.valueOf(3)); order.setRemarks("工会卡再次充值订单号" + orderNoAgain); highOrderService.updateOrder(order); // 汇联通卡充值 JSONObject deposit = HuiLianTongUnionCardConfig.deposit(orderNoAgain, highChildOrder.getGoodsSpecName(), order.getPayPrice(), businessType, order.getPaySerialNo(), goodsDesc); return ResponseMsgUtil.success( HuiLianTongUnionCardConfig.resolveResponse(deposit.getString("data"))); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getHuiLianTongCardByCardNo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据卡号查询汇联通工会卡详情") public ResponseData getHuiLianTongCardByCardNo(@RequestParam(name = "cardNo", required = true) String cardNo) { try { // 查询工会卡 JSONObject cardInfo = HuiLianTongUnionCardConfig.queryBalance(cardNo); JSONObject resolveResponse = HuiLianTongUnionCardConfig.resolveResponse(cardInfo.getString("data")); return ResponseMsgUtil.success(resolveResponse); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardByCardNo() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/consumption", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "工会卡支付") public ResponseData consumption(@RequestParam(name = "payRealPrice", required = true) BigDecimal payRealPrice, @RequestParam(name = "cardNo", required = true) String cardNo) { try { String goodsDesc = ""; String tranDesc = ""; String instCode = "11101527"; String businessType = "hisen_consume"; // 工会卡支付 JSONObject consumption = HuiLianTongUnionCardConfig.consumption(OrderUtil.generateOrderNo(), cardNo, payRealPrice, businessType, instCode, goodsDesc, tranDesc); if (!consumption.getString("respCode").equals("0000")) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumption.getString("respMessage")); } // 响应参数 JSONObject consumptionResult = HuiLianTongUnionCardConfig.resolveResponse(consumption.getString("data")); if (consumptionResult.getBoolean("success") != true) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumptionResult.getString("message")); } return ResponseMsgUtil.success(consumptionResult); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardByCardNo() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/refundOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "工会卡退款") public ResponseData refundOrder(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); if (order.getOrderStatus() != 2) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单状态错误"); } orderService.refundOrder(order, OrderProductType.getDataByType(order.getProductType()).getName() + "退款",OrderRefundOpUserType.TYPE1, null, "系统自动退款"); if (order.getProductType().equals(4)) { HighUser user = highUserService.findByUserId(order.getMemId()); // 获取应退款积分 int integralNum = order.getTotalPrice().multiply(new BigDecimal(100)).intValue(); if ( integralNum> user.getGold()) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "积分数量不足"); } String remark = "订单" + order.getOrderNo() + "退还积分:" + integralNum; // 积分退款 highUserService.goldHandle(user.getId(), integralNum,2, 3, order.getId() , remark , order.getOrderNo()); } return ResponseMsgUtil.success("退款成功"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/externalOrderRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "对外订单退款") public ResponseData externalOrderRefund(@RequestParam(name = "paySerialNo", required = true) String paySerialNo, @RequestParam(name = "WxMchId", required = true) String WxMchId, @RequestParam(name = "payRealPrice", required = true) String payRealPrice) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "B94B5E62807FA56A7260AB581D8A1B48"); mapPost.put("merchId" , "20230394901"); mapPost.put("paySerialNo" , paySerialNo); mapPost.put("wxMchId" , WxMchId); mapPost.put("payRealPrice" , payRealPrice); mapPost.put("refundPrice" , payRealPrice); Map map = new HashMap<>(); map.put("apiKey" , "B94B5E62807FA56A7260AB581D8A1B48"); map.put("merchId" , "20230394901"); map.put("paySerialNo" , paySerialNo); map.put("wxMchId" , WxMchId); map.put("payRealPrice" , payRealPrice); map.put("refundPrice" , payRealPrice); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("https://hsg.dctpay.com/v1/order/externalOrderRefund" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getBlxCouponBalance", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询停车券") public ResponseData getBlxCouponBalance(@RequestParam(name = "phone", required = true) String phone) { try { highUserCardService.getBlxCouponBalance(phone); return ResponseMsgUtil.success("object"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryJsParking", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询捷顺停车场") public ResponseData queryJsParking(@RequestParam(name = "gps", required = true) String gps) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("gps" , gps); mapPost.put("range" , "1000"); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/queryJsParking" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getUserCouponPage", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询捷顺停车场") public ResponseData getUserCouponPage(@RequestParam(name = "phone", required = true) String phone) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("phone" , phone); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/getUserCouponPage" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryJsOrderList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询车牌订单列表信息") public ResponseData queryJsOrderList(@RequestParam(name = "carNo", required = true) String carNo, @RequestParam(name = "orderStatus", required = true) String orderStatus) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("orderStatus" , orderStatus); mapPost.put("carNo" , carNo); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/queryJsOrderList" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getCouponList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询车牌订单列表信息") public ResponseData getCouponList() { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2 FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/getCouponList" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/sendCoupon", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "发放券") public ResponseData sendCoupon(@RequestParam(name = "couponCode", required = true) String couponCode, @RequestParam(name = "receiverCount", required = true) String receiverCount, @RequestParam(name = "receiverPhone", required = true) String receiverPhone) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/getCouponList" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/preorder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "发起支付") public ResponseData preorder() { try { JSONObject object = new JSONObject(); object.put("outTradeNo" , "HUI" + OrderUtil.generateOrderNo()); object.put("transType" , "JSAPI"); object.put("payMode" , "WECHAT"); object.put("totalAmount" , "0.01"); object.put("profitSharing" , 0); object.put("subject" , "测试"); object.put("userId" , "oUGn_4unIjp90MY-oEXluY4laDrQ"); return ResponseMsgUtil.success(huiConfig.preorder(object)); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryGasInfoListByPage", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询团油门店") public ResponseData queryGasInfoListByPage() { try { HighMerchantModel merchant = highMerchantService.getMerchantById(39L); if (merchant == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到商户"); } JSONObject jsonObjectP = TuanYouConfig.queryGasInfoListByPage(1, 1000); JSONObject resultObjectP = jsonObjectP.getObject("result", JSONObject.class); for (int i = 1; i <= resultObjectP.getInteger("totalPageNum").intValue();i++) { JSONObject jsonObject = TuanYouConfig.queryGasInfoListByPage(i, 1000); JSONObject resultObject = jsonObject.getObject("result", JSONObject.class); JSONArray jsonArray = resultObject.getJSONArray("gasInfoList"); HighMerchantStore highMerchantStore; HighGasOilPrice highGasOilPrice; for (Object gasObject : jsonArray) { JSONObject object = JSONObject.parseObject(JSONObject.toJSONString(gasObject)); HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreByKey(object.getString("gasId")); if (store != null) { store.setType(1); store.setSourceType(2); store.setMerchantId(merchant.getId()); store.setCompanyId(merchant.getCompanyId()); store.setStoreKey(object.getString("gasId")); store.setStoreName(object.getString("gasName")); store.setStoreLogo(object.getString("gasLogoSmall")); store.setRegionId(object.getLong("provinceCode")); store.setRegionName(object.getString("provinceName")); store.setAddress(object.getString("gasAddress")); store.setLongitude(object.getString("gasAddressLongitude")); store.setLatitude(object.getString("gasAddressLatitude")); store.setStatus(object.getInteger("gasStatus")); store.setPrestoreType(0); store.setOperatorId(0L); store.setOperatorName("系统创建"); store.setUpdateTime(new Date()); store.setExt1(object.getString("gasSourceId")); highMerchantStoreService.updateMerchantStoreDetail(store); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); // 查询门店油号 highGasOilPrice = highGasOilPriceService.getGasOilPriceByStoreAndOilNo(store.getId(), oilPriceObject.getString("oilNo")); if (highGasOilPrice == null) { highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getString("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); highGasOilPrice.setStatus(GasOilPriceStatusEnum.status1.getStatus()); } else { highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getString("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); } highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } else { highMerchantStore = new HighMerchantStore(); highMerchantStore.setType(1); highMerchantStore.setSourceType(2); highMerchantStore.setMerchantId(merchant.getId()); highMerchantStore.setCompanyId(merchant.getCompanyId()); highMerchantStore.setStoreKey(object.getString("gasId")); highMerchantStore.setStoreName(object.getString("gasName")); highMerchantStore.setStoreLogo(object.getString("gasLogoSmall")); highMerchantStore.setRegionId(object.getLong("provinceCode")); highMerchantStore.setRegionName(object.getString("provinceName")); highMerchantStore.setAddress(object.getString("gasAddress")); highMerchantStore.setLongitude(object.getString("gasAddressLongitude")); highMerchantStore.setLatitude(object.getString("gasAddressLatitude")); highMerchantStore.setStatus(1); highMerchantStore.setPrestoreType(0); highMerchantStore.setOperatorId(0L); highMerchantStore.setOperatorName("系统创建"); highMerchantStore.setCreateTime(new Date()); highMerchantStore.setUpdateTime(new Date()); highMerchantStore.setExt1(object.getString("gasSourceId")); HighMerchantStoreModel merchantStoreModel = new HighMerchantStoreModel(); BeanUtils.copyProperties(highMerchantStore, merchantStoreModel); highMerchantStoreService.insertMerchantStore(merchantStoreModel); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(merchantStoreModel.getId()); highGasOilPrice.setOilNo(oilPriceObject.getString("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } } } return ResponseMsgUtil.success("完成"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } } \ 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.DianConfig; import com.hai.config.HuiLianTongUnionCardConfig; import com.hai.config.TuanYouConfig; import com.hai.entity.*; import com.hai.enum_type.GasOilPriceStatusEnum; import com.hai.model.HighMerchantModel; import com.hai.model.HighMerchantStoreModel; import com.hai.model.ResponseData; import com.hai.openApi.config.BlxConfig; import com.hai.order.service.OrderService; import com.hai.order.type.OrderProductType; import com.hai.order.type.OrderRefundOpUserType; import com.hai.order.utils.OrderUtil; import com.hai.pay.channel.huipay.config.HuiConfig; import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.bouncycastle.LICENSE; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.io.FileOutputStream; import java.io.InputStream; import java.math.BigDecimal; import java.net.URL; import java.net.URLConnection; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/test") @Api(value = "订单接口") public class HighTestController { private static Logger log = LoggerFactory.getLogger(HighTestController.class); @Resource private OrderService orderService; @Resource private HighUserCardService highUserCardService; @Resource private HighOrderService highOrderService; @Resource private HighUserService highUserService; @Resource private HighMerchantService highMerchantService; @Resource private HighMerchantStoreService highMerchantStoreService; @Resource private HighGasOilPriceService highGasOilPriceService; @Resource private HuiConfig huiConfig; @Resource private CommonService commonService; @RequestMapping(value="/resolveResponse",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "解析") public ResponseData resolveResponse( @RequestParam(name = "data", required = false) String data ) { try { JSONObject cardInfoObject = HuiLianTongUnionCardConfig.resolveResponse(data); return ResponseMsgUtil.success(cardInfoObject); } catch (Exception e) { log.error("getUserByTelephone",e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getHuiLianTongCardConsume", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询汇联通工会卡消费记录") public ResponseData getHuiLianTongCardConsume(@RequestParam(name = "businessType", required = true) String businessType, @RequestParam(name = "cardNo", required = true) String cardNo, @RequestParam(name = "sdate", required = true) Long sdate, @RequestParam(name = "edate", required = true) Long edate, @RequestParam(name = "pageNum", required = true) Integer pageNum, @RequestParam(name = "pageSize", required = true) Integer pageSize, HttpServletRequest request) { try { JSONObject consumptionRecord = HuiLianTongUnionCardConfig.queryConsumptionRecordByBusiness(businessType, cardNo, sdate, edate, pageNum, pageSize); if (StringUtils.isBlank(consumptionRecord.getString("data"))) { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQUEST_ERROR, ""); } JSONArray array = HuiLianTongUnionCardConfig.resolveResponse(consumptionRecord.getString("data")).getJSONArray("records"); return ResponseMsgUtil.success(array); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardConsume() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/createOrder", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "创建订单") public ResponseData createOrder(@RequestBody JSONObject object) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("timetable" , new Date().getTime()); mapPost.put("orderNo" , "TEST" + OrderUtil.generateOrderNo()); mapPost.put("productType" , object.getString("productType")); mapPost.put("content" , object.getJSONObject("content").toString()); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/order/createOrder" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/payOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "支付订单") public ResponseData payOrder(@RequestParam(name = "mchOrderNo", required = true) String mchOrderNo) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("mchOrderNo" , mchOrderNo); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("mchOrderNo" , mchOrderNo); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/order/orderPay" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryOrderDetail", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询订单详情") public ResponseData queryOrderDetail(@RequestParam(name = "mchOrderNo", required = true) String mchOrderNo) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("mchOrderNo" , mchOrderNo); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("mchOrderNo" , mchOrderNo); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/order/queryOrderDetail" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/deposit", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "工会卡充值") public ResponseData deposit(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); HighChildOrder highChildOrder = order.getHighChildOrderList().get(0); if (order.getOrderStatus() != 2) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单状态错误"); } // 汇联通充值 String goodsDesc = "汇联通充值"+order.getPayPrice()+"元"; String tranDesc = ""; String businessType = "ghk_deposit"; String orderNoAgain = OrderUtil.generateOrderNo(); order.setOrderStatus(Integer.valueOf(3)); order.setRemarks("工会卡再次充值订单号" + orderNoAgain); highOrderService.updateOrder(order); // 汇联通卡充值 JSONObject deposit = HuiLianTongUnionCardConfig.deposit(orderNoAgain, highChildOrder.getGoodsSpecName(), order.getPayPrice(), businessType, order.getPaySerialNo(), goodsDesc); return ResponseMsgUtil.success( HuiLianTongUnionCardConfig.resolveResponse(deposit.getString("data"))); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getHuiLianTongCardByCardNo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据卡号查询汇联通工会卡详情") public ResponseData getHuiLianTongCardByCardNo(@RequestParam(name = "cardNo", required = true) String cardNo) { try { // 查询工会卡 JSONObject cardInfo = HuiLianTongUnionCardConfig.queryBalance(cardNo); JSONObject resolveResponse = HuiLianTongUnionCardConfig.resolveResponse(cardInfo.getString("data")); return ResponseMsgUtil.success(resolveResponse); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardByCardNo() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/consumption", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "工会卡支付") public ResponseData consumption(@RequestParam(name = "payRealPrice", required = true) BigDecimal payRealPrice, @RequestParam(name = "cardNo", required = true) String cardNo) { try { String goodsDesc = ""; String tranDesc = ""; String instCode = "11101527"; String businessType = "hisen_consume"; // 工会卡支付 JSONObject consumption = HuiLianTongUnionCardConfig.consumption(OrderUtil.generateOrderNo(), cardNo, payRealPrice, businessType, instCode, goodsDesc, tranDesc); if (!consumption.getString("respCode").equals("0000")) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumption.getString("respMessage")); } // 响应参数 JSONObject consumptionResult = HuiLianTongUnionCardConfig.resolveResponse(consumption.getString("data")); if (consumptionResult.getBoolean("success") != true) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumptionResult.getString("message")); } return ResponseMsgUtil.success(consumptionResult); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardByCardNo() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/refundOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "工会卡退款") public ResponseData refundOrder(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); if (order.getOrderStatus() != 2) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单状态错误"); } orderService.refundOrder(order, OrderProductType.getDataByType(order.getProductType()).getName() + "退款",OrderRefundOpUserType.TYPE1, null, "系统自动退款"); if (order.getProductType().equals(4)) { HighUser user = highUserService.findByUserId(order.getMemId()); // 获取应退款积分 int integralNum = order.getTotalPrice().multiply(new BigDecimal(100)).intValue(); if ( integralNum> user.getGold()) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "积分数量不足"); } String remark = "订单" + order.getOrderNo() + "退还积分:" + integralNum; // 积分退款 highUserService.goldHandle(user.getId(), integralNum,2, 3, order.getId() , remark , order.getOrderNo()); } return ResponseMsgUtil.success("退款成功"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/externalOrderRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "对外订单退款") public ResponseData externalOrderRefund(@RequestParam(name = "paySerialNo", required = true) String paySerialNo, @RequestParam(name = "WxMchId", required = true) String WxMchId, @RequestParam(name = "payRealPrice", required = true) String payRealPrice) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "B94B5E62807FA56A7260AB581D8A1B48"); mapPost.put("merchId" , "20230394901"); mapPost.put("paySerialNo" , paySerialNo); mapPost.put("wxMchId" , WxMchId); mapPost.put("payRealPrice" , payRealPrice); mapPost.put("refundPrice" , payRealPrice); Map map = new HashMap<>(); map.put("apiKey" , "B94B5E62807FA56A7260AB581D8A1B48"); map.put("merchId" , "20230394901"); map.put("paySerialNo" , paySerialNo); map.put("wxMchId" , WxMchId); map.put("payRealPrice" , payRealPrice); map.put("refundPrice" , payRealPrice); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("https://hsg.dctpay.com/v1/order/externalOrderRefund" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getBlxCouponBalance", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询停车券") public ResponseData getBlxCouponBalance(@RequestParam(name = "phone", required = true) String phone) { try { highUserCardService.getBlxCouponBalance(phone); return ResponseMsgUtil.success("object"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryJsParking", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询捷顺停车场") public ResponseData queryJsParking(@RequestParam(name = "gps", required = true) String gps) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("gps" , gps); mapPost.put("range" , "1000"); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/queryJsParking" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getUserCouponPage", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询捷顺停车场") public ResponseData getUserCouponPage(@RequestParam(name = "phone", required = true) String phone) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("phone" , phone); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/getUserCouponPage" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryJsOrderList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询车牌订单列表信息") public ResponseData queryJsOrderList(@RequestParam(name = "carNo", required = true) String carNo, @RequestParam(name = "orderStatus", required = true) String orderStatus) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("orderStatus" , orderStatus); mapPost.put("carNo" , carNo); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/queryJsOrderList" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getCouponList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询车牌订单列表信息") public ResponseData getCouponList() { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2 FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/getCouponList" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/sendCoupon", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "发放券") public ResponseData sendCoupon(@RequestParam(name = "couponCode", required = true) String couponCode, @RequestParam(name = "receiverCount", required = true) String receiverCount, @RequestParam(name = "receiverPhone", required = true) String receiverPhone) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/getCouponList" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/preorder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "发起支付") public ResponseData preorder() { try { JSONObject object = new JSONObject(); object.put("outTradeNo" , "HUI" + OrderUtil.generateOrderNo()); object.put("transType" , "JSAPI"); object.put("payMode" , "WECHAT"); object.put("totalAmount" , "0.01"); object.put("profitSharing" , 0); object.put("subject" , "测试"); object.put("userId" , "oUGn_4unIjp90MY-oEXluY4laDrQ"); return ResponseMsgUtil.success(huiConfig.preorder(object)); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryGasInfoListByPage", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询团油门店") public ResponseData queryGasInfoListByPage() { try { HighMerchantModel merchant = highMerchantService.getMerchantById(39L); if (merchant == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到商户"); } JSONObject jsonObjectP = TuanYouConfig.queryGasInfoListByPage(1, 1000); JSONObject resultObjectP = jsonObjectP.getObject("result", JSONObject.class); for (int i = 1; i <= resultObjectP.getInteger("totalPageNum").intValue();i++) { JSONObject jsonObject = TuanYouConfig.queryGasInfoListByPage(i, 1000); JSONObject resultObject = jsonObject.getObject("result", JSONObject.class); JSONArray jsonArray = resultObject.getJSONArray("gasInfoList"); HighMerchantStore highMerchantStore; HighGasOilPrice highGasOilPrice; for (Object gasObject : jsonArray) { JSONObject object = JSONObject.parseObject(JSONObject.toJSONString(gasObject)); HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreByKey(object.getString("gasId")); if (store != null) { store.setType(1); store.setSourceType(2); store.setMerchantId(merchant.getId()); store.setCompanyId(merchant.getCompanyId()); store.setStoreKey(object.getString("gasId")); store.setStoreName(object.getString("gasName")); store.setStoreLogo(object.getString("gasLogoSmall")); store.setRegionId(object.getLong("provinceCode")); store.setRegionName(object.getString("provinceName")); store.setAddress(object.getString("gasAddress")); store.setLongitude(object.getString("gasAddressLongitude")); store.setLatitude(object.getString("gasAddressLatitude")); store.setStatus(object.getInteger("gasStatus")); store.setPrestoreType(0); store.setOperatorId(0L); store.setOperatorName("系统创建"); store.setUpdateTime(new Date()); store.setExt1(object.getString("gasSourceId")); highMerchantStoreService.updateMerchantStoreDetail(store); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); // 查询门店油号 highGasOilPrice = highGasOilPriceService.getGasOilPriceByStoreAndOilNo(store.getId(), oilPriceObject.getString("oilNo")); if (highGasOilPrice == null) { highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getString("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); highGasOilPrice.setStatus(GasOilPriceStatusEnum.status1.getStatus()); } else { highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getString("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); } highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } else { highMerchantStore = new HighMerchantStore(); highMerchantStore.setType(1); highMerchantStore.setSourceType(2); highMerchantStore.setMerchantId(merchant.getId()); highMerchantStore.setCompanyId(merchant.getCompanyId()); highMerchantStore.setStoreKey(object.getString("gasId")); highMerchantStore.setStoreName(object.getString("gasName")); highMerchantStore.setStoreLogo(object.getString("gasLogoSmall")); highMerchantStore.setRegionId(object.getLong("provinceCode")); highMerchantStore.setRegionName(object.getString("provinceName")); highMerchantStore.setAddress(object.getString("gasAddress")); highMerchantStore.setLongitude(object.getString("gasAddressLongitude")); highMerchantStore.setLatitude(object.getString("gasAddressLatitude")); highMerchantStore.setStatus(1); highMerchantStore.setPrestoreType(0); highMerchantStore.setOperatorId(0L); highMerchantStore.setOperatorName("系统创建"); highMerchantStore.setCreateTime(new Date()); highMerchantStore.setUpdateTime(new Date()); highMerchantStore.setExt1(object.getString("gasSourceId")); HighMerchantStoreModel merchantStoreModel = new HighMerchantStoreModel(); BeanUtils.copyProperties(highMerchantStore, merchantStoreModel); highMerchantStoreService.insertMerchantStore(merchantStoreModel); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(merchantStoreModel.getId()); highGasOilPrice.setOilNo(oilPriceObject.getString("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } } } return ResponseMsgUtil.success("完成"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/test", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "测试") public ResponseData test() { try { JSONObject jsonObject = DianConfig.orderRefund("2023101615205322380"); 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); } } } \ No newline at end of file diff --git a/hai-cweb/src/main/java/com/cweb/controller/CmsContentController.java b/hai-cweb/src/main/java/com/cweb/controller/CmsContentController.java index e3273ac2..ef1cdc71 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/CmsContentController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/CmsContentController.java @@ -67,7 +67,6 @@ public class CmsContentController { SessionObject sessionObject = userCenter.getSessionObjectByCms(request); HighUserModel userInfoModel = new HighUserModel(); - System.out.println("sessionObject============" + sessionObject); if (sessionObject != null) { // 用户 diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighGasController.java b/hai-cweb/src/main/java/com/cweb/controller/HighGasController.java index 8c5433f5..89aa0b3d 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighGasController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighGasController.java @@ -11,6 +11,7 @@ import com.hai.common.utils.CoordCommonUtil; import com.hai.common.utils.PageUtil; import com.hai.common.utils.ResponseMsgUtil; import com.hai.config.CommonSysConst; +import com.hai.config.DianConfig; import com.hai.config.TuanYouConfig; import com.hai.dao.HighGasOrderPushMapper; import com.hai.entity.*; @@ -169,7 +170,7 @@ public class HighGasController { } } - } else if (MapUtils.getInteger(map, "source_type").equals(2)) { + } else if (MapUtils.getInteger(map, "source_type").equals(2)|| MapUtils.getInteger(map, "source_type").equals(6)) { // 查询是否配置了【油站的】优惠比例 HighTyAgentPrice tyAgentPrice = tyAgentPriceService.getDetail(1, MapUtils.getLong(map, "id"), MapUtils.getString(map, "oil_no")); if (tyAgentPrice != null) { @@ -452,6 +453,101 @@ public class HighGasController { return ResponseMsgUtil.success(jsonObject.get("result")); } throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, jsonObject.getString("message")); + } else if (store.getSourceType().equals(MerchantStoreSourceType.type6.getNumber())) { + JSONObject jsonObject = DianConfig.getGasInfoByGasId(storeKey); + if (jsonObject != null && jsonObject.getString("code").equals("200")) { + JSONArray object = jsonObject.getJSONArray("result"); + + JSONObject data = JSONObject.parseObject(JSONObject.toJSONString(object.get(0))); + JSONObject result = new JSONObject(); + + result.put("gasLogoSmall" , data.getString("tupian")); + result.put("gasAddress" , data.getString("dizhi")); + result.put("gasName" , data.getString("mingcheng")); + result.put("gasAddress" , data.getString("dizhi")); + result.put("goodsId", store.getId()); + result.put("gasId", data.getString("jyzid")); + result.put("gasAddressLatitude", data.getString("lat")); + result.put("gasAddressLongitude", data.getString("lng")); + + // 原始油品价格 + JSONArray originalOilPriceList = data.getJSONArray("oilPriceList"); + JSONArray gasGunList = data.getJSONArray("gasGunList"); + + + // 新油品价格 + JSONArray newOilPriceList = new JSONArray(); + JSONArray newGunList = new JSONArray(); + + for (Object gunObject: gasGunList) { + JSONObject gun = JSON.parseObject(JSONObject.toJSONString(gunObject), JSONObject.class); + gun.put("gunNo" , gun.getString("youqiang")); + gun.put("oilNo" , gun.getString("youhao")); + gun.put("oilNoName" , gun.getString("youhao") + "#"); + newGunList.add(gun); + } + + // 处理油品价格 + for (Object oilPriceObject : originalOilPriceList) { + JSONObject price = JSON.parseObject(JSONObject.toJSONString(oilPriceObject), JSONObject.class); + price.put("oilTypeName" , price.getString("oiltype").equals("1") ? "汽油": "柴油"); + price.put("oilNoName" , price.getString("youhao") + "#"); + price.put("priceOfficial" , price.getString("priceGun")); + price.put("oilNo" , price.getString("youhao")); + price.put("oilType" , price.getString("oiltype")); + + // 查询油站油品状态 + HighGasOilPrice oilNo = highGasOilPriceService.getGasOilPriceByStoreAndOilNo(store.getId(), price.getString("youhao")); + if (oilNo != null && !oilNo.getStatus().equals(GasOilPriceStatusEnum.status1.getStatus())) { + continue; + } + // 查询是否配置了【油站的】优惠比例 + HighTyAgentPrice tyAgentPrice = tyAgentPriceService.getDetail(1, store.getId(), price.getString("youhao")); + if (tyAgentPrice != null) { + // 优惠比例 / 100 = 最终优惠比例 + BigDecimal priceRate = tyAgentPrice.getPriceRate().divide(new BigDecimal("100").setScale(2, BigDecimal.ROUND_DOWN)); + // 油品国标价 * 最终优惠比例 + price.put("priceVip", price.getBigDecimal("priceGun").multiply(priceRate).setScale(2, BigDecimal.ROUND_HALF_UP)); + } else { + // 查询是否配置了【油品】优惠比例 + HighGasDiscountOilPrice gasDiscountOilPrice = gasDiscountOilPriceService.getDetailByOilNo(price.getString("youhao")); + if (gasDiscountOilPrice != null) { + // 优惠比例 / 100 = 最终优惠比例 + BigDecimal priceRate = gasDiscountOilPrice.getPriceRate().divide(new BigDecimal("100").setScale(2, BigDecimal.ROUND_DOWN)); + // 油品国标价 * 最终优惠比例 + price.put("priceVip", price.getBigDecimal("priceGun").multiply(priceRate).setScale(2, BigDecimal.ROUND_HALF_UP)); + } + } + + // 查询是否配置了【代理商油站】优惠比例 + if (isTyAgent != null && isTyAgent == true) { + HighTyAgentPrice agentPrice = tyAgentPriceService.getDetail(2, store.getId(), price.getString("youhao")); + if (agentPrice != null) { + // 优惠比例 / 100 = 最终优惠比例 + BigDecimal priceRate = agentPrice.getPriceRate().divide(new BigDecimal("100").setScale(2, BigDecimal.ROUND_DOWN)); + // 油品国标价 * 最终优惠比例 + price.put("priceVip", price.getBigDecimal("priceGun").multiply(priceRate).setScale(2, BigDecimal.ROUND_HALF_UP)); + } + } + newOilPriceList.add(price); + } + + + + result.put("oilPriceList" , newOilPriceList); + result.put("gasGunList" , newGunList); + + if (StringUtils.isNotBlank(longitude) && StringUtils.isNotBlank(latitude)) { + // 距离 + double distance = CoordCommonUtil.getDistance(Double.valueOf(result.get("gasAddressLatitude").toString()), Double.valueOf(result.get("gasAddressLongitude").toString()), Double.valueOf(latitude), Double.valueOf(longitude)); + result.put("distance", Math.round(distance/100d)/10d); + } else { + result.put("distance", null); + } + + return ResponseMsgUtil.success(result); + } + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, jsonObject.getString("message")); } throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到加油站"); 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 fee3f758..89ffc696 100644 --- a/hai-order/src/main/java/com/web/controller/OrderPayController.java +++ b/hai-order/src/main/java/com/web/controller/OrderPayController.java @@ -281,6 +281,16 @@ public class OrderPayController { weChatPayReqInfo.setSub_mch_id(gasChannelConfig.getPayPlatformMerNo()); profitSharing = gasChannelConfig.getProfitSharingStatus().equals(true) ? "Y" : "N"; + } else if (store.getSourceType().equals(MerchantStoreSourceType.type6.getNumber())) { + + // 查询支付配置 + HighGasChannelConfig gasChannelConfig = gasChannelConfigService.getConfig(GasChannel.type2, GasChannelPayPlatformType.type1); + if (gasChannelConfig == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未配置支付参数,请稍后重试!"); + } + weChatPayReqInfo.setSub_mch_id(gasChannelConfig.getPayPlatformMerNo()); + profitSharing = gasChannelConfig.getProfitSharingStatus().equals(true) ? "Y" : "N"; + } else { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未配置支付参数,请稍后重试!"); } @@ -325,8 +335,6 @@ public class OrderPayController { payMap.put("api_key", SysConst.getSysConfig().getWxPayApiKey()); payMap.put("unified_order_url", SysConst.getSysConfig().getWxPayUnifiedOrderUrl()); - - sortedMap = wechatPayUtil.goWechatPay(weChatPayReqInfo, payMap); order.setAccountMerchantNum(weChatPayReqInfo.getSub_mch_id()); diff --git a/hai-schedule/src/main/java/com/hai/schedule/HighGasSchedule.java b/hai-schedule/src/main/java/com/hai/schedule/HighGasSchedule.java index 82894bb8..ecfde80d 100644 --- a/hai-schedule/src/main/java/com/hai/schedule/HighGasSchedule.java +++ b/hai-schedule/src/main/java/com/hai/schedule/HighGasSchedule.java @@ -5,10 +5,8 @@ import com.alibaba.fastjson.JSONObject; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; -import com.hai.config.PayloService; import com.hai.config.TuanYouConfig; import com.hai.entity.HighGasOilPrice; -import com.hai.entity.HighGasOilPriceOfficial; import com.hai.entity.HighMerchantStore; import com.hai.enum_type.GasOilPriceStatusEnum; import com.hai.model.HighMerchantModel; @@ -39,137 +37,131 @@ public class HighGasSchedule { @Resource private HighGasService gasService; - @Scheduled(cron = "0 0 1 * * ?") //每日凌晨1点执行一次 - public void certification() throws Exception { - 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); - } - } - } - } - } - - @Scheduled(cron = "5 0 0 * * ?") // 每日凌晨00:00:5执行一次 - public void getJiaHaoYouAllStation() throws Exception { - gasService.getJiaHaoYouAllStation(); - } +// @Scheduled(cron = "0 0 1 * * ?") //每日凌晨1点执行一次 +// public void certification() throws Exception { +// HighMerchantModel merchant = highMerchantService.getMerchantById(63L); +// 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("jyzid")); +// highMerchantStore.setStoreName(object.getString("mingcheng")); +// highMerchantStore.setStoreLogo(object.getString("tupian")); +// highMerchantStore.setRegionName(object.getString("province")); +// highMerchantStore.setAddress(object.getString("dizhi")); +// 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); +// } +// } +// } +// } +// } + +// @Scheduled(cron = "5 0 0 * * ?") // 每日凌晨00:00:5执行一次 +// public void getJiaHaoYouAllStation() throws Exception { +// gasService.getJiaHaoYouAllStation(); +// } + +// @Scheduled(cron = "5 0 0 * * ?") // 每日凌晨00:00:5执行一次 +// public void getPayloAllStation() throws Exception { +// gasService.getPayloAllStation(); +// } @Scheduled(cron = "5 0 0 * * ?") // 每日凌晨00:00:5执行一次 - public void getPayloAllStation() throws Exception { - gasService.getPayloAllStation(); + public void getDianAllStation() throws Exception { + gasService.getDianAllStation(); } - /* @Scheduled(cron = "0 1 0 * * ?") //每日凌晨12点01分执行一次 - public void getJinZhuAllStation() throws Exception { - gasService.getJinZhuAllStation(); - }*/ - - /* @Scheduled(cron = "0 30 7 * * ?") //每日7点1分执行一次 - public void refreshPriceOfficial() throws Exception { - gasOilPriceOfficialService.refreshPriceOfficial(); - - gasOilPriceOfficialService.refreshGasPriceOfficial(null, null); - }*/ } 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 73b52722..529c410b 100644 --- a/hai-service/src/main/java/com/hai/config/CommonSysConfig.java +++ b/hai-service/src/main/java/com/hai/config/CommonSysConfig.java @@ -138,4 +138,8 @@ public class CommonSysConfig { private String blxPostUrl; + private String diandianwPostUrl; + private String diandianwAppid; + private String diandianwAppSecret; + } diff --git a/hai-service/src/main/java/com/hai/config/DianConfig.java b/hai-service/src/main/java/com/hai/config/DianConfig.java new file mode 100644 index 00000000..ddb2fb90 --- /dev/null +++ b/hai-service/src/main/java/com/hai/config/DianConfig.java @@ -0,0 +1,149 @@ +package com.hai.config; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.hai.common.utils.HttpsUtils; +import com.hai.common.utils.MD5Util; +import org.apache.commons.codec.binary.Base64; + +import javax.crypto.Cipher; +import javax.crypto.KeyGenerator; +import javax.crypto.spec.SecretKeySpec; +import java.nio.charset.StandardCharsets; +import java.security.SecureRandom; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + + +public class DianConfig { + + private static final String ALGORITHMS = "AES/ECB/PKCS5Padding"; + /** + * 静态常量 + */ + private static final String AES = "AES"; + + /** + * @Author Sum1Dream + * @Name getGasInfoAll + * @Description // 获取(全量)油站信息 + * @Date 14:47 2023/10/11 + * @return com.alibaba.fastjson.JSONObject + */ + public static JSONObject getGasInfoAll() { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("jyzid" , "ALL"); + JSONObject paramMap = new JSONObject(); + paramMap.put("appid", CommonSysConst.getSysConfig().getDiandianwAppid()); + paramMap.put("postInfo", aesEncrypt(jsonObject.toJSONString() , CommonSysConst.getSysConfig().getDiandianwAppSecret())); + return HttpsUtils.doGet(CommonSysConst.getSysConfig().getDiandianwPostUrl()+"/otherUnit/Interface_getJyzInfoAll.html" , paramMap); + } + + /** + * @Author Sum1Dream + * @Name getGasInfoByGasId + * @Description // 根据油站 id 拉取最新的油站数据 + * @Date 16:40 2023/10/11 + * @Param gasId + * @return com.alibaba.fastjson.JSONObject + */ + public static JSONObject getGasInfoByGasId(String gasId) { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("jyzid" , gasId); + JSONObject paramMap = new JSONObject(); + paramMap.put("appid", CommonSysConst.getSysConfig().getDiandianwAppid()); + paramMap.put("postInfo", aesEncrypt(jsonObject.toJSONString() , CommonSysConst.getSysConfig().getDiandianwAppSecret())); + return HttpsUtils.doGet(CommonSysConst.getSysConfig().getDiandianwPostUrl()+"otherUnit/Interface_getJyzInfoById.html" , paramMap); + } + + /** + * @Author Sum1Dream + * @Name refuelingOrderPush + * @Description // 推送订单 + * @Date 15:29 2023/10/12 + * @Param object + * @return com.alibaba.fastjson.JSONObject + */ + public static JSONObject refuelingOrderPush(JSONObject object) { + JSONObject paramMap = new JSONObject(); + paramMap.put("appid", CommonSysConst.getSysConfig().getDiandianwAppid()); + paramMap.put("postInfo", aesEncrypt(object.toJSONString() , CommonSysConst.getSysConfig().getDiandianwAppSecret())); + return HttpsUtils.doGet(CommonSysConst.getSysConfig().getDiandianwPostUrl()+"otherUnit/Interface_nl_orderPush.html" , paramMap); + } + + /** + * @Author Sum1Dream + * @Name queryCompanyPriceDetail + * @Description // + * @Date 16:28 2023/10/12 + * @Param gasId + * @Param oilNo + * @return com.alibaba.fastjson.JSONObject + */ + public static JSONObject queryCompanyPriceDetail(String gasId , String oilNo) { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("jyzid" , gasId); + jsonObject.put("youhao" , oilNo); + JSONObject paramMap = new JSONObject(); + paramMap.put("appid", CommonSysConst.getSysConfig().getDiandianwAppid()); + paramMap.put("postInfo", aesEncrypt(jsonObject.toJSONString() , CommonSysConst.getSysConfig().getDiandianwAppSecret())); + return HttpsUtils.doGet(CommonSysConst.getSysConfig().getDiandianwPostUrl()+"otherUnit/Interface_getPriceInfoById.html" , paramMap); + } + + /** + * @Author Sum1Dream + * @ClassName DianConfig + * @Description // 5.根据订单 ID 查询订单结果 + * @Date 2023/10/16 15:25 + **/ + public static JSONObject getOrderDetail( String orderNo) { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("orderid" , orderNo); + JSONObject paramMap = new JSONObject(); + paramMap.put("appid", CommonSysConst.getSysConfig().getDiandianwAppid()); + paramMap.put("postInfo", aesEncrypt(jsonObject.toJSONString() , CommonSysConst.getSysConfig().getDiandianwAppSecret())); + return HttpsUtils.doGet(CommonSysConst.getSysConfig().getDiandianwPostUrl()+"otherUnit/Interface_getOrderResultById.html" , paramMap); + } + + + public static JSONObject orderRefund( String orderNo) { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("orderid" , orderNo); + JSONObject paramMap = new JSONObject(); + paramMap.put("appid", CommonSysConst.getSysConfig().getDiandianwAppid()); + paramMap.put("postInfo", aesEncrypt(jsonObject.toJSONString() , CommonSysConst.getSysConfig().getDiandianwAppSecret())); + return HttpsUtils.doGet(CommonSysConst.getSysConfig().getDiandianwPostUrl()+"otherUnit/Interface_nl_orderRefund.html" , paramMap); + } + + + + /** + * 将字符串【AES加密】为base 64 code + * + * @param content 待加密的内容 + * @return 加密后的base 64 code + */ + public static String aesEncrypt(String content, String key) { + try { + // 创建密码器 + // 密钥 AES加解密要求key必须要128个比特位(这里需要长度为16,否则会报错) + KeyGenerator kgen = KeyGenerator.getInstance("AES"); + kgen.init(128); + // 初始化为加密模式的密码器 + Cipher cipher = Cipher.getInstance(ALGORITHMS); + cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(key.getBytes(), DianConfig.AES)); + + byte[] bytes = cipher.doFinal(content.getBytes(StandardCharsets.UTF_8)); + System.out.println(); + // 使用base64解码 + return Base64.encodeBase64String(bytes); + } catch (Exception e) { + System.err.println(e.getMessage() + e); + } + return null; + } + + +} + diff --git a/hai-service/src/main/java/com/hai/entity/HighGasChannelConfig.java b/hai-service/src/main/java/com/hai/entity/HighGasChannelConfig.java index 640d2019..2b243585 100644 --- a/hai-service/src/main/java/com/hai/entity/HighGasChannelConfig.java +++ b/hai-service/src/main/java/com/hai/entity/HighGasChannelConfig.java @@ -20,7 +20,7 @@ public class HighGasChannelConfig implements Serializable { private Long id; /** - * 渠道id 1:自建站 2:团油 3:加好油 4:金猪加油 + * 渠道id 1:自建站 2:团油 3:加好油 4:金猪加油 6:点点网络 */ private Integer channelId; diff --git a/hai-service/src/main/java/com/hai/enum_type/GasChannel.java b/hai-service/src/main/java/com/hai/enum_type/GasChannel.java index d3b3a341..f120ac43 100644 --- a/hai-service/src/main/java/com/hai/enum_type/GasChannel.java +++ b/hai-service/src/main/java/com/hai/enum_type/GasChannel.java @@ -11,6 +11,7 @@ public enum GasChannel { type3(3 , "加好油"), type4(4 , "金猪加油"), type5(5 , "paylo系统"), + type6(6 , "点点网络"), ; private Integer type; diff --git a/hai-service/src/main/java/com/hai/enum_type/MerchantStoreSourceType.java b/hai-service/src/main/java/com/hai/enum_type/MerchantStoreSourceType.java index d0531b51..29fdd78b 100644 --- a/hai-service/src/main/java/com/hai/enum_type/MerchantStoreSourceType.java +++ b/hai-service/src/main/java/com/hai/enum_type/MerchantStoreSourceType.java @@ -12,6 +12,7 @@ public enum MerchantStoreSourceType { type3(3, "加好油", "重庆壳牌"), type4(4, "金猪加油", "金猪加油"), type5(5, "paylo", "四川壳牌"), + type6(6, "点点网络", "团油"), ; private Integer number; diff --git a/hai-service/src/main/java/com/hai/order/service/impl/OrderPayBeforeServiceImpl.java b/hai-service/src/main/java/com/hai/order/service/impl/OrderPayBeforeServiceImpl.java index 5a91c538..235c8bea 100644 --- a/hai-service/src/main/java/com/hai/order/service/impl/OrderPayBeforeServiceImpl.java +++ b/hai-service/src/main/java/com/hai/order/service/impl/OrderPayBeforeServiceImpl.java @@ -83,6 +83,12 @@ public class OrderPayBeforeServiceImpl implements OrderPayBeforeService { if (gasChannelConfig == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未配置支付参数,请稍后重试!"); } + } else if (store.getSourceType().equals(MerchantStoreSourceType.type6.getNumber())) { + // 查询支付配置 + HighGasChannelConfig gasChannelConfig = gasChannelConfigService.getConfig(GasChannel.type6,GasChannelPayPlatformType.type1 ); + if (gasChannelConfig == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未配置支付参数,请稍后重试!"); + } } else { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未配置支付参数,请稍后重试!"); } 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 2edc8d81..63b86f22 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 @@ -378,6 +378,17 @@ public class OrderPaySuccessServiceImpl implements OrderPaySuccessService { order.getPayablePrice(), order.getTotalDeductionPrice() ); + } else if (gasOrder.getChannelType().equals(MerchantStoreSourceType.type6.getNumber())) { + JSONObject object = new JSONObject(); + object.put("jyzid" , store.getStoreKey()); + object.put("total" , order.getTotalPrice()); + object.put("youhao" , gasOrder.getGasOilNo()); + object.put("youqiang" , gasOrder.getGasGunNo()); + object.put("mobile" , order.getMemPhone()); + object.put("orderid" , order.getOrderNo()); + object.put("priceGun", gasOrder.getGasPriceGun()); // 枪单价 + object.put("priceVip", gasOrder.getGasPriceVip()); // 优惠价 + DianConfig.refuelingOrderPush(object); } } } diff --git a/hai-service/src/main/java/com/hai/pay/channel/huipay/config/HuiConfig.java b/hai-service/src/main/java/com/hai/pay/channel/huipay/config/HuiConfig.java index 0b8ebebf..318e457c 100644 --- a/hai-service/src/main/java/com/hai/pay/channel/huipay/config/HuiConfig.java +++ b/hai-service/src/main/java/com/hai/pay/channel/huipay/config/HuiConfig.java @@ -41,9 +41,11 @@ public class HuiConfig { // 渝北区浩联物资经营部 public final static String hlMerNo = "2023090816465844909"; + public final static String yFMerNo = "2023101109385455305"; // 渝北区浩联物资经营部 public final static String hlKey = "ZatCMLMSZxnkc2rk7dtpTORMLcKetcKt"; + public final static String yFKey = "plfJ6Ohgj4OmPblknuMzoSeT8cvI5dTR"; public final static String hlSubAppid = "wx8d49e2f83025229d"; @@ -56,9 +58,9 @@ public class HuiConfig { * @return java.util.SortedMap */ public SortedMap preorder(JSONObject object) throws Exception { - object.put("merchantNo" , hlMerNo); + object.put("merchantNo" , yFMerNo); object.put("subAppid" , hlSubAppid); - object.put("sign" , SignatureUtil.createSign(object , hlKey)); + object.put("sign" , SignatureUtil.createSign(object , yFKey)); JSONObject jsonObject = HttpsUtils.doPost(postUrl + "trade/preorder", object, new HashMap<>()); // 签名校验 diff --git a/hai-service/src/main/java/com/hai/service/HighGasService.java b/hai-service/src/main/java/com/hai/service/HighGasService.java index c0c03e0f..2f2807f1 100644 --- a/hai-service/src/main/java/com/hai/service/HighGasService.java +++ b/hai-service/src/main/java/com/hai/service/HighGasService.java @@ -21,6 +21,12 @@ public interface HighGasService { */ void getPayloAllStation() throws Exception; + /** + * 团油 + * 获取渠道商【点点网络】全量加油站 + */ + void getDianAllStation() throws Exception; + /** * * 获取渠道商【金猪加油】全量加油站 diff --git a/hai-service/src/main/java/com/hai/service/impl/HighGasDiscountOilPriceServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighGasDiscountOilPriceServiceImpl.java index 5f353f36..13a250af 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighGasDiscountOilPriceServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighGasDiscountOilPriceServiceImpl.java @@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; +import com.hai.config.DianConfig; import com.hai.config.TuanYouConfig; import com.hai.dao.HighGasDiscountOilPriceMapper; import com.hai.entity.*; @@ -154,6 +155,7 @@ public class HighGasDiscountOilPriceServiceImpl implements HighGasDiscountOilPri || store.getSourceType().equals(MerchantStoreSourceType.type3.getNumber()) || store.getSourceType().equals(MerchantStoreSourceType.type4.getNumber()) || store.getSourceType().equals(MerchantStoreSourceType.type5.getNumber()) + || store.getSourceType().equals(MerchantStoreSourceType.type6.getNumber()) ) { // 嗨森逛平台价 油枪价 * 折扣 @@ -271,6 +273,72 @@ public class HighGasDiscountOilPriceServiceImpl implements HighGasDiscountOilPri // 本次优惠 payPriceModel.setTotalPreferences(payPriceModel.getOilLiters().multiply(payPriceModel.getLitersPreferences()).setScale(2, BigDecimal.ROUND_DOWN)); + // 支付价格 + payPriceModel.setPayPrice(oilingPrice.subtract(payPriceModel.getTotalPreferences())); + } else if (store.getSourceType().equals(MerchantStoreSourceType.type6.getNumber())) { + // 查询油站油品价格 + JSONObject oilPriceObject = DianConfig.queryCompanyPriceDetail(store.getStoreKey(), oilNo); + if (oilPriceObject == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到油站价格"); + } + JSONObject priceDetail = oilPriceObject.getJSONObject("result"); + if (priceDetail == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到油站价格"); + } + + // 团油枪价 + priceGun = priceDetail.getBigDecimal("priceGun"); + // 团油优惠价 + priceVip = priceDetail.getBigDecimal("priceVip"); + + // 嗨森逛平台价 国标价 * 折扣 + BigDecimal pricePlatform = priceGun.multiply(discount).setScale(2, BigDecimal.ROUND_HALF_UP); + + // 加油金额 + payPriceModel.setOilingPrice(oilingPrice); + + // 团油枪价 + payPriceModel.setPriceGun(priceGun); + + // 团油优惠价 + payPriceModel.setPriceVip(priceVip); + + // 团油国标价 + payPriceModel.setPriceOfficial(priceOfficial); + + // 油站直降 + payPriceModel.setGasStationDrop(gasStationDrop); + + // 平台补贴 + payPriceModel.setPreferentialMargin(gasOilPrice.getPreferentialMargin()); + + // 平台价 + payPriceModel.setPricePlatform(pricePlatform); + + // 加油升数,计算方式:加油金额 / 枪价 + payPriceModel.setOilLiters(oilingPrice.divide(priceGun, 2, BigDecimal.ROUND_HALF_DOWN)); + + // 平台折扣,我们平台或者代理商设置的折扣 + payPriceModel.setDiscount(discount.compareTo(new BigDecimal("1.00")) == 0 ? new BigDecimal("1.00") : discount); + + // 加油补贴, 计算方式:团油枪价 - 团油VIP价 + // payPriceModel.setOilSubsidy(priceGun.subtract(priceVip)); + + // 折扣,1 -平台折扣 + BigDecimal decimal1 = new BigDecimal("1").subtract(discount); + + // 价格差价 团油枪价 - 团油VIP价 + BigDecimal oilPriceDifferences = priceGun.subtract(priceVip); + + // 每升优惠 团油枪价 *(1-平台折扣)+(国标价-团油VIP价 ) + payPriceModel.setLitersPreferences(priceGun.multiply(decimal1).setScale(2, BigDecimal.ROUND_HALF_UP).add(oilPriceDifferences)); + + // 优惠价格 团油枪价 * 平台折扣 -(国标价-团油VIP价 ) + payPriceModel.setPricePreferences(pricePlatform.subtract(oilPriceDifferences)); + + // 本次优惠 + payPriceModel.setTotalPreferences(payPriceModel.getOilLiters().multiply(payPriceModel.getLitersPreferences()).setScale(2, BigDecimal.ROUND_DOWN)); + // 支付价格 payPriceModel.setPayPrice(oilingPrice.subtract(payPriceModel.getTotalPreferences())); } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighGasServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighGasServiceImpl.java index a1f5be1b..bf82fa9a 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighGasServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighGasServiceImpl.java @@ -6,11 +6,10 @@ import com.alibaba.fastjson.JSONObject; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; -import com.hai.config.CommonSysConst; -import com.hai.config.JinZhuJiaYouService; -import com.hai.config.PayloService; -import com.hai.config.ShellGroupService; +import com.hai.common.utils.ResponseMsgUtil; +import com.hai.config.*; import com.hai.entity.*; +import com.hai.enum_type.GasOilPriceStatusEnum; import com.hai.enum_type.JinZhuJiaYouOilNo; import com.hai.enum_type.MerchantStoreSourceType; import com.hai.model.HighMerchantModel; @@ -460,6 +459,114 @@ public class HighGasServiceImpl implements HighGasService { } } + @Override + public void getDianAllStation() throws Exception { + 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); + } + } + + } + + } + @Override public void getJinZhuAllStation() throws Exception { HighMerchantModel merchant = highMerchantService.getDetailByKey("HF0802153624"); diff --git a/hai-service/src/main/resources/dev/commonConfig.properties b/hai-service/src/main/resources/dev/commonConfig.properties index 78bcfdbe..bd11056e 100644 --- a/hai-service/src/main/resources/dev/commonConfig.properties +++ b/hai-service/src/main/resources/dev/commonConfig.properties @@ -138,3 +138,8 @@ filesystem=https://hsgcs.dctpay.com/filesystem/ # blxPostUrl=https://vertical-formats-gateway.blx.bodata.cn:18443 + +#DianDian +diandianwPostUrl=http://test.diandianw.cn/youdianyou_test/ +diandianwAppid=10071000470d6z3rs80fc537qp7ipr4s +diandianwAppSecret=syz5cfetikr4by6gzxndpubtf6ht6zs5 diff --git a/hai-service/src/main/resources/prod-9401/commonConfig.properties b/hai-service/src/main/resources/prod-9401/commonConfig.properties index 3848450e..d1c6114a 100644 --- a/hai-service/src/main/resources/prod-9401/commonConfig.properties +++ b/hai-service/src/main/resources/prod-9401/commonConfig.properties @@ -122,3 +122,9 @@ filesystem=https://hsg.dctpay.com/filesystem/ blxPostUrl=https://gateway.vf.bilinxing.com + + +#DianDian +diandianwPostUrl=http://www.diandianw.cn/youdianyou/ +diandianwAppid=1016145002rmz7dkti3f5oqh1razswc0 +diandianwAppSecret=msk48q5jinmpsfdgpcyryx6lhkoiii4s \ 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 0aed1961..e3b2ddc0 100644 --- a/hai-service/src/main/resources/prod/commonConfig.properties +++ b/hai-service/src/main/resources/prod/commonConfig.properties @@ -128,3 +128,9 @@ filesystem=https://hsg.dctpay.com/filesystem/ blxPostUrl=https://gateway.vf.bilinxing.com + + +#DianDian +diandianwPostUrl=http://www.diandianw.cn/youdianyou/ +diandianwAppid=1016145002rmz7dkti3f5oqh1razswc0 +diandianwAppSecret=msk48q5jinmpsfdgpcyryx6lhkoiii4s \ No newline at end of file