From 0885e9ad5408541fe530c5d7c81b7af1663ecf92 Mon Sep 17 00:00:00 2001 From: yuanye <418471657@qq.com> Date: Fri, 24 May 2024 09:56:21 +0800 Subject: [PATCH] 1 --- .../bweb/controller/HighTestController.java | 2 +- .../controller/Etc/EtcCustomerController.java | 34 ++++++- .../controller/Goods/GoodsController.java | 2 +- .../business/GoodsOrderController.java | 3 - .../main/java/com/hai/config/EtcService.java | 1 + .../service/OrderCreateHandleService.java | 1 + .../impl/OrderCreateHandleServiceImpl.java | 29 ++++++ .../impl/OrderPaySuccessServiceImpl.java | 14 +++ .../order/service/impl/OrderServiceImpl.java | 6 ++ .../hai/order/type/OrderChildGoodsType.java | 1 + .../com/hai/order/type/OrderProductType.java | 1 + .../com/hai/service/HighOrderService.java | 1 + .../hai/service/impl/HighGasServiceImpl.java | 1 - .../service/impl/HighOrderServiceImpl.java | 29 ++++++ .../main/java/com/v1/config/AuthConfig.java | 3 + .../business/RefuelOnlineController.java | 95 +++++++++++-------- .../com/v1/controller/orderController.java | 3 + 17 files changed, 175 insertions(+), 51 deletions(-) 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 3e04fcdd..7ba91045 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.*; import com.hai.config.*; import com.hai.entity.*; import com.hai.enum_type.GasOilPriceStatusEnum; import com.hai.model.HighMerchantModel; import com.hai.model.HighMerchantStoreModel; import com.hai.model.ResponseData; import com.hai.openApi.config.BlxConfig; import com.hai.openApi.config.PriceComputeConfig; import com.hai.openApi.service.ApiOrderService; import com.hai.order.service.OrderPaySuccessService; import com.hai.order.service.OrderService; import com.hai.order.service.impl.OrderPaySuccessServiceImpl; import com.hai.order.type.OrderPayType; import com.hai.order.type.OrderProductType; import com.hai.order.type.OrderRefundOpUserType; import com.hai.order.type.OrderStatus; 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.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; import java.nio.charset.StandardCharsets; import java.util.*; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/test") @Api(value = "订单接口") public class HighTestController { private static Logger log = LoggerFactory.getLogger(HighTestController.class); @Resource private BsOrderRebateService bsOrderRebateService; @Resource private PetroConfig petroConfig; @Resource private HighGoldRecService highGoldRecService; @Resource private OrderService orderService; @Resource private HighUserCardService highUserCardService; @Resource private HighOrderService highOrderService; @Resource private HighUserService highUserService; @Resource private HighGasService gasService; @Resource private HighMerchantService highMerchantService; @Resource private HighMerchantStoreService highMerchantStoreService; @Resource private HighGasOilPriceService highGasOilPriceService; @Resource private OutRechargeOrderService outRechargeOrderService; @Resource private HuiConfig huiConfig; @Resource private CommonService commonService; @Resource private HighOilCardOrderService highOilCardOrderService; @Resource private HighGasOrderService gasOrderService; @Resource private ShellGroupService shellGroupService; @Resource private HighMerchantStoreService merchantStoreService; @Resource private ApiOrderService apiOrderService; @Resource private ApiMerchantsService apiMerchantsService; @Resource private BlxConfig blxConfig; @Resource private HighGasOilGunNoService gasOilGunNoService; @Autowired private RedisTemplate redisTemplate; @Resource private PriceComputeConfig priceComputeConfig; @Resource private OrderPaySuccessServiceImpl orderPaySuccessService = new OrderPaySuccessServiceImpl(); @RequestMapping(value = "/orderBusHandle", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "") public ResponseData orderBusHandle(@RequestParam(name = "orderNo", required = true) String orderNo) { try { orderPaySuccessService.orderBusHandle(orderService.getOrderDetailByNo(orderNo)); /* HighOrder order = orderService.getOrderDetailByNo(orderNo); if (order != null) { // orderService.refundOrder(orderNo, DateUtil.date2String(new Date(), "yyyy-MM-dd HH:mm:ss")); // order.setRefundTime(new Date()); // orderService.updateOrderData(order); return ResponseMsgUtil.success("修改成功"); }*/ return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("HighUserCardController --> rocketMq() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/gasSyncPayment", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "重庆壳牌推送") public ResponseData gasSyncPayment(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighGasOrder order = gasOrderService.getDetailByOrderNo(orderNo); if (order != null) { // 查询油站 HighMerchantStore store = merchantStoreService.getDetailById(order.getStoreId()); if (store == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到门店"); } return ResponseMsgUtil.success( // 推送加好油 shellGroupService.gasSyncPayment(order.getOrderNo(), store.getStoreKey(), order.getPayTime(), order.getGasRefuelPrice(), order.getGasOilNo(), order.getGasGunNo(), order.getPayPrice(), order.getTotalDeductionPrice() ) ); } return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("HighOrderController --> gasSyncPayment() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value="/resolveResponse",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "解析") public ResponseData resolveResponse( @RequestParam(name = "data", required = false) String data ) { try { JSONObject cardInfoObject = HuiLianTongUnionCardConfig.resolveResponse(data); return ResponseMsgUtil.success(cardInfoObject); } catch (Exception e) { log.error("getUserByTelephone",e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getHuiLianTongCardConsume", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询汇联通工会卡消费记录") public ResponseData getHuiLianTongCardConsume(@RequestParam(name = "businessType", required = true) String businessType, @RequestParam(name = "cardNo", required = true) String cardNo, @RequestParam(name = "sdate", required = true) Long sdate, @RequestParam(name = "edate", required = true) Long edate, @RequestParam(name = "pageNum", required = true) Integer pageNum, @RequestParam(name = "pageSize", required = true) Integer pageSize, HttpServletRequest request) { try { JSONObject consumptionRecord = HuiLianTongUnionCardConfig.queryConsumptionRecordByBusiness(businessType, cardNo, sdate, edate, pageNum, pageSize); if (StringUtils.isBlank(consumptionRecord.getString("data"))) { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQUEST_ERROR, ""); } JSONArray array = HuiLianTongUnionCardConfig.resolveResponse(consumptionRecord.getString("data")).getJSONArray( "records"); return ResponseMsgUtil.success(array); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardConsume() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/createOrder", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "创建订单") public ResponseData createOrder(@RequestBody JSONObject object) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230394901"); mapPost.put("timetable" , new Date().getTime()); mapPost.put("orderNo" , OrderUtil.generateOrderNo()); mapPost.put("productType" , object.getString("productType")); mapPost.put("content" , object.getJSONObject("content").toString()); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "B94B5E62807FA56A7260AB581D8A1B48", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://1.95.43.71: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" , "B94B5E62807FA56A7260AB581D8A1B48"); mapPost.put("merchId" , "20230394901"); mapPost.put("mchOrderNo" , mchOrderNo); Map map = new HashMap<>(); map.put("apiKey" , "B94B5E62807FA56A7260AB581D8A1B48"); map.put("merchId" , "20230394901"); map.put("mchOrderNo" , mchOrderNo); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("https://hsg.dctpay.com/v1/order/orderPay" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryOrderDetail", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询订单详情") public ResponseData queryOrderDetail(@RequestParam(name = "mchOrderNo", required = true) String mchOrderNo) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("mchOrderNo" , mchOrderNo); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("mchOrderNo" , mchOrderNo); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/order/queryOrderDetail" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/deposit", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "工会卡充值") public ResponseData deposit(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); HighChildOrder highChildOrder = order.getHighChildOrderList().get(0); if (order.getOrderStatus() != 2) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单状态错误"); } // 汇联通充值 String goodsDesc = "汇联通充值"+order.getPayPrice()+"元"; String tranDesc = ""; String businessType = "ghk_deposit"; String orderNoAgain = OrderUtil.generateOrderNo(); order.setOrderStatus(Integer.valueOf(3)); order.setRemarks("工会卡再次充值订单号" + orderNoAgain); highOrderService.updateOrder(order); // 汇联通卡充值 JSONObject deposit = HuiLianTongUnionCardConfig.deposit(orderNoAgain, highChildOrder.getGoodsSpecName(), order.getPayPrice(), businessType, order.getPaySerialNo(), goodsDesc); return ResponseMsgUtil.success( HuiLianTongUnionCardConfig.resolveResponse(deposit.getString("data"))); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getHuiLianTongCardByCardNo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据卡号查询汇联通工会卡详情") public ResponseData getHuiLianTongCardByCardNo(@RequestParam(name = "cardNo", required = true) String cardNo) { try { // 查询工会卡 JSONObject cardInfo = HuiLianTongUnionCardConfig.queryBalance(cardNo); JSONObject resolveResponse = HuiLianTongUnionCardConfig.resolveResponse(cardInfo.getString("data")); return ResponseMsgUtil.success(resolveResponse); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardByCardNo() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/consumption", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "工会卡支付") public ResponseData consumption(@RequestParam(name = "payRealPrice", required = true) BigDecimal payRealPrice, @RequestParam(name = "cardNo", required = true) String cardNo) { try { String goodsDesc = ""; String tranDesc = ""; String instCode = "11101652"; String businessType = "hisen_consume"; // 工会卡支付 JSONObject consumption = HuiLianTongUnionCardConfig.consumption(OrderUtil.generateOrderNo(), cardNo, payRealPrice, businessType, instCode, goodsDesc, tranDesc); if (!consumption.getString("respCode").equals("0000")) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumption.getString("respMessage")); } // 响应参数 JSONObject consumptionResult = HuiLianTongUnionCardConfig.resolveResponse(consumption.getString("data")); if (consumptionResult.getBoolean("success") != true) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumptionResult.getString("message")); } return ResponseMsgUtil.success(consumptionResult); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardByCardNo() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/refundOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "工会卡退款") public ResponseData refundOrder(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); if (order.getOrderStatus() != 2) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单状态错误"); } orderService.refundOrder(order, OrderProductType.getDataByType(order.getProductType()).getName() + "退款",OrderRefundOpUserType.TYPE1, null, "系统自动退款"); if (order.getProductType().equals(4)) { HighUser user = highUserService.findByUserId(order.getMemId()); // 获取应退款积分 int integralNum = order.getTotalPrice().multiply(new BigDecimal(100)).intValue(); if ( integralNum> user.getGold()) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "积分数量不足"); } String remark = "订单" + order.getOrderNo() + "退还积分:" + integralNum; // 积分退款 highUserService.goldHandle(user.getId(), integralNum,2, 3, order.getId() , remark , order.getOrderNo()); } return ResponseMsgUtil.success("退款成功"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/externalOrderRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "对外订单退款") public ResponseData externalOrderRefund(@RequestParam(name = "paySerialNo", required = true) String paySerialNo, @RequestParam(name = "WxMchId", required = true) String WxMchId, @RequestParam(name = "payRealPrice", required = true) String payRealPrice) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "B94B5E62807FA56A7260AB581D8A1B48"); mapPost.put("merchId" , "20230394901"); mapPost.put("paySerialNo" , paySerialNo); mapPost.put("wxMchId" , WxMchId); mapPost.put("payRealPrice" , payRealPrice); mapPost.put("refundPrice" , payRealPrice); Map map = new HashMap<>(); map.put("apiKey" , "B94B5E62807FA56A7260AB581D8A1B48"); map.put("merchId" , "20230394901"); map.put("paySerialNo" , paySerialNo); map.put("wxMchId" , WxMchId); map.put("payRealPrice" , payRealPrice); map.put("refundPrice" , payRealPrice); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("https://hsg.dctpay.com/v1/order/externalOrderRefund" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getBlxCouponBalance", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询停车券") public ResponseData getBlxCouponBalance(@RequestParam(name = "phone", required = true) String phone) { try { highUserCardService.getBlxCouponBalance(phone); return ResponseMsgUtil.success("object"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryJsParking", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询捷顺停车场") public ResponseData queryJsParking(@RequestParam(name = "gps", required = true) String gps) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("gps" , gps); mapPost.put("range" , "1000"); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/queryJsParking" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getUserCouponPage", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询捷顺停车场") public ResponseData getUserCouponPage(@RequestParam(name = "phone", required = true) String phone) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("phone" , phone); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/getUserCouponPage" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryJsOrderList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询车牌订单列表信息") public ResponseData queryJsOrderList(@RequestParam(name = "carNo", required = true) String carNo, @RequestParam(name = "orderStatus", required = true) String orderStatus) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("orderStatus" , orderStatus); mapPost.put("carNo" , carNo); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/queryJsOrderList" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/sendCoupon", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "发放券") public ResponseData sendCoupon(@RequestParam(name = "couponCode", required = true) String couponCode, @RequestParam(name = "receiverCount", required = true) Integer receiverCount, @RequestParam(name = "orderNo", required = true) String orderNo, @RequestParam(name = "receiverPhone", required = true) String receiverPhone) { try { // 下单请求 JSONObject rechargeObject = HuiLianTongConfig.recharge(orderNo, receiverCount, couponCode, receiverPhone); if (!rechargeObject.getString("respCode").equals("0000")) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "下单失败"); } JSONObject response = HuiLianTongUnionCardConfig.resolveResponse(rechargeObject.getString("data")); // 购买卡券 JSONObject returnParam = HuiLianTongConfig.costRechargeOrder(response.getJSONObject("data").getString("rechargeOrderId")); if (returnParam != null && returnParam.getString("respCode").equals("0000")) { // 解密 JSONObject jsonObject = HuiLianTongUnionCardConfig.resolveResponse(returnParam.getString("data")); JSONArray dataArray = JSONObject.parseObject(jsonObject.getString("data"), JSONArray.class); return ResponseMsgUtil.success(dataArray); } else { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "下单失败"); } } 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")); JSONArray gasGunList = object.getJSONArray("gasGunList"); 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.setPriceCost(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceGun")); 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.setPriceCost(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceGun")); 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()); } highGasOilPriceService.editGasOilPrice(highGasOilPrice); for (Object o : gasGunList) { JSONObject gunNoObject = (JSONObject) o; HighGasOilGunNo gasOilGunNo = gasOilGunNoService.getDetailByStoreAndGunNo(highGasOilPrice.getMerchantStoreId(), gunNoObject.getString("gunNo")); if (gasOilGunNo == null) { gasOilGunNo = new HighGasOilGunNo(); gasOilGunNo.setGasOilPriceId(highGasOilPrice.getId()); gasOilGunNo.setStoreId(highGasOilPrice.getMerchantStoreId()); gasOilGunNo.setOilNo(highGasOilPrice.getOilNo()); gasOilGunNo.setOilNoName(highGasOilPrice.getOilNoName()); gasOilGunNo.setOilType(highGasOilPrice.getOilType()); gasOilGunNo.setOilTypeName(highGasOilPrice.getOilTypeName()); gasOilGunNo.setGunNo(gunNoObject.getString("gunNo")); gasOilGunNo.setStatus(1); gasOilGunNoService.editGunNo(gasOilGunNo); } } } } 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.setPriceCost(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceGun")); 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()); highGasOilPriceService.editGasOilPrice(highGasOilPrice); for (Object o : gasGunList) { JSONObject gunNoObject = (JSONObject) o; HighGasOilGunNo gasOilGunNo = gasOilGunNoService.getDetailByStoreAndGunNo(highGasOilPrice.getMerchantStoreId(), gunNoObject.getString("gunNo")); if (gasOilGunNo == null) { gasOilGunNo = new HighGasOilGunNo(); gasOilGunNo.setGasOilPriceId(highGasOilPrice.getId()); gasOilGunNo.setStoreId(highGasOilPrice.getMerchantStoreId()); gasOilGunNo.setOilNo(highGasOilPrice.getOilNo()); gasOilGunNo.setOilNoName(highGasOilPrice.getOilNoName()); gasOilGunNo.setOilType(highGasOilPrice.getOilType()); gasOilGunNo.setOilTypeName(highGasOilPrice.getOilTypeName()); gasOilGunNo.setGunNo(gunNoObject.getString("gunNo")); gasOilGunNo.setStatus(1); gasOilGunNoService.editGunNo(gasOilGunNo); } } } } } } return ResponseMsgUtil.success("完成"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/test", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "测试") public ResponseData test(@RequestParam(name = "no", required = true) String no) { try { JSONObject jsonObject = DianConfig.getGasInfoByGasId(no); return ResponseMsgUtil.success(jsonObject); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getGasInfoAll", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取全量油站") public ResponseData getGasInfoAll() { try { HighMerchantModel merchant = highMerchantService.getMerchantById(39L); JSONObject jsonObject = DianConfig.getGasInfoAll(); JSONArray resultObject = jsonObject.getObject("result", JSONArray.class); for (int i = 0; i < resultObject.size();i++) { Object objectData = resultObject.get(i); JSONObject object = JSONObject.parseObject(JSONObject.toJSONString(objectData)); HighMerchantStore highMerchantStore; HighGasOilPrice highGasOilPrice; HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreByKey(object.getString("jyzid")); SecRegion region = commonService.getRegionsByName(object.getString("province")); if (store != null) { store.setType(1); store.setSourceType(6); store.setMerchantId(merchant.getId()); store.setCompanyId(merchant.getCompanyId()); store.setStoreKey(object.getString("jyzid")); store.setStoreName(object.getString("mingcheng")); store.setStoreLogo(object.getString("tupian")); store.setRegionId(region.getRegionId()); store.setRegionName(object.getString("province")); store.setAddress(object.getString("dizhi")); store.setLongitude(object.getString("lng")); store.setLatitude(object.getString("lat")); store.setStatus(object.getInteger("zhuangtai")); store.setPrestoreType(0); store.setOperatorId(0L); store.setOperatorName("系统创建"); store.setUpdateTime(new Date()); store.setExt1(object.getString("gasSourceId")); highMerchantStoreService.updateMerchantStoreDetail(store); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); // 查询门店油号 highGasOilPrice = highGasOilPriceService.getGasOilPriceByStoreAndOilNo(store.getId(), oilPriceObject.getString("youhao")); if (highGasOilPrice == null) { highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getString("youhao")); highGasOilPrice.setOilNoName(oilPriceObject.getString("youhao") + "#"); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oiltype")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oiltype").equals("1") ? "汽油": "柴油"); highGasOilPrice.setStatus(GasOilPriceStatusEnum.status1.getStatus()); } else { highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getString("youhao")); highGasOilPrice.setOilNoName( oilPriceObject.getString("youhao") + "#"); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oiltype")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oiltype").equals("1") ? "汽油": "柴油"); } highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } else { highMerchantStore = new HighMerchantStore(); highMerchantStore.setType(1); highMerchantStore.setSourceType(6); highMerchantStore.setMerchantId(merchant.getId()); highMerchantStore.setCompanyId(merchant.getCompanyId()); highMerchantStore.setStoreKey(object.getString("jyzid")); highMerchantStore.setStoreName(object.getString("mingcheng")); highMerchantStore.setStoreLogo(object.getString("tupian")); highMerchantStore.setRegionId(region.getRegionId()); highMerchantStore.setRegionName(object.getString("province")); highMerchantStore.setAddress(object.getString("dizhi")); highMerchantStore.setLongitude(object.getString("lng")); highMerchantStore.setLatitude(object.getString("lat")); highMerchantStore.setStatus(1); highMerchantStore.setPrestoreType(0); highMerchantStore.setOperatorId(0L); highMerchantStore.setOperatorName("系统创建"); highMerchantStore.setCreateTime(new Date()); highMerchantStore.setUpdateTime(new Date()); highMerchantStore.setExt1(object.getString("gasSourceId")); HighMerchantStoreModel merchantStoreModel = new HighMerchantStoreModel(); BeanUtils.copyProperties(highMerchantStore, merchantStoreModel); highMerchantStoreService.insertMerchantStore(merchantStoreModel); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(merchantStoreModel.getId()); highGasOilPrice.setOilNo(oilPriceObject.getString("youhao")); highGasOilPrice.setOilNoName(oilPriceObject.getString("youhao") + "#"); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oiltype")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oiltype").equals("1") ? "汽油": "柴油"); highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } } return ResponseMsgUtil.success(jsonObject); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getOrderPay", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "getOrderPay") public ResponseData getOrderPay(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOilCardOrder highOilCardOrder = highOilCardOrderService.findOrder(orderNo); highOilCardOrder.setStatus(2); JSONObject object = KytcService.getOrderPay(highOilCardOrder.getThirdOrderNo() , highOilCardOrder.getPrice() , highOilCardOrder.getCardNo()); highOilCardOrder.setExt1(object.toJSONString()); highOilCardOrderService.updateOilCardOrder(highOilCardOrder); return ResponseMsgUtil.success("成功"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getOrderInfo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "getOrderInfo") public ResponseData getOrderInfo(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOilCardOrder highOilCardOrder = highOilCardOrderService.findOrder(orderNo); JSONObject object = KytcService.getOrderInfo(highOilCardOrder.getThirdOrderNo()); highOilCardOrder.setExt2(object.toJSONString()); if (object.getBoolean("State") == true) { JSONObject jsonObject = object.getJSONObject("Data"); if (jsonObject.getInteger("OilOrderState") == 2) { highOilCardOrder.setStatus(3); HighOrder highOrder = highOrderService.getOrderByOrderNo(highOilCardOrder.getOrderNo()); highOrder.setOrderStatus(3); highOrder.getHighChildOrderList().get(0).setChildOrderStatus(3); highOrderService.updateOrder(highOrder); } } highOilCardOrderService.updateOilCardOrder(highOilCardOrder); return ResponseMsgUtil.success("成功"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getLogisticsMsg", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取物流") public ResponseData getLogisticsMsg(@RequestParam(name = "no", required = true) String no) { try { JSONObject jsonObjects = CommonConfig.getLogisticsMsg(no); return ResponseMsgUtil.success(jsonObjects); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } // @RequestMapping(value = "/synCouponRule", method = RequestMethod.GET) // @ResponseBody // @ApiOperation(value = "获取卡券") // public ResponseData synCouponRule() { // try { // return ResponseMsgUtil.success(PetroConfig.synCouponRule()); // } catch (Exception e) { // log.error("HighOrderController --> getBackendToken() error!", e); // return ResponseMsgUtil.exception(e); // } // } // @RequestMapping(value = "/getCoupon", method = RequestMethod.GET) // @ResponseBody // @ApiOperation(value = "卡券下单") // public ResponseData getCoupon() { // try { // // JSONObject jsonObject = PetroConfig.getCoupon("16000443991501" , "18090580471" , OrderUtil.generateOrderNo()); // String data = PetroConfig.decrypt(jsonObject.getString("biz_content")); // JSONObject object = JSONObject.parseObject(data); // // return ResponseMsgUtil.success(object); // } catch (Exception e) { // log.error("HighOrderController --> getBackendToken() error!", e); // return ResponseMsgUtil.exception(e); // } // } @RequestMapping(value = "/deleteOilNo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "删除油品") public ResponseData deleteOilNo() { try { gasService.deleteOilNo(); return ResponseMsgUtil.success("1231243"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getJiaHaoYouAllStation", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "加好油油站刷新") public ResponseData getJiaHaoYouAllStation() { try { gasService.getJiaHaoYouAllStation(); return ResponseMsgUtil.success("1231243"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getDianAllStation", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "点点网络") public ResponseData getDianAllStation() { try { gasService.getDianAllStation(); return ResponseMsgUtil.success("1231243"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() err1or!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/integralRebateOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "积分返利") public ResponseData integralRebateOrder() { try { // 查询满足初步返利条件订单 List order = highOrderService.integralRebateOrder(); for (HighOrder highOrder : order) { // 查询是否存在积分记录 Map map = new HashMap<>(); map.put("goldType", 1); map.put("resType", 4); map.put("userId", highOrder.getMemId()); map.put("resId", highOrder.getId()); List goldRecs = highGoldRecService.getGoldRec(map); // 判断是否重复赠送积分 if (goldRecs.size() == 0) { bsOrderRebateService.insertOrderRebate(highOrder); } highOrder.setWhetherRebate(true); highOrderService.updateOrderDetail(highOrder); } return ResponseMsgUtil.success("1231243"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() err1or!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getApiCoupon", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取卡券") public ResponseData getApiCoupon() { try { // 查询满足初步返利条件订单 List order = highOrderService.integralRebateOrder(); for (HighOrder highOrder : order) { // 查询是否存在积分记录 Map map = new HashMap<>(); map.put("goldType", 1); map.put("resType", 4); map.put("userId", highOrder.getMemId()); map.put("resId", highOrder.getId()); List goldRecs = highGoldRecService.getGoldRec(map); // 判断是否重复赠送积分 if (goldRecs.size() == 0) { bsOrderRebateService.insertOrderRebate(highOrder); } highOrder.setWhetherRebate(true); highOrderService.updateOrderDetail(highOrder); } return ResponseMsgUtil.success("1231243"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() err1or!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/couponDetail", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据订单号查询中石油卡券详情") public ResponseData couponDetail(@RequestParam(name = "mchOrderNo", required = true) String mchOrderNo) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("mchOrderNo" , mchOrderNo); mapPost.put("timetable" , new Date().getTime()); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/apiCoupon/getCheckCode" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getCouponList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取卡券") public ResponseData getCouponList() { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230394901"); mapPost.put("timetable" , new Date().getTime()); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "B94B5E62807FA56A7260AB581D8A1B48", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("https://hsg.dctpay.com/v1/apiCoupon/getCouponList" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/refundApi", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "支付退款") public ResponseData refundApi(@RequestParam(name = "mchOrderNo", required = true) String mchOrderNo) { try { ApiOrder apiOrder = apiOrderService.findByOrderNo(mchOrderNo , null); // 查询APi HighOrder order = highOrderService.getOrderByOrderNo(apiOrder.getOrderNo()); orderService.refundOrder(order, "商户退款退款", OrderRefundOpUserType.TYPE1, null, "系统自动退款"); return ResponseMsgUtil.success("退款成功"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/checkAccountBalance", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询余额") public ResponseData checkAccountBalance() { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20240133101"); // mapPost.put("mchOrderNo" , mchOrderNo); mapPost.put("timetable" , new Date().getTime()); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "1F43EEC88D0F99FC201D81143F9EED85", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("https://hsg.dctpay.com/v1/apiMerchants/checkAccountBalance" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getStationStore", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询油站") public ResponseData getStationStore() { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20240133101"); // mapPost.put("mchOrderNo" , mchOrderNo); // mapPost.put("timetable" , new Date().getTime()); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "1F43EEC88D0F99FC201D81143F9EED85", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("https://hsg.dctpay.com/v1/refuelOnline/getStationStore" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/decryptPetroConfig", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "解码") public ResponseData decryptPetroConfig(@RequestParam(name = "content", required = true) String content) { try { PetroConfig.init(1); String data = PetroConfig.decrypt(content); JSONObject object = JSONObject.parseObject(data); return ResponseMsgUtil.success(object); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/synCouponRule", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "synCouponRule") public ResponseData synCouponRule() { try { PetroConfig.init(2); JSONObject jsonObject = petroConfig.synCouponRule(); String data = PetroConfig.decrypt(jsonObject.getString("jsonResult")); JSONArray jsonArray = JSONArray.parseArray(data); return ResponseMsgUtil.success(jsonArray); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getCoupon", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "getCoupon") public ResponseData getCoupon(@RequestParam(name = "code", required = true) String code) { try { PetroConfig.init(2); // 发放卡券 JSONObject jsonObject = petroConfig.getCoupon(code ,"18090580471"); String data = PetroConfig.decrypt(jsonObject.getString("jsonResult")); JSONObject object = JSONObject.parseObject(data); return ResponseMsgUtil.success(object); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/decrypt", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "decrypt") public ResponseData decrypt(@RequestParam(name = "jsonResult", required = true) String jsonResult) { try { PetroConfig.init(2); String data = PetroConfig.decrypt(jsonResult); JSONObject object = JSONObject.parseObject(data); return ResponseMsgUtil.success(object); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/jNiuGoodsList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "jNiuGoodsList") public ResponseData jNiuGoodsList() { try { JSONObject object = RechargeConfig.jNiuGoodsList(); JSONArray array = object.getJSONArray("data"); List list = new ArrayList<>(); for (int i = 0; i < array.size(); i++) { JSONObject jsonObject = array.getJSONObject(i); JSONArray jsonArray = jsonObject.getJSONArray("goodsOption"); for (int j = 0; j < jsonArray.size(); j++) { JSONObject goodsOption = jsonArray.getJSONObject(j); JSONArray childArray = goodsOption.getJSONArray("child"); for (int t = 0; t < childArray.size(); t++) { JSONObject child = childArray.getJSONObject(j); JSONObject data = new JSONObject(); data.put("title" , jsonObject.getString("sort_title") + goodsOption.getString("name")); data.put("goodsId" , child.getString("goods_id")); data.put("goodsOptionId" , child.getString("goods_option_id")); data.put("platPrice" , child.getString("plat_price")); data.put("officialPrice" , child.getString("official_price")); list.add(data); } } } return ResponseMsgUtil.success(list); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/rechargeOrderByJn", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "rechargeOrderByJn") public ResponseData rechargeOrderByJn() { try { JSONObject object = new JSONObject(); object.put("orderNo", OrderUtil.generateOrderNo()); object.put("option_id", "632"); object.put("phone", "18090580471"); JSONObject returnObject = RechargeConfig.rechargeOrderByJn(object); return ResponseMsgUtil.success(returnObject); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/checkOrderByJn", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "checkOrderByJn") public ResponseData checkOrderByJn(@RequestParam(name = "order_no", required = true) String order_no) { try { JSONObject object = new JSONObject(); object.put("orderNo" , order_no); int status = 0; JSONObject jsonObject = RechargeConfig.checkOrderByJn(object); if (jsonObject.getJSONObject("data") != null) { JSONObject objectData= jsonObject.getJSONObject("data"); // // 10充值中 20充值完成 -10 充值失败 // -1取消,0充值中 ,1充值成功,2充值失败,3部分成功 if (objectData.getInteger("status") == 10) { status = 0; } else if (objectData.getInteger("status") == 20) { status = 1; } else if (objectData.getInteger("status") == -10) { status = 2; } } return ResponseMsgUtil.success(status); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getListRechargeOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "getListRechargeOrder") public ResponseData getListRechargeOrder(@RequestParam(name = "order_no", required = true) String order_no) { try { log.info("处理话费订单定时任务开始"); Map map = new HashMap<>(); map.put("payStatus", String.valueOf(102)); map.put("rechargeStatus", String.valueOf(201)); List orderList = outRechargeOrderService.getListRechargeOrder(map); log.info("处理话费订单条数:" + orderList.size()); if (orderList.size() > 0) { for (OutRechargeOrder order : orderList) { try { outRechargeOrderService.prepaidRechargeHandle(order); } catch (Exception e) { log.info("话费定时任务订单业务出现异常", e); } } } return ResponseMsgUtil.success(""); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/etcOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "etcOrder") public ResponseData etcOrder() { try { String mobile = "18090580471"; Map map = new TreeMap<>(); map.put("requestId" , System.nanoTime()); map.put("channelCode" , CommonSysConst.getSysConfig().getEtcChannelCode()); map.put("timestamp" , new Date().getTime() / 1000); map.put("productNo" , "GZETCFXQD_GZETCCSCP"); map.put("mobile" , RSAUtil.encryptBASE64(RSAUtil.encryptByPublicKey(mobile.getBytes(StandardCharsets.UTF_8), CommonSysConst.getSysConfig().getEtcPublicKey()))); map.put("num" , 1); map.put("thirdOrderId" , OrderUtil.generateOrderNo()); String s = StringUtils.join(map.values(), ""); String sign = RSAUtil.sign(s.getBytes(), CommonSysConst.getSysConfig().getEtcPrivateKey()); map.put("sign", sign); return ResponseMsgUtil.success(petroConfig.etcOrder(map)); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/couJointDist", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "商户派发电子券") public ResponseData couJointDist(@RequestParam(name = "order_no", required = true) String order_no) { try { // 购买卡券 JSONObject returnParam = HuiLianTongConfig.costRechargeOrder(order_no); // 解密 JSONObject jsonObject = HuiLianTongUnionCardConfig.resolveResponse(returnParam.getString("data")); JSONArray dataArray = JSONObject.parseObject(jsonObject.getString("data"), JSONArray.class); return ResponseMsgUtil.success(dataArray); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getCarNo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询车牌订单号") public ResponseData getCarNo(@RequestParam(name = "carNo", required = true) String carNo) { try { JSONObject jsonObject = new JSONObject(); jsonObject.put("carNo" , carNo); jsonObject.put("orderStatus" , "03"); JSONObject data = blxConfig.queryJsOrderList(jsonObject); return ResponseMsgUtil.success(data); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value="/getGasDetailByStoreKey",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据门店key 查询") public ResponseData getGasDetailByStoreKey(@RequestParam(name = "storeKey", required = true) String storeKey) { try { JSONObject jsonObject = TuanYouConfig.queryGasInfoByGasId(storeKey); return ResponseMsgUtil.success(jsonObject.get("result")); } catch (Exception e) { log.error("HighGasController -> getGasDetailByStoreKey() error!",e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value="/getSphCoupon",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取卡券") public ResponseData getSphCoupon() { try { JSONObject jsonObject = PetroCouponConfig.getCouponList(); return ResponseMsgUtil.success(jsonObject); } catch (Exception e) { log.error("HighGasController -> getGasDetailByStoreKey() error!",e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value="/mchBalance",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "处理扣款") public ResponseData mchBalance(@RequestParam(name = "merchId", required = true) String merchId, @RequestParam(name = "mchOrderNo", required = true) String mchOrderNo) { try { ApiMerchants apiMerchants = apiMerchantsService.findByMchId(merchId); ApiOrder apiOrder = apiOrderService.findByOrderNo(mchOrderNo , null); String key = "apiMerchant" + apiMerchants.getMchId(); // 分布式锁占坑 Boolean lock = redisTemplate.opsForValue().setIfAbsent(key, apiOrder.getOrderNo()); HighOrder order = highOrderService.getOrderByOrderNo(apiOrder.getOrderNo()); if(!order.getOrderStatus().equals(OrderStatus.STATUS1.getNumber())) { throw ErrorHelp.genException(SysCode.System, ErrorCode.ORDER_NO_STAY_PAY, ""); } if(Boolean.TRUE.equals(lock)) { // 判断金额是否充足 if (!priceComputeConfig.mchBalance(apiMerchants , apiOrder.getCostPrice() , apiOrder.getMchOrderNo())) { throw ErrorHelp.genException(SysCode.System, ErrorCode.INSUFFICIENT_BALANCE); } } else { // 加锁失败,重试 Thread.sleep(100); mchBalance(merchId , mchOrderNo); } return null; } catch (Exception e) { log.error("HighGasController -> getGasDetailByStoreKey() error!",e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getMerchantStoreList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "下架团油") public ResponseData getMerchantStoreList() { try { // 客户端 Map param = new HashMap<>(); param.put("sourceType", 2); // param.put("regionId", "500000"); // param.put("storeName", "壳牌"); param.put("status", 1); List merchantStoreList = merchantStoreService.getMerchantStoreList(param); for (HighMerchantStore merchantStore : merchantStoreList) { merchantStore.setUpdateTime(new Date()); merchantStore.setStatus(0); merchantStoreService.updateMerchantStoreDetail(merchantStore); } return ResponseMsgUtil.success("成功"); } catch (Exception 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.*; import com.hai.config.*; import com.hai.entity.*; import com.hai.enum_type.GasOilPriceStatusEnum; import com.hai.model.HighMerchantModel; import com.hai.model.HighMerchantStoreModel; import com.hai.model.ResponseData; import com.hai.openApi.config.BlxConfig; import com.hai.openApi.config.PriceComputeConfig; import com.hai.openApi.service.ApiOrderService; import com.hai.order.service.OrderPaySuccessService; import com.hai.order.service.OrderService; import com.hai.order.service.impl.OrderPaySuccessServiceImpl; import com.hai.order.type.OrderPayType; import com.hai.order.type.OrderProductType; import com.hai.order.type.OrderRefundOpUserType; import com.hai.order.type.OrderStatus; 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.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; import java.nio.charset.StandardCharsets; import java.util.*; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/test") @Api(value = "订单接口") public class HighTestController { private static Logger log = LoggerFactory.getLogger(HighTestController.class); @Resource private BsOrderRebateService bsOrderRebateService; @Resource private PetroConfig petroConfig; @Resource private HighGoldRecService highGoldRecService; @Resource private OrderService orderService; @Resource private HighUserCardService highUserCardService; @Resource private HighOrderService highOrderService; @Resource private HighUserService highUserService; @Resource private HighGasService gasService; @Resource private HighMerchantService highMerchantService; @Resource private HighMerchantStoreService highMerchantStoreService; @Resource private HighGasOilPriceService highGasOilPriceService; @Resource private OutRechargeOrderService outRechargeOrderService; @Resource private HuiConfig huiConfig; @Resource private CommonService commonService; @Resource private HighOilCardOrderService highOilCardOrderService; @Resource private HighGasOrderService gasOrderService; @Resource private ShellGroupService shellGroupService; @Resource private HighMerchantStoreService merchantStoreService; @Resource private ApiOrderService apiOrderService; @Resource private ApiMerchantsService apiMerchantsService; @Resource private BlxConfig blxConfig; @Resource private HighGasOilGunNoService gasOilGunNoService; @Autowired private RedisTemplate redisTemplate; @Resource private PriceComputeConfig priceComputeConfig; @Resource private OrderPaySuccessServiceImpl orderPaySuccessService = new OrderPaySuccessServiceImpl(); @RequestMapping(value = "/orderBusHandle", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "") public ResponseData orderBusHandle(@RequestParam(name = "orderNo", required = true) String orderNo) { try { orderPaySuccessService.orderBusHandle(orderService.getOrderDetailByNo(orderNo)); /* HighOrder order = orderService.getOrderDetailByNo(orderNo); if (order != null) { // orderService.refundOrder(orderNo, DateUtil.date2String(new Date(), "yyyy-MM-dd HH:mm:ss")); // order.setRefundTime(new Date()); // orderService.updateOrderData(order); return ResponseMsgUtil.success("修改成功"); }*/ return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("HighUserCardController --> rocketMq() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/gasSyncPayment", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "重庆壳牌推送") public ResponseData gasSyncPayment(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighGasOrder order = gasOrderService.getDetailByOrderNo(orderNo); if (order != null) { // 查询油站 HighMerchantStore store = merchantStoreService.getDetailById(order.getStoreId()); if (store == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到门店"); } return ResponseMsgUtil.success( // 推送加好油 shellGroupService.gasSyncPayment(order.getOrderNo(), store.getStoreKey(), order.getPayTime(), order.getGasRefuelPrice(), order.getGasOilNo(), order.getGasGunNo(), order.getPayPrice(), order.getTotalDeductionPrice() ) ); } return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("HighOrderController --> gasSyncPayment() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value="/resolveResponse",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "解析") public ResponseData resolveResponse( @RequestParam(name = "data", required = false) String data ) { try { JSONObject cardInfoObject = HuiLianTongUnionCardConfig.resolveResponse(data); return ResponseMsgUtil.success(cardInfoObject); } catch (Exception e) { log.error("getUserByTelephone",e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getHuiLianTongCardConsume", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询汇联通工会卡消费记录") public ResponseData getHuiLianTongCardConsume(@RequestParam(name = "businessType", required = true) String businessType, @RequestParam(name = "cardNo", required = true) String cardNo, @RequestParam(name = "sdate", required = true) Long sdate, @RequestParam(name = "edate", required = true) Long edate, @RequestParam(name = "pageNum", required = true) Integer pageNum, @RequestParam(name = "pageSize", required = true) Integer pageSize, HttpServletRequest request) { try { JSONObject consumptionRecord = HuiLianTongUnionCardConfig.queryConsumptionRecordByBusiness(businessType, cardNo, sdate, edate, pageNum, pageSize); if (StringUtils.isBlank(consumptionRecord.getString("data"))) { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQUEST_ERROR, ""); } JSONArray array = HuiLianTongUnionCardConfig.resolveResponse(consumptionRecord.getString("data")).getJSONArray( "records"); return ResponseMsgUtil.success(array); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardConsume() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/createOrder", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "创建订单") public ResponseData createOrder(@RequestBody JSONObject object) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230394901"); mapPost.put("timetable" , new Date().getTime()); mapPost.put("orderNo" , OrderUtil.generateOrderNo()); mapPost.put("productType" , object.getString("productType")); mapPost.put("content" , object.getJSONObject("content").toString()); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "B94B5E62807FA56A7260AB581D8A1B48", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://1.95.43.71: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" , "B94B5E62807FA56A7260AB581D8A1B48"); mapPost.put("merchId" , "20230394901"); mapPost.put("mchOrderNo" , mchOrderNo); Map map = new HashMap<>(); map.put("apiKey" , "B94B5E62807FA56A7260AB581D8A1B48"); map.put("merchId" , "20230394901"); map.put("mchOrderNo" , mchOrderNo); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("https://hsg.dctpay.com/v1/order/orderPay" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryOrderDetail", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询订单详情") public ResponseData queryOrderDetail(@RequestParam(name = "mchOrderNo", required = true) String mchOrderNo) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("mchOrderNo" , mchOrderNo); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("mchOrderNo" , mchOrderNo); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/order/queryOrderDetail" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/deposit", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "工会卡充值") public ResponseData deposit(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); HighChildOrder highChildOrder = order.getHighChildOrderList().get(0); if (order.getOrderStatus() != 2) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单状态错误"); } // 汇联通充值 String goodsDesc = "汇联通充值"+order.getPayPrice()+"元"; String tranDesc = ""; String businessType = "ghk_deposit"; String orderNoAgain = OrderUtil.generateOrderNo(); order.setOrderStatus(Integer.valueOf(3)); order.setRemarks("工会卡再次充值订单号" + orderNoAgain); highOrderService.updateOrder(order); // 汇联通卡充值 JSONObject deposit = HuiLianTongUnionCardConfig.deposit(orderNoAgain, highChildOrder.getGoodsSpecName(), order.getPayPrice(), businessType, order.getPaySerialNo(), goodsDesc); return ResponseMsgUtil.success( HuiLianTongUnionCardConfig.resolveResponse(deposit.getString("data"))); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getHuiLianTongCardByCardNo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据卡号查询汇联通工会卡详情") public ResponseData getHuiLianTongCardByCardNo(@RequestParam(name = "cardNo", required = true) String cardNo) { try { // 查询工会卡 JSONObject cardInfo = HuiLianTongUnionCardConfig.queryBalance(cardNo); JSONObject resolveResponse = HuiLianTongUnionCardConfig.resolveResponse(cardInfo.getString("data")); return ResponseMsgUtil.success(resolveResponse); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardByCardNo() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/consumption", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "工会卡支付") public ResponseData consumption(@RequestParam(name = "payRealPrice", required = true) BigDecimal payRealPrice, @RequestParam(name = "cardNo", required = true) String cardNo) { try { String goodsDesc = ""; String tranDesc = ""; String instCode = "11101652"; String businessType = "hisen_consume"; // 工会卡支付 JSONObject consumption = HuiLianTongUnionCardConfig.consumption(OrderUtil.generateOrderNo(), cardNo, payRealPrice, businessType, instCode, goodsDesc, tranDesc); if (!consumption.getString("respCode").equals("0000")) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumption.getString("respMessage")); } // 响应参数 JSONObject consumptionResult = HuiLianTongUnionCardConfig.resolveResponse(consumption.getString("data")); if (consumptionResult.getBoolean("success") != true) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumptionResult.getString("message")); } return ResponseMsgUtil.success(consumptionResult); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardByCardNo() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/refundOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "工会卡退款") public ResponseData refundOrder(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); if (order.getOrderStatus() != 2) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单状态错误"); } orderService.refundOrder(order, OrderProductType.getDataByType(order.getProductType()).getName() + "退款",OrderRefundOpUserType.TYPE1, null, "系统自动退款"); if (order.getProductType().equals(4)) { HighUser user = highUserService.findByUserId(order.getMemId()); // 获取应退款积分 int integralNum = order.getTotalPrice().multiply(new BigDecimal(100)).intValue(); if ( integralNum> user.getGold()) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "积分数量不足"); } String remark = "订单" + order.getOrderNo() + "退还积分:" + integralNum; // 积分退款 highUserService.goldHandle(user.getId(), integralNum,2, 3, order.getId() , remark , order.getOrderNo()); } return ResponseMsgUtil.success("退款成功"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/externalOrderRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "对外订单退款") public ResponseData externalOrderRefund(@RequestParam(name = "paySerialNo", required = true) String paySerialNo, @RequestParam(name = "WxMchId", required = true) String WxMchId, @RequestParam(name = "payRealPrice", required = true) String payRealPrice) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "B94B5E62807FA56A7260AB581D8A1B48"); mapPost.put("merchId" , "20230394901"); mapPost.put("paySerialNo" , paySerialNo); mapPost.put("wxMchId" , WxMchId); mapPost.put("payRealPrice" , payRealPrice); mapPost.put("refundPrice" , payRealPrice); Map map = new HashMap<>(); map.put("apiKey" , "B94B5E62807FA56A7260AB581D8A1B48"); map.put("merchId" , "20230394901"); map.put("paySerialNo" , paySerialNo); map.put("wxMchId" , WxMchId); map.put("payRealPrice" , payRealPrice); map.put("refundPrice" , payRealPrice); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("https://hsg.dctpay.com/v1/order/externalOrderRefund" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getBlxCouponBalance", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询停车券") public ResponseData getBlxCouponBalance(@RequestParam(name = "phone", required = true) String phone) { try { highUserCardService.getBlxCouponBalance(phone); return ResponseMsgUtil.success("object"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryJsParking", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询捷顺停车场") public ResponseData queryJsParking(@RequestParam(name = "gps", required = true) String gps) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("gps" , gps); mapPost.put("range" , "1000"); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/queryJsParking" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getUserCouponPage", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询捷顺停车场") public ResponseData getUserCouponPage(@RequestParam(name = "phone", required = true) String phone) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("phone" , phone); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/getUserCouponPage" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryJsOrderList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询车牌订单列表信息") public ResponseData queryJsOrderList(@RequestParam(name = "carNo", required = true) String carNo, @RequestParam(name = "orderStatus", required = true) String orderStatus) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("orderStatus" , orderStatus); mapPost.put("carNo" , carNo); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/queryJsOrderList" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/sendCoupon", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "发放券") public ResponseData sendCoupon(@RequestParam(name = "couponCode", required = true) String couponCode, @RequestParam(name = "receiverCount", required = true) Integer receiverCount, @RequestParam(name = "orderNo", required = true) String orderNo, @RequestParam(name = "receiverPhone", required = true) String receiverPhone) { try { // 下单请求 JSONObject rechargeObject = HuiLianTongConfig.recharge(orderNo, receiverCount, couponCode, receiverPhone); if (!rechargeObject.getString("respCode").equals("0000")) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "下单失败"); } JSONObject response = HuiLianTongUnionCardConfig.resolveResponse(rechargeObject.getString("data")); // 购买卡券 JSONObject returnParam = HuiLianTongConfig.costRechargeOrder(response.getJSONObject("data").getString("rechargeOrderId")); if (returnParam != null && returnParam.getString("respCode").equals("0000")) { // 解密 JSONObject jsonObject = HuiLianTongUnionCardConfig.resolveResponse(returnParam.getString("data")); JSONArray dataArray = JSONObject.parseObject(jsonObject.getString("data"), JSONArray.class); return ResponseMsgUtil.success(dataArray); } else { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "下单失败"); } } 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")); JSONArray gasGunList = object.getJSONArray("gasGunList"); 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.setPriceCost(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceGun")); 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.setPriceCost(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceGun")); 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()); } highGasOilPriceService.editGasOilPrice(highGasOilPrice); for (Object o : gasGunList) { JSONObject gunNoObject = (JSONObject) o; HighGasOilGunNo gasOilGunNo = gasOilGunNoService.getDetailByStoreAndGunNo(highGasOilPrice.getMerchantStoreId(), gunNoObject.getString("gunNo")); if (gasOilGunNo == null) { gasOilGunNo = new HighGasOilGunNo(); gasOilGunNo.setGasOilPriceId(highGasOilPrice.getId()); gasOilGunNo.setStoreId(highGasOilPrice.getMerchantStoreId()); gasOilGunNo.setOilNo(highGasOilPrice.getOilNo()); gasOilGunNo.setOilNoName(highGasOilPrice.getOilNoName()); gasOilGunNo.setOilType(highGasOilPrice.getOilType()); gasOilGunNo.setOilTypeName(highGasOilPrice.getOilTypeName()); gasOilGunNo.setGunNo(gunNoObject.getString("gunNo")); gasOilGunNo.setStatus(1); gasOilGunNoService.editGunNo(gasOilGunNo); } } } } 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.setPriceCost(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceGun")); 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()); highGasOilPriceService.editGasOilPrice(highGasOilPrice); for (Object o : gasGunList) { JSONObject gunNoObject = (JSONObject) o; HighGasOilGunNo gasOilGunNo = gasOilGunNoService.getDetailByStoreAndGunNo(highGasOilPrice.getMerchantStoreId(), gunNoObject.getString("gunNo")); if (gasOilGunNo == null) { gasOilGunNo = new HighGasOilGunNo(); gasOilGunNo.setGasOilPriceId(highGasOilPrice.getId()); gasOilGunNo.setStoreId(highGasOilPrice.getMerchantStoreId()); gasOilGunNo.setOilNo(highGasOilPrice.getOilNo()); gasOilGunNo.setOilNoName(highGasOilPrice.getOilNoName()); gasOilGunNo.setOilType(highGasOilPrice.getOilType()); gasOilGunNo.setOilTypeName(highGasOilPrice.getOilTypeName()); gasOilGunNo.setGunNo(gunNoObject.getString("gunNo")); gasOilGunNo.setStatus(1); gasOilGunNoService.editGunNo(gasOilGunNo); } } } } } } return ResponseMsgUtil.success("完成"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/test", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "测试") public ResponseData test(@RequestParam(name = "no", required = true) String no) { try { JSONObject jsonObject = DianConfig.getGasInfoByGasId(no); return ResponseMsgUtil.success(jsonObject); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getGasInfoAll", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取全量油站") public ResponseData getGasInfoAll() { try { HighMerchantModel merchant = highMerchantService.getMerchantById(39L); JSONObject jsonObject = DianConfig.getGasInfoAll(); JSONArray resultObject = jsonObject.getObject("result", JSONArray.class); for (int i = 0; i < resultObject.size();i++) { Object objectData = resultObject.get(i); JSONObject object = JSONObject.parseObject(JSONObject.toJSONString(objectData)); HighMerchantStore highMerchantStore; HighGasOilPrice highGasOilPrice; HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreByKey(object.getString("jyzid")); SecRegion region = commonService.getRegionsByName(object.getString("province")); if (store != null) { store.setType(1); store.setSourceType(6); store.setMerchantId(merchant.getId()); store.setCompanyId(merchant.getCompanyId()); store.setStoreKey(object.getString("jyzid")); store.setStoreName(object.getString("mingcheng")); store.setStoreLogo(object.getString("tupian")); store.setRegionId(region.getRegionId()); store.setRegionName(object.getString("province")); store.setAddress(object.getString("dizhi")); store.setLongitude(object.getString("lng")); store.setLatitude(object.getString("lat")); store.setStatus(object.getInteger("zhuangtai")); store.setPrestoreType(0); store.setOperatorId(0L); store.setOperatorName("系统创建"); store.setUpdateTime(new Date()); store.setExt1(object.getString("gasSourceId")); highMerchantStoreService.updateMerchantStoreDetail(store); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); // 查询门店油号 highGasOilPrice = highGasOilPriceService.getGasOilPriceByStoreAndOilNo(store.getId(), oilPriceObject.getString("youhao")); if (highGasOilPrice == null) { highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getString("youhao")); highGasOilPrice.setOilNoName(oilPriceObject.getString("youhao") + "#"); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oiltype")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oiltype").equals("1") ? "汽油": "柴油"); highGasOilPrice.setStatus(GasOilPriceStatusEnum.status1.getStatus()); } else { highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getString("youhao")); highGasOilPrice.setOilNoName( oilPriceObject.getString("youhao") + "#"); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oiltype")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oiltype").equals("1") ? "汽油": "柴油"); } highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } else { highMerchantStore = new HighMerchantStore(); highMerchantStore.setType(1); highMerchantStore.setSourceType(6); highMerchantStore.setMerchantId(merchant.getId()); highMerchantStore.setCompanyId(merchant.getCompanyId()); highMerchantStore.setStoreKey(object.getString("jyzid")); highMerchantStore.setStoreName(object.getString("mingcheng")); highMerchantStore.setStoreLogo(object.getString("tupian")); highMerchantStore.setRegionId(region.getRegionId()); highMerchantStore.setRegionName(object.getString("province")); highMerchantStore.setAddress(object.getString("dizhi")); highMerchantStore.setLongitude(object.getString("lng")); highMerchantStore.setLatitude(object.getString("lat")); highMerchantStore.setStatus(1); highMerchantStore.setPrestoreType(0); highMerchantStore.setOperatorId(0L); highMerchantStore.setOperatorName("系统创建"); highMerchantStore.setCreateTime(new Date()); highMerchantStore.setUpdateTime(new Date()); highMerchantStore.setExt1(object.getString("gasSourceId")); HighMerchantStoreModel merchantStoreModel = new HighMerchantStoreModel(); BeanUtils.copyProperties(highMerchantStore, merchantStoreModel); highMerchantStoreService.insertMerchantStore(merchantStoreModel); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(merchantStoreModel.getId()); highGasOilPrice.setOilNo(oilPriceObject.getString("youhao")); highGasOilPrice.setOilNoName(oilPriceObject.getString("youhao") + "#"); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oiltype")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oiltype").equals("1") ? "汽油": "柴油"); highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } } return ResponseMsgUtil.success(jsonObject); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getOrderPay", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "getOrderPay") public ResponseData getOrderPay(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOilCardOrder highOilCardOrder = highOilCardOrderService.findOrder(orderNo); highOilCardOrder.setStatus(2); JSONObject object = KytcService.getOrderPay(highOilCardOrder.getThirdOrderNo() , highOilCardOrder.getPrice() , highOilCardOrder.getCardNo()); highOilCardOrder.setExt1(object.toJSONString()); highOilCardOrderService.updateOilCardOrder(highOilCardOrder); return ResponseMsgUtil.success("成功"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getOrderInfo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "getOrderInfo") public ResponseData getOrderInfo(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOilCardOrder highOilCardOrder = highOilCardOrderService.findOrder(orderNo); JSONObject object = KytcService.getOrderInfo(highOilCardOrder.getThirdOrderNo()); highOilCardOrder.setExt2(object.toJSONString()); if (object.getBoolean("State") == true) { JSONObject jsonObject = object.getJSONObject("Data"); if (jsonObject.getInteger("OilOrderState") == 2) { highOilCardOrder.setStatus(3); HighOrder highOrder = highOrderService.getOrderByOrderNo(highOilCardOrder.getOrderNo()); highOrder.setOrderStatus(3); highOrder.getHighChildOrderList().get(0).setChildOrderStatus(3); highOrderService.updateOrder(highOrder); } } highOilCardOrderService.updateOilCardOrder(highOilCardOrder); return ResponseMsgUtil.success("成功"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getLogisticsMsg", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取物流") public ResponseData getLogisticsMsg(@RequestParam(name = "no", required = true) String no) { try { JSONObject jsonObjects = CommonConfig.getLogisticsMsg(no); return ResponseMsgUtil.success(jsonObjects); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } // @RequestMapping(value = "/synCouponRule", method = RequestMethod.GET) // @ResponseBody // @ApiOperation(value = "获取卡券") // public ResponseData synCouponRule() { // try { // return ResponseMsgUtil.success(PetroConfig.synCouponRule()); // } catch (Exception e) { // log.error("HighOrderController --> getBackendToken() error!", e); // return ResponseMsgUtil.exception(e); // } // } // @RequestMapping(value = "/getCoupon", method = RequestMethod.GET) // @ResponseBody // @ApiOperation(value = "卡券下单") // public ResponseData getCoupon() { // try { // // JSONObject jsonObject = PetroConfig.getCoupon("16000443991501" , "18090580471" , OrderUtil.generateOrderNo()); // String data = PetroConfig.decrypt(jsonObject.getString("biz_content")); // JSONObject object = JSONObject.parseObject(data); // // return ResponseMsgUtil.success(object); // } catch (Exception e) { // log.error("HighOrderController --> getBackendToken() error!", e); // return ResponseMsgUtil.exception(e); // } // } @RequestMapping(value = "/deleteOilNo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "删除油品") public ResponseData deleteOilNo() { try { gasService.deleteOilNo(); return ResponseMsgUtil.success("1231243"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getJiaHaoYouAllStation", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "加好油油站刷新") public ResponseData getJiaHaoYouAllStation() { try { gasService.getJiaHaoYouAllStation(); return ResponseMsgUtil.success("1231243"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getDianAllStation", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "点点网络") public ResponseData getDianAllStation() { try { gasService.getDianAllStation(); return ResponseMsgUtil.success("1231243"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() err1or!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/integralRebateOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "积分返利") public ResponseData integralRebateOrder() { try { // 查询满足初步返利条件订单 List order = highOrderService.integralRebateOrder(); for (HighOrder highOrder : order) { // 查询是否存在积分记录 Map map = new HashMap<>(); map.put("goldType", 1); map.put("resType", 4); map.put("userId", highOrder.getMemId()); map.put("resId", highOrder.getId()); List goldRecs = highGoldRecService.getGoldRec(map); // 判断是否重复赠送积分 if (goldRecs.size() == 0) { bsOrderRebateService.insertOrderRebate(highOrder); } highOrder.setWhetherRebate(true); highOrderService.updateOrderDetail(highOrder); } return ResponseMsgUtil.success("1231243"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() err1or!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getApiCoupon", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取卡券") public ResponseData getApiCoupon() { try { // 查询满足初步返利条件订单 List order = highOrderService.integralRebateOrder(); for (HighOrder highOrder : order) { // 查询是否存在积分记录 Map map = new HashMap<>(); map.put("goldType", 1); map.put("resType", 4); map.put("userId", highOrder.getMemId()); map.put("resId", highOrder.getId()); List goldRecs = highGoldRecService.getGoldRec(map); // 判断是否重复赠送积分 if (goldRecs.size() == 0) { bsOrderRebateService.insertOrderRebate(highOrder); } highOrder.setWhetherRebate(true); highOrderService.updateOrderDetail(highOrder); } return ResponseMsgUtil.success("1231243"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() err1or!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/couponDetail", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据订单号查询中石油卡券详情") public ResponseData couponDetail(@RequestParam(name = "mchOrderNo", required = true) String mchOrderNo) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("mchOrderNo" , mchOrderNo); mapPost.put("timetable" , new Date().getTime()); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/apiCoupon/getCheckCode" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getCouponList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取卡券") public ResponseData getCouponList() { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230394901"); mapPost.put("timetable" , new Date().getTime()); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "B94B5E62807FA56A7260AB581D8A1B48", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("https://hsg.dctpay.com/v1/apiCoupon/getCouponList" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/refundApi", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "支付退款") public ResponseData refundApi(@RequestParam(name = "mchOrderNo", required = true) String mchOrderNo) { try { ApiOrder apiOrder = apiOrderService.findByOrderNo(mchOrderNo , null); // 查询APi HighOrder order = highOrderService.getOrderByOrderNo(apiOrder.getOrderNo()); orderService.refundOrder(order, "商户退款退款", OrderRefundOpUserType.TYPE1, null, "系统自动退款"); return ResponseMsgUtil.success("退款成功"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/checkAccountBalance", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询余额") public ResponseData checkAccountBalance() { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20240133101"); // mapPost.put("mchOrderNo" , mchOrderNo); mapPost.put("timetable" , new Date().getTime()); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "1F43EEC88D0F99FC201D81143F9EED85", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("https://hsg.dctpay.com/v1/apiMerchants/checkAccountBalance" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getStationStore", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询油站") public ResponseData getStationStore() { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20240587402"); // mapPost.put("mchOrderNo" , mchOrderNo); // mapPost.put("timetable" , new Date().getTime()); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "1A566F46B57830C45A06AD0AA387435C", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("https://hsg.dctpay.com/v1/refuelOnline/getStationStore" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/decryptPetroConfig", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "解码") public ResponseData decryptPetroConfig(@RequestParam(name = "content", required = true) String content) { try { PetroConfig.init(1); String data = PetroConfig.decrypt(content); JSONObject object = JSONObject.parseObject(data); return ResponseMsgUtil.success(object); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/synCouponRule", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "synCouponRule") public ResponseData synCouponRule() { try { PetroConfig.init(2); JSONObject jsonObject = petroConfig.synCouponRule(); String data = PetroConfig.decrypt(jsonObject.getString("jsonResult")); JSONArray jsonArray = JSONArray.parseArray(data); return ResponseMsgUtil.success(jsonArray); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getCoupon", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "getCoupon") public ResponseData getCoupon(@RequestParam(name = "code", required = true) String code) { try { PetroConfig.init(2); // 发放卡券 JSONObject jsonObject = petroConfig.getCoupon(code ,"18090580471"); String data = PetroConfig.decrypt(jsonObject.getString("jsonResult")); JSONObject object = JSONObject.parseObject(data); return ResponseMsgUtil.success(object); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/decrypt", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "decrypt") public ResponseData decrypt(@RequestParam(name = "jsonResult", required = true) String jsonResult) { try { PetroConfig.init(2); String data = PetroConfig.decrypt(jsonResult); JSONObject object = JSONObject.parseObject(data); return ResponseMsgUtil.success(object); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/jNiuGoodsList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "jNiuGoodsList") public ResponseData jNiuGoodsList() { try { JSONObject object = RechargeConfig.jNiuGoodsList(); JSONArray array = object.getJSONArray("data"); List list = new ArrayList<>(); for (int i = 0; i < array.size(); i++) { JSONObject jsonObject = array.getJSONObject(i); JSONArray jsonArray = jsonObject.getJSONArray("goodsOption"); for (int j = 0; j < jsonArray.size(); j++) { JSONObject goodsOption = jsonArray.getJSONObject(j); JSONArray childArray = goodsOption.getJSONArray("child"); for (int t = 0; t < childArray.size(); t++) { JSONObject child = childArray.getJSONObject(j); JSONObject data = new JSONObject(); data.put("title" , jsonObject.getString("sort_title") + goodsOption.getString("name")); data.put("goodsId" , child.getString("goods_id")); data.put("goodsOptionId" , child.getString("goods_option_id")); data.put("platPrice" , child.getString("plat_price")); data.put("officialPrice" , child.getString("official_price")); list.add(data); } } } return ResponseMsgUtil.success(list); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/rechargeOrderByJn", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "rechargeOrderByJn") public ResponseData rechargeOrderByJn() { try { JSONObject object = new JSONObject(); object.put("orderNo", OrderUtil.generateOrderNo()); object.put("option_id", "632"); object.put("phone", "18090580471"); JSONObject returnObject = RechargeConfig.rechargeOrderByJn(object); return ResponseMsgUtil.success(returnObject); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/checkOrderByJn", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "checkOrderByJn") public ResponseData checkOrderByJn(@RequestParam(name = "order_no", required = true) String order_no) { try { JSONObject object = new JSONObject(); object.put("orderNo" , order_no); int status = 0; JSONObject jsonObject = RechargeConfig.checkOrderByJn(object); if (jsonObject.getJSONObject("data") != null) { JSONObject objectData= jsonObject.getJSONObject("data"); // // 10充值中 20充值完成 -10 充值失败 // -1取消,0充值中 ,1充值成功,2充值失败,3部分成功 if (objectData.getInteger("status") == 10) { status = 0; } else if (objectData.getInteger("status") == 20) { status = 1; } else if (objectData.getInteger("status") == -10) { status = 2; } } return ResponseMsgUtil.success(status); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getListRechargeOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "getListRechargeOrder") public ResponseData getListRechargeOrder(@RequestParam(name = "order_no", required = true) String order_no) { try { log.info("处理话费订单定时任务开始"); Map map = new HashMap<>(); map.put("payStatus", String.valueOf(102)); map.put("rechargeStatus", String.valueOf(201)); List orderList = outRechargeOrderService.getListRechargeOrder(map); log.info("处理话费订单条数:" + orderList.size()); if (orderList.size() > 0) { for (OutRechargeOrder order : orderList) { try { outRechargeOrderService.prepaidRechargeHandle(order); } catch (Exception e) { log.info("话费定时任务订单业务出现异常", e); } } } return ResponseMsgUtil.success(""); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/etcOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "etcOrder") public ResponseData etcOrder() { try { String mobile = "18090580471"; Map map = new TreeMap<>(); map.put("requestId" , System.nanoTime()); map.put("channelCode" , CommonSysConst.getSysConfig().getEtcChannelCode()); map.put("timestamp" , new Date().getTime() / 1000); map.put("productNo" , "GZETCFXQD_GZETCCSCP"); map.put("mobile" , RSAUtil.encryptBASE64(RSAUtil.encryptByPublicKey(mobile.getBytes(StandardCharsets.UTF_8), CommonSysConst.getSysConfig().getEtcPublicKey()))); map.put("num" , 1); map.put("thirdOrderId" , OrderUtil.generateOrderNo()); String s = StringUtils.join(map.values(), ""); String sign = RSAUtil.sign(s.getBytes(), CommonSysConst.getSysConfig().getEtcPrivateKey()); map.put("sign", sign); return ResponseMsgUtil.success(petroConfig.etcOrder(map)); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/couJointDist", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "商户派发电子券") public ResponseData couJointDist(@RequestParam(name = "order_no", required = true) String order_no) { try { // 购买卡券 JSONObject returnParam = HuiLianTongConfig.costRechargeOrder(order_no); // 解密 JSONObject jsonObject = HuiLianTongUnionCardConfig.resolveResponse(returnParam.getString("data")); JSONArray dataArray = JSONObject.parseObject(jsonObject.getString("data"), JSONArray.class); return ResponseMsgUtil.success(dataArray); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getCarNo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询车牌订单号") public ResponseData getCarNo(@RequestParam(name = "carNo", required = true) String carNo) { try { JSONObject jsonObject = new JSONObject(); jsonObject.put("carNo" , carNo); jsonObject.put("orderStatus" , "03"); JSONObject data = blxConfig.queryJsOrderList(jsonObject); return ResponseMsgUtil.success(data); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value="/getGasDetailByStoreKey",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据门店key 查询") public ResponseData getGasDetailByStoreKey(@RequestParam(name = "storeKey", required = true) String storeKey) { try { JSONObject jsonObject = TuanYouConfig.queryGasInfoByGasId(storeKey); return ResponseMsgUtil.success(jsonObject.get("result")); } catch (Exception e) { log.error("HighGasController -> getGasDetailByStoreKey() error!",e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value="/getSphCoupon",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取卡券") public ResponseData getSphCoupon() { try { JSONObject jsonObject = PetroCouponConfig.getCouponList(); return ResponseMsgUtil.success(jsonObject); } catch (Exception e) { log.error("HighGasController -> getGasDetailByStoreKey() error!",e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value="/mchBalance",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "处理扣款") public ResponseData mchBalance(@RequestParam(name = "merchId", required = true) String merchId, @RequestParam(name = "mchOrderNo", required = true) String mchOrderNo) { try { ApiMerchants apiMerchants = apiMerchantsService.findByMchId(merchId); ApiOrder apiOrder = apiOrderService.findByOrderNo(mchOrderNo , null); String key = "apiMerchant" + apiMerchants.getMchId(); // 分布式锁占坑 Boolean lock = redisTemplate.opsForValue().setIfAbsent(key, apiOrder.getOrderNo()); HighOrder order = highOrderService.getOrderByOrderNo(apiOrder.getOrderNo()); if(!order.getOrderStatus().equals(OrderStatus.STATUS1.getNumber())) { throw ErrorHelp.genException(SysCode.System, ErrorCode.ORDER_NO_STAY_PAY, ""); } if(Boolean.TRUE.equals(lock)) { // 判断金额是否充足 if (!priceComputeConfig.mchBalance(apiMerchants , apiOrder.getCostPrice() , apiOrder.getMchOrderNo())) { throw ErrorHelp.genException(SysCode.System, ErrorCode.INSUFFICIENT_BALANCE); } } else { // 加锁失败,重试 Thread.sleep(100); mchBalance(merchId , mchOrderNo); } return null; } catch (Exception e) { log.error("HighGasController -> getGasDetailByStoreKey() error!",e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getMerchantStoreList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "下架团油") public ResponseData getMerchantStoreList() { try { // 客户端 Map param = new HashMap<>(); param.put("sourceType", 2); // param.put("regionId", "500000"); // param.put("storeName", "壳牌"); param.put("status", 1); List merchantStoreList = merchantStoreService.getMerchantStoreList(param); for (HighMerchantStore merchantStore : merchantStoreList) { merchantStore.setUpdateTime(new Date()); merchantStore.setStatus(0); merchantStoreService.updateMerchantStoreDetail(merchantStore); } return ResponseMsgUtil.success("成功"); } catch (Exception e) { return ResponseMsgUtil.exception(e); } } } \ No newline at end of file diff --git a/hai-cweb/src/main/java/com/cweb/controller/Etc/EtcCustomerController.java b/hai-cweb/src/main/java/com/cweb/controller/Etc/EtcCustomerController.java index 64e98f76..0bed5ac7 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/Etc/EtcCustomerController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/Etc/EtcCustomerController.java @@ -14,10 +14,7 @@ import com.hai.etc.EtcCustMsgService; import com.hai.model.HighUserModel; import com.hai.model.ResponseData; import com.hai.model.UserInfoModel; -import com.hai.service.CommonService; -import com.hai.service.HighDiscountPackageDetailsService; -import com.hai.service.HighDiscountPackageService; -import com.hai.service.SecConfigService; +import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; @@ -49,6 +46,9 @@ public class EtcCustomerController { @Resource private SecConfigService secConfigService; + @Resource + private HighOrderService highOrderService; + @Resource private HighDiscountPackageService highDiscountPackageService; @@ -395,7 +395,7 @@ public class EtcCustomerController { @RequestMapping(value = "/getEquity", method = RequestMethod.POST) @ResponseBody - @ApiOperation(value = "签约银行卡代扣") + @ApiOperation(value = "获取优惠券包") public ResponseData getEquity() { try { @@ -421,6 +421,30 @@ public class EtcCustomerController { } + @RequestMapping(value = "/getEtcTrain", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询是否需要支付货车推广费用") + public ResponseData getEtcTrain( HttpServletRequest request + ) { + try { + + SessionObject sessionObject = userCenter.getSessionObject(request); + HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject(); + + Map mapUser = new HashMap<>(); + + mapUser.put("userId" , userInfoModel.getHighUser().getPhone()); + mapUser.put("status" , "2,3"); + + HighOrder order = highOrderService.getOrderByMap(mapUser); + + return ResponseMsgUtil.success(order == null); + + } catch (Exception e) { + log.error("BsMsgController --> getMsgByList() error!", e); + return ResponseMsgUtil.exception(e); + } + } diff --git a/hai-cweb/src/main/java/com/cweb/controller/Goods/GoodsController.java b/hai-cweb/src/main/java/com/cweb/controller/Goods/GoodsController.java index 8cf3577b..69c51225 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/Goods/GoodsController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/Goods/GoodsController.java @@ -130,7 +130,7 @@ public class GoodsController { @RequestMapping(value = "/getListGoodsDetailByHome", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询商品列表") - public ResponseData getListGoodsDetail( + public ResponseData getListGoodsDetailByHome( @RequestParam(value = "goodsTypeId", required = false) String goodsTypeId, @RequestParam(value = "title", required = false) String title, @RequestParam(value = "companyId", required = false) Long companyId diff --git a/hai-order/src/main/java/com/web/controller/business/GoodsOrderController.java b/hai-order/src/main/java/com/web/controller/business/GoodsOrderController.java index 0d1fa1eb..b70866d3 100644 --- a/hai-order/src/main/java/com/web/controller/business/GoodsOrderController.java +++ b/hai-order/src/main/java/com/web/controller/business/GoodsOrderController.java @@ -152,9 +152,6 @@ public class GoodsOrderController { } } - - - @RequestMapping(value="/getGoodsOrderDetail",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询订单详情") diff --git a/hai-service/src/main/java/com/hai/config/EtcService.java b/hai-service/src/main/java/com/hai/config/EtcService.java index 8eeaead2..1ccd1781 100644 --- a/hai-service/src/main/java/com/hai/config/EtcService.java +++ b/hai-service/src/main/java/com/hai/config/EtcService.java @@ -82,6 +82,7 @@ public class EtcService { vehInfoListObject.put("vehPlateColor" , etcCarMsg.getVehPlateColor()); vehInfoListObject.put("vehType" , etcCarMsg.getVehType()); vehInfoListObject.put("wheelsNum" , etcCarMsg.getWheelsNum()); + vehInfoListObject.put("axlesNum" , etcCarMsg.getAxlesNum()); vehInfoListObject.put("drivLicMainFro" , convertToBase64(etcCarMsg.getDrivlicMainFro())); vehInfoListObject.put("drivLicSubFro" , convertToBase64(etcCarMsg.getDrivlicSubFro())); vehInfoListObject.put("headStockPhoto" , convertToBase64(etcCarMsg.getHeadStockPhoto())); diff --git a/hai-service/src/main/java/com/hai/order/service/OrderCreateHandleService.java b/hai-service/src/main/java/com/hai/order/service/OrderCreateHandleService.java index ab396ae2..7dc4d3b8 100644 --- a/hai-service/src/main/java/com/hai/order/service/OrderCreateHandleService.java +++ b/hai-service/src/main/java/com/hai/order/service/OrderCreateHandleService.java @@ -149,5 +149,6 @@ public interface OrderCreateHandleService { HighChildOrder cpPetroCoupon(HighOrder order , CreateOrderChildModel createOrderChildModel) throws Exception; HighChildOrder etcUser(HighOrder order , CreateOrderChildModel createOrderChildModel) throws Exception; + HighChildOrder etcTrain(HighOrder order , CreateOrderChildModel createOrderChildModel) throws Exception; } diff --git a/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java b/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java index aa7e5733..b1297d9a 100644 --- a/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java +++ b/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java @@ -1420,4 +1420,33 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService { return childOrder; } + + @Override + public HighChildOrder etcTrain(HighOrder order, CreateOrderChildModel createOrderChildModel) throws Exception { + HighChildOrder childOrder = new HighChildOrder(); + childOrder.setOrderNo(order.getOrderNo()); + childOrder.setMemId(order.getMemId()); + childOrder.setMemName(order.getMemName()); + childOrder.setMemPhone(order.getMemPhone()); + childOrder.setChildOrderNo(OrderUtil.generateChildOrderNo()); + childOrder.setGoodsType(OrderChildGoodsType.TYPE21.getNumber()); + childOrder.setGoodsId(createOrderChildModel.getGoodsId()); + childOrder.setSkuId(createOrderChildModel.getSkuId()); + childOrder.setGoodsName("ETC货车办理"); + childOrder.setGoodsSpecName("ETC货车办理"); + childOrder.setGoodsPrice(createOrderChildModel.getGoodsPrice()); + childOrder.setGoodsActualPrice(childOrder.getGoodsPrice()); + childOrder.setSaleCount(createOrderChildModel.getSaleCount()); + childOrder.setGiveawayType(false); + childOrder.setChildOrderStatus(OrderChildStatus.STATUS1.getNumber()); + childOrder.setTotalPrice(childOrder.getGoodsPrice()); + childOrder.setTotalActualPrice(childOrder.getGoodsPrice()); + childOrder.setTotalDeductionPrice(childOrder.getTotalPrice().subtract(childOrder.getTotalActualPrice())); + childOrder.setPraiseStatus(0); + childOrder.setCreateTime(new Date()); + + return childOrder; + } + + } 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 803e6a83..ebefad79 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 @@ -294,6 +294,12 @@ public class OrderPaySuccessServiceImpl implements OrderPaySuccessService { cpPetroCoupon(order , childOrder); } else if (childOrder.getGoodsType().equals(OrderChildGoodsType.TYPE20.getNumber())) { etcUser(order); + } else if (childOrder.getGoodsType().equals(OrderChildGoodsType.TYPE21.getNumber())) { + etcTrain + + + + (order); } } } @@ -837,4 +843,12 @@ public class OrderPaySuccessServiceImpl implements OrderPaySuccessService { } + private void etcTrain(HighOrder order) throws Exception { + + // 赠送优惠券 + highDiscountPackageService.giveAway(order.getHighChildOrderList().get(0).getSkuId() , order.getMemPhone() , 2 , order.getMemId().toString()); + + + } + } diff --git a/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java b/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java index b141de70..690be05d 100644 --- a/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java @@ -399,6 +399,12 @@ public class OrderServiceImpl implements OrderService { order.setProductType(OrderProductType.PRODUCT_TYPE20.getNumber()); order.setSecUserId(childOrder.getId()); order.setTitle("ETC用户办理"); + } else if (child.getGoodsType().equals(OrderChildGoodsType.TYPE21.getNumber())) { + HighChildOrder childOrder = orderCreateHandleService.etcTrain(order , child); + childOrderList.add(childOrder); + order.setProductType(OrderProductType.PRODUCT_TYPE21.getNumber()); + order.setSecUserId(childOrder.getId()); + order.setTitle("ETC货车办理"); } else { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知业务类型"); diff --git a/hai-service/src/main/java/com/hai/order/type/OrderChildGoodsType.java b/hai-service/src/main/java/com/hai/order/type/OrderChildGoodsType.java index b0bd4bea..0d251d04 100644 --- a/hai-service/src/main/java/com/hai/order/type/OrderChildGoodsType.java +++ b/hai-service/src/main/java/com/hai/order/type/OrderChildGoodsType.java @@ -28,6 +28,7 @@ public enum OrderChildGoodsType { TYPE18(18, "中石油卡券"), TYPE19(19, "重庆中石油卡券"), TYPE20(20, "ETC用户办理"), + TYPE21(21, "ETC货车推广"), ; private Integer number; diff --git a/hai-service/src/main/java/com/hai/order/type/OrderProductType.java b/hai-service/src/main/java/com/hai/order/type/OrderProductType.java index 91d19bf3..9237d4c6 100644 --- a/hai-service/src/main/java/com/hai/order/type/OrderProductType.java +++ b/hai-service/src/main/java/com/hai/order/type/OrderProductType.java @@ -31,6 +31,7 @@ public enum OrderProductType { PRODUCT_TYPE18(18, "中石油卡券" , "orderLogo/coupon.png", "PETRO_COUPON"), PRODUCT_TYPE19(19, "重庆中石油卡券" , "orderLogo/coupon.png", "CQ_PETRO_COUPON"), PRODUCT_TYPE20(20, "ETC用户办理" , "orderLogo/coupon.png", "ETC_USER"), + PRODUCT_TYPE21(21, "ETC货车办理" , "orderLogo/coupon.png", "ETC_TRAIN"), PRODUCT_TYPE101(101, "惠支付" , "orderLogo/pay.png", "PAY"), PRODUCT_TYPE102(102, "门店活动" , "orderLogo/store_activity.png", "STORE_ACTIVITY"), ; diff --git a/hai-service/src/main/java/com/hai/service/HighOrderService.java b/hai-service/src/main/java/com/hai/service/HighOrderService.java index 8a92f77c..73985242 100644 --- a/hai-service/src/main/java/com/hai/service/HighOrderService.java +++ b/hai-service/src/main/java/com/hai/service/HighOrderService.java @@ -100,6 +100,7 @@ public interface HighOrderService { * @Date 2021/3/27 0:38 **/ HighOrder getOrderByOrderNo(String orderNo); + HighOrder getOrderByMap(Map map); /** * @Author 袁野 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 cef7c97e..5016b818 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 @@ -825,7 +825,6 @@ public class HighGasServiceImpl implements HighGasService { Map param = new HashMap<>(); param.put("sourceType", 2); param.put("regionId", "500000"); - param.put("storeName", "壳牌"); param.put("status", 1); List merchantStoreList = merchantStoreService.getMerchantStoreList(param); diff --git a/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java index 20e20596..1928c627 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java @@ -472,6 +472,8 @@ public class HighOrderServiceImpl implements HighOrderService { return order; } + + @Override public HighOrder getOrderByOrderNo(String orderNo) { HighOrderExample example = new HighOrderExample(); @@ -484,6 +486,33 @@ public class HighOrderServiceImpl implements HighOrderService { return null; } + @Override + public HighOrder getOrderByMap(Map map) { + HighOrderExample example = new HighOrderExample(); + HighOrderExample.Criteria criteria = example.createCriteria(); + + if (MapUtils.getLong(map, "memId") != null) { + criteria.andMemIdEqualTo(MapUtils.getLong(map, "memId")); + } + + if (StringUtils.isNotBlank(MapUtils.getString(map, "status"))) { + String[] statuses = MapUtils.getString(map, "status").split(","); + List list = new ArrayList<>(); + for (String status : statuses) { + list.add(Integer.parseInt(status)); + } + criteria.andOrderStatusIn(list); + } + List list = highOrderMapper.selectByExample(example); + + if (!list.isEmpty()) { + return list.get(0); + } + + return null; + } + + @Override public List getOrderBList(Map map) { return highOrderMapperExt.selectOrderDataList(map); diff --git a/v1/src/main/java/com/v1/config/AuthConfig.java b/v1/src/main/java/com/v1/config/AuthConfig.java index 806109fd..ebe76965 100644 --- a/v1/src/main/java/com/v1/config/AuthConfig.java +++ b/v1/src/main/java/com/v1/config/AuthConfig.java @@ -102,6 +102,9 @@ public class AuthConfig implements WebMvcConfigurer { .excludePathPatterns("/refuelOnline/*") .excludePathPatterns("/apiCoupon/*") .excludePathPatterns("/apiMerchants/*") + .excludePathPatterns("/kfc/*") + .excludePathPatterns("/starbucks/*") + .excludePathPatterns("/memberRecharge/*") ; } diff --git a/v1/src/main/java/com/v1/controller/business/RefuelOnlineController.java b/v1/src/main/java/com/v1/controller/business/RefuelOnlineController.java index 7b4b08ca..20a606b1 100644 --- a/v1/src/main/java/com/v1/controller/business/RefuelOnlineController.java +++ b/v1/src/main/java/com/v1/controller/business/RefuelOnlineController.java @@ -4,6 +4,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.common.utils.RedisUtil; import com.hai.common.utils.ResponseMsgUtil; import com.hai.entity.*; import com.hai.model.ResponseData; @@ -60,12 +61,17 @@ public class RefuelOnlineController { @Resource private ApiCommonConfig apiCommonConfig; + @Resource + private RedisUtil redisUtil; + @RequestMapping(value = "/getStationStore", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "获取油站门店") public ResponseData getStationStore(@RequestBody JSONObject object , HttpServletRequest request ) { try { + + String ip = ""; // 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for if (request.getHeader("x-forwarded-for") == null) { @@ -82,10 +88,10 @@ public class RefuelOnlineController { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR); } - if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) { - log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!"); - } +// if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) { +// log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!"); +// throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!"); +// } ApiMerchants apiMerchants = apiMerchantsService.findByMchId(object.getString("merchId")); @@ -108,55 +114,64 @@ public class RefuelOnlineController { throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY); } - Map mapProduct = new HashMap<>(); - mapProduct.put("mchId" , object.getString("merchId")); - mapProduct.put("productType" , OrderProductType.PRODUCT_TYPE6.getNumber()); + List apiMchStoreModels; - List apiMchProducts = apiMchProductService.getListMchProduct(mapProduct); + apiMchStoreModels = (List) redisUtil.get("stationStoreApi"); - Map mapMerchant = new HashMap<>();; - Map discountMap = new HashMap<>(); - List merchantStores = new ArrayList<>(); + if (apiMchStoreModels == null) { + apiMchStoreModels = new ArrayList<>(); + Map mapProduct = new HashMap<>(); + mapProduct.put("mchId" , object.getString("merchId")); + mapProduct.put("productType" , OrderProductType.PRODUCT_TYPE6.getNumber()); - for (ApiMchProduct mchProduct : apiMchProducts) { - mapMerchant.put("merchantId" , mchProduct.getMerchantId()); - discountMap.put(mchProduct.getMerchantId() , mchProduct.getDiscount()); - merchantStores.addAll(highMerchantStoreService.getMerchantStoreList(mapMerchant)); - } + List apiMchProducts = apiMchProductService.getListMchProduct(mapProduct); + + Map mapMerchant = new HashMap<>();; + Map discountMap = new HashMap<>(); + List merchantStores = new ArrayList<>(); + + for (ApiMchProduct mchProduct : apiMchProducts) { + mapMerchant.put("merchantId" , mchProduct.getMerchantId()); + discountMap.put(mchProduct.getMerchantId() , mchProduct.getDiscount()); + merchantStores.addAll(highMerchantStoreService.getMerchantStoreList(mapMerchant)); + } - List apiMchStoreModels = new ArrayList<>(); - for (HighMerchantStore merchantStore : merchantStores) { - ApiMchStoreModel apiMchStoreModel = new ApiMchStoreModel(); - apiMchStoreModel.setAddress(merchantStore.getAddress()); - apiMchStoreModel.setStoreCode(merchantStore.getId().toString()); - apiMchStoreModel.setLatitude(merchantStore.getLatitude()); - apiMchStoreModel.setLongitude(merchantStore.getLongitude()); - apiMchStoreModel.setStoreName(merchantStore.getStoreName()); - apiMchStoreModel.setRegionName(merchantStore.getRegionName()); - List gasOilPrices = gasOilPriceService.getGasOilPriceByStore(merchantStore.getId()); + for (HighMerchantStore merchantStore : merchantStores) { + ApiMchStoreModel apiMchStoreModel = new ApiMchStoreModel(); + apiMchStoreModel.setAddress(merchantStore.getAddress()); + apiMchStoreModel.setStoreCode(merchantStore.getId().toString()); + apiMchStoreModel.setLatitude(merchantStore.getLatitude()); + apiMchStoreModel.setLongitude(merchantStore.getLongitude()); + apiMchStoreModel.setStoreName(merchantStore.getStoreName()); + apiMchStoreModel.setRegionName(merchantStore.getRegionName()); + List gasOilPrices = gasOilPriceService.getGasOilPriceByStore(merchantStore.getId()); - List list = new ArrayList<>(); - for (HighGasOilPrice gasOilPrice : gasOilPrices) { - ApiGasOliPriceModel gasOliPriceModel = new ApiGasOliPriceModel(); - gasOliPriceModel.setPriceCost(apiCommonConfig.computationPriceCost(discountMap.get(merchantStore.getMerchantId()), gasOilPrice.getPriceGun())); - gasOliPriceModel.setPriceGun(gasOilPrice.getPriceGun()); - gasOliPriceModel.setPriceOfficial(gasOilPrice.getPriceOfficial()); - gasOliPriceModel.setOilNo(gasOilPrice.getOilNo()); - gasOliPriceModel.setOilNoName(gasOilPrice.getOilNoName()); - gasOliPriceModel.setOilType(gasOilPrice.getOilType()); - gasOliPriceModel.setOilTypeName(gasOilPrice.getOilTypeName()); - gasOliPriceModel.setGasOliNo(apiCommonConfig.assemblyGasOilGunNo(gasOilPrice.getId())); - list.add(gasOliPriceModel); + List list = new ArrayList<>(); + for (HighGasOilPrice gasOilPrice : gasOilPrices) { + ApiGasOliPriceModel gasOliPriceModel = new ApiGasOliPriceModel(); + gasOliPriceModel.setPriceCost(apiCommonConfig.computationPriceCost(discountMap.get(merchantStore.getMerchantId()), gasOilPrice.getPriceGun())); + gasOliPriceModel.setPriceGun(gasOilPrice.getPriceGun()); + gasOliPriceModel.setPriceOfficial(gasOilPrice.getPriceOfficial()); + gasOliPriceModel.setOilNo(gasOilPrice.getOilNo()); + gasOliPriceModel.setOilNoName(gasOilPrice.getOilNoName()); + gasOliPriceModel.setOilType(gasOilPrice.getOilType()); + gasOliPriceModel.setOilTypeName(gasOilPrice.getOilTypeName()); + gasOliPriceModel.setGasOliNo(apiCommonConfig.assemblyGasOilGunNo(gasOilPrice.getId())); + list.add(gasOliPriceModel); + + } + apiMchStoreModel.setApiGasOliPriceModels(list); + apiMchStoreModels.add(apiMchStoreModel); } - apiMchStoreModel.setApiGasOliPriceModels(list); - apiMchStoreModels.add(apiMchStoreModel); + redisUtil.set("stationStoreApi", apiMchStoreModels); } + return ResponseMsgUtil.success(apiMchStoreModels); } catch (Exception e) { diff --git a/v1/src/main/java/com/v1/controller/orderController.java b/v1/src/main/java/com/v1/controller/orderController.java index e0362b73..49e0bbf4 100644 --- a/v1/src/main/java/com/v1/controller/orderController.java +++ b/v1/src/main/java/com/v1/controller/orderController.java @@ -73,6 +73,9 @@ public class orderController { public ResponseData createOrder(@RequestBody JSONObject object , HttpServletRequest request ) { try { + System.out.println("请求订单内容======================================================"); + System.out.println(object); + String ip; // 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for if (request.getHeader("x-forwarded-for") == null) {