From 3c2a1569918744f3c3db8bb10618f6d77fbbd356 Mon Sep 17 00:00:00 2001 From: Sum1Dream <418471657@qq.com> Date: Wed, 30 Aug 2023 15:27:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bweb/controller/HighTestController.java | 2 +- .../com/hai/entity/HighCouponCodeOther.java | 4 +- .../java/com/hai/entity/HighUserCoupon.java | 14 +- .../com/hai/openApi/config/BlxConfig.java | 183 ++++++++++- .../com/hai/service/HighUserCardService.java | 3 +- .../hai/service/HighUserCouponService.java | 11 + .../impl/HighCouponCodeServiceImpl.java | 1 + .../service/impl/HighUserCardServiceImpl.java | 96 +++++- .../impl/HighUserCouponServiceImpl.java | 19 ++ .../hai/service/impl/HighUserServiceImpl.java | 2 +- .../business/BlxCouponController.java | 304 ++++++++++++++++++ .../com/v1/controller/orderController.java | 26 +- 12 files changed, 621 insertions(+), 44 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 be11c355..d9d2f7b2 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java @@ -1 +1 @@ - package com.bweb.controller; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.utils.HttpsUtils; import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.WxUtils; import com.hai.config.HuiLianTongUnionCardConfig; import com.hai.entity.*; import com.hai.model.ResponseData; import com.hai.order.service.OrderService; import com.hai.order.type.OrderRefundOpUserType; import com.hai.order.utils.OrderUtil; import com.hai.service.HighCouponCodeOtherService; import com.hai.service.HighCouponService; import com.hai.service.HighOrderService; import com.hai.service.TestService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.bouncycastle.LICENSE; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; import java.util.HashMap; import java.util.List; import java.util.Map; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/test") @Api(value = "订单接口") public class HighTestController { private static Logger log = LoggerFactory.getLogger(HighTestController.class); @Resource private OrderService orderService; @Resource private HighOrderService highOrderService; @Resource private HighCouponCodeOtherService couponCodeOtherService; @Resource private TestService testService; @Resource private HighCouponService highCouponService; @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("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); // mapPost.put("merchId" , "20230258302"); // mapPost.put("timetable" , new Date().getTime()); // mapPost.put("orderNo" , "TEST" + OrderUtil.generateOrderNo()); // mapPost.put("productType" , object.getString("productType")); // mapPost.put("notifyUrl" , "test"); // // mapPost.put("content" , object.toString()); // System.out.println(mapPost); // // Map map = new HashMap<>(); // map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); // map.put("merchId" , "20230258302"); // map.put("timetable" , mapPost.get("timetable").toString()); // map.put("orderNo" , mapPost.get("orderNo")); // map.put("productType" , object.getString("productType")); // map.put("content" , object.toString()); // // System.out.println(map); // // mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); // return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/order/createOrder" , mapPost , new HashMap<>())); // } catch (Exception e) { // log.error("HighOrderController --> getBackendToken() error!", e); // return ResponseMsgUtil.exception(e); // } // } @RequestMapping(value = "/payOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "支付订单") public ResponseData payOrder(@RequestParam(name = "mchOrderNo", required = true) String mchOrderNo) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("mchOrderNo" , mchOrderNo); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("mchOrderNo" , mchOrderNo); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/order/orderPay" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryOrderDetail", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询订单详情") public ResponseData queryOrderDetail(@RequestParam(name = "mchOrderNo", required = true) String mchOrderNo) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("mchOrderNo" , mchOrderNo); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("mchOrderNo" , mchOrderNo); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/order/queryOrderDetail" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/deposit", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "工会卡充值") public ResponseData deposit(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); HighChildOrder highChildOrder = order.getHighChildOrderList().get(0); if (order.getOrderStatus() != 2) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单状态错误"); } // 汇联通充值 String goodsDesc = "汇联通充值"+order.getPayPrice()+"元"; String tranDesc = ""; String businessType = "ghk_deposit"; String orderNoAgain = OrderUtil.generateOrderNo(); order.setOrderStatus(Integer.valueOf(3)); order.setRemarks("工会卡再次充值订单号" + orderNoAgain); highOrderService.updateOrder(order); // 汇联通卡充值 JSONObject deposit = HuiLianTongUnionCardConfig.deposit(orderNoAgain, highChildOrder.getGoodsSpecName(), order.getPayPrice(), businessType, order.getPaySerialNo(), goodsDesc); return ResponseMsgUtil.success( HuiLianTongUnionCardConfig.resolveResponse(deposit.getString("data"))); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getHuiLianTongCardByCardNo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据卡号查询汇联通工会卡详情") public ResponseData getHuiLianTongCardByCardNo(@RequestParam(name = "cardNo", required = true) String cardNo) { try { // 查询工会卡 JSONObject cardInfo = HuiLianTongUnionCardConfig.queryBalance(cardNo); JSONObject resolveResponse = HuiLianTongUnionCardConfig.resolveResponse(cardInfo.getString("data")); return ResponseMsgUtil.success(resolveResponse); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardByCardNo() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/consumption", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "工会卡支付") public ResponseData consumption(@RequestParam(name = "payRealPrice", required = true) BigDecimal payRealPrice, @RequestParam(name = "cardNo", required = true) String cardNo) { try { String goodsDesc = ""; String tranDesc = ""; String instCode = "11101527"; String businessType = "hisen_consume"; // 工会卡支付 JSONObject consumption = HuiLianTongUnionCardConfig.consumption(OrderUtil.generateOrderNo(), cardNo, payRealPrice, businessType, instCode, goodsDesc, tranDesc); if (!consumption.getString("respCode").equals("0000")) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumption.getString("respMessage")); } // 响应参数 JSONObject consumptionResult = HuiLianTongUnionCardConfig.resolveResponse(consumption.getString("data")); if (consumptionResult.getBoolean("success") != true) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumptionResult.getString("message")); } return ResponseMsgUtil.success(consumptionResult); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardByCardNo() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/refundOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "工会卡退款") public ResponseData refundOrder(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); if (order.getOrderStatus() != 2) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单状态错误"); } orderService.refundOrder(order, "工会卡充值退款",OrderRefundOpUserType.TYPE1, null, "系统自动退款"); 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); } } } \ No newline at end of file + package com.bweb.controller; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.utils.HttpsUtils; import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.WxUtils; import com.hai.config.HuiLianTongUnionCardConfig; import com.hai.entity.*; import com.hai.model.ResponseData; import com.hai.openApi.config.BlxConfig; import com.hai.order.service.OrderService; import com.hai.order.type.OrderRefundOpUserType; import com.hai.order.utils.OrderUtil; import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.bouncycastle.LICENSE; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; import java.util.HashMap; import java.util.List; import java.util.Map; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/test") @Api(value = "订单接口") public class HighTestController { private static Logger log = LoggerFactory.getLogger(HighTestController.class); @Resource private OrderService orderService; @Resource private HighUserCardService highUserCardService; @Resource private HighOrderService highOrderService; @Resource private BlxConfig blxConfig; @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("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); // mapPost.put("merchId" , "20230258302"); // mapPost.put("timetable" , new Date().getTime()); // mapPost.put("orderNo" , "TEST" + OrderUtil.generateOrderNo()); // mapPost.put("productType" , object.getString("productType")); // mapPost.put("notifyUrl" , "test"); // // mapPost.put("content" , object.toString()); // System.out.println(mapPost); // // Map map = new HashMap<>(); // map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); // map.put("merchId" , "20230258302"); // map.put("timetable" , mapPost.get("timetable").toString()); // map.put("orderNo" , mapPost.get("orderNo")); // map.put("productType" , object.getString("productType")); // map.put("content" , object.toString()); // // System.out.println(map); // // mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); // return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/order/createOrder" , mapPost , new HashMap<>())); // } catch (Exception e) { // log.error("HighOrderController --> getBackendToken() error!", e); // return ResponseMsgUtil.exception(e); // } // } @RequestMapping(value = "/payOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "支付订单") public ResponseData payOrder(@RequestParam(name = "mchOrderNo", required = true) String mchOrderNo) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("mchOrderNo" , mchOrderNo); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("mchOrderNo" , mchOrderNo); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/order/orderPay" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryOrderDetail", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询订单详情") public ResponseData queryOrderDetail(@RequestParam(name = "mchOrderNo", required = true) String mchOrderNo) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("mchOrderNo" , mchOrderNo); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("mchOrderNo" , mchOrderNo); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/order/queryOrderDetail" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/deposit", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "工会卡充值") public ResponseData deposit(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); HighChildOrder highChildOrder = order.getHighChildOrderList().get(0); if (order.getOrderStatus() != 2) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单状态错误"); } // 汇联通充值 String goodsDesc = "汇联通充值"+order.getPayPrice()+"元"; String tranDesc = ""; String businessType = "ghk_deposit"; String orderNoAgain = OrderUtil.generateOrderNo(); order.setOrderStatus(Integer.valueOf(3)); order.setRemarks("工会卡再次充值订单号" + orderNoAgain); highOrderService.updateOrder(order); // 汇联通卡充值 JSONObject deposit = HuiLianTongUnionCardConfig.deposit(orderNoAgain, highChildOrder.getGoodsSpecName(), order.getPayPrice(), businessType, order.getPaySerialNo(), goodsDesc); return ResponseMsgUtil.success( HuiLianTongUnionCardConfig.resolveResponse(deposit.getString("data"))); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getHuiLianTongCardByCardNo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据卡号查询汇联通工会卡详情") public ResponseData getHuiLianTongCardByCardNo(@RequestParam(name = "cardNo", required = true) String cardNo) { try { // 查询工会卡 JSONObject cardInfo = HuiLianTongUnionCardConfig.queryBalance(cardNo); JSONObject resolveResponse = HuiLianTongUnionCardConfig.resolveResponse(cardInfo.getString("data")); return ResponseMsgUtil.success(resolveResponse); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardByCardNo() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/consumption", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "工会卡支付") public ResponseData consumption(@RequestParam(name = "payRealPrice", required = true) BigDecimal payRealPrice, @RequestParam(name = "cardNo", required = true) String cardNo) { try { String goodsDesc = ""; String tranDesc = ""; String instCode = "11101527"; String businessType = "hisen_consume"; // 工会卡支付 JSONObject consumption = HuiLianTongUnionCardConfig.consumption(OrderUtil.generateOrderNo(), cardNo, payRealPrice, businessType, instCode, goodsDesc, tranDesc); if (!consumption.getString("respCode").equals("0000")) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumption.getString("respMessage")); } // 响应参数 JSONObject consumptionResult = HuiLianTongUnionCardConfig.resolveResponse(consumption.getString("data")); if (consumptionResult.getBoolean("success") != true) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumptionResult.getString("message")); } return ResponseMsgUtil.success(consumptionResult); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardByCardNo() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/refundOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "工会卡退款") public ResponseData refundOrder(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); if (order.getOrderStatus() != 2) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单状态错误"); } orderService.refundOrder(order, "工会卡充值退款",OrderRefundOpUserType.TYPE1, null, "系统自动退款"); return ResponseMsgUtil.success("退款成功"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/externalOrderRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "对外订单退款") public ResponseData externalOrderRefund(@RequestParam(name = "paySerialNo", required = true) String paySerialNo, @RequestParam(name = "WxMchId", required = true) String WxMchId, @RequestParam(name = "payRealPrice", required = true) String payRealPrice) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "B94B5E62807FA56A7260AB581D8A1B48"); mapPost.put("merchId" , "20230394901"); mapPost.put("paySerialNo" , paySerialNo); mapPost.put("wxMchId" , WxMchId); mapPost.put("payRealPrice" , payRealPrice); mapPost.put("refundPrice" , payRealPrice); Map map = new HashMap<>(); map.put("apiKey" , "B94B5E62807FA56A7260AB581D8A1B48"); map.put("merchId" , "20230394901"); map.put("paySerialNo" , paySerialNo); map.put("wxMchId" , WxMchId); map.put("payRealPrice" , payRealPrice); map.put("refundPrice" , payRealPrice); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("https://hsg.dctpay.com/v1/order/externalOrderRefund" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getBlxCouponBalance", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询停车券") public ResponseData getBlxCouponBalance(@RequestParam(name = "phone", required = true) String phone) { try { highUserCardService.getBlxCouponBalance(phone); return ResponseMsgUtil.success("object"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryJsParking", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询捷顺停车场") public ResponseData queryJsParking(@RequestParam(name = "gps", required = true) String gps) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("gps" , gps); mapPost.put("range" , "1000"); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/queryJsParking" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getUserCouponPage", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询捷顺停车场") public ResponseData getUserCouponPage(@RequestParam(name = "phone", required = true) String phone) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("phone" , phone); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/getUserCouponPage" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryJsOrderList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询车牌订单列表信息") public ResponseData queryJsOrderList(@RequestParam(name = "carNo", required = true) String carNo, @RequestParam(name = "orderStatus", required = true) String orderStatus) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("orderStatus" , orderStatus); mapPost.put("carNo" , carNo); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/queryJsOrderList" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getCouponList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询车牌订单列表信息") public ResponseData getCouponList() { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/getCouponList" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/sendCoupon", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "发放券") public ResponseData sendCoupon(@RequestParam(name = "couponCode", required = true) String couponCode, @RequestParam(name = "receiverCount", required = true) String receiverCount, @RequestParam(name = "receiverPhone", required = true) String receiverPhone) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/getCouponList" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } } \ No newline at end of file diff --git a/hai-service/src/main/java/com/hai/entity/HighCouponCodeOther.java b/hai-service/src/main/java/com/hai/entity/HighCouponCodeOther.java index 457b735c..4c1bdf83 100644 --- a/hai-service/src/main/java/com/hai/entity/HighCouponCodeOther.java +++ b/hai-service/src/main/java/com/hai/entity/HighCouponCodeOther.java @@ -19,7 +19,7 @@ public class HighCouponCodeOther implements Serializable { private Long id; /** - * 类型: 1 贵州中石化 2 重庆中石油 3 优惠券 + * 类型: 1 贵州中石化 2 重庆中石油 3 优惠券 4:黔印象停车券 */ private Integer type; @@ -341,4 +341,4 @@ public class HighCouponCodeOther implements Serializable { sb.append("]"); return sb.toString(); } -} \ No newline at end of file +} diff --git a/hai-service/src/main/java/com/hai/entity/HighUserCoupon.java b/hai-service/src/main/java/com/hai/entity/HighUserCoupon.java index a76af136..3b4bb087 100644 --- a/hai-service/src/main/java/com/hai/entity/HighUserCoupon.java +++ b/hai-service/src/main/java/com/hai/entity/HighUserCoupon.java @@ -1,5 +1,7 @@ package com.hai.entity; +import com.hai.model.HighCouponModel; + import java.io.Serializable; import java.util.Date; @@ -101,6 +103,16 @@ public class HighUserCoupon implements Serializable { private String ext4; + private HighCouponModel highCouponModel; + + public HighCouponModel getHighCouponModel() { + return highCouponModel; + } + + public void setHighCouponModel(HighCouponModel highCouponModel) { + this.highCouponModel = highCouponModel; + } + private static final long serialVersionUID = 1L; public Long getId() { @@ -354,4 +366,4 @@ public class HighUserCoupon implements Serializable { sb.append("]"); return sb.toString(); } -} \ No newline at end of file +} diff --git a/hai-service/src/main/java/com/hai/openApi/config/BlxConfig.java b/hai-service/src/main/java/com/hai/openApi/config/BlxConfig.java index 492c62b5..10007bc7 100644 --- a/hai-service/src/main/java/com/hai/openApi/config/BlxConfig.java +++ b/hai-service/src/main/java/com/hai/openApi/config/BlxConfig.java @@ -1,15 +1,12 @@ package com.hai.openApi.config; -import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.hai.common.utils.HttpsUtils; import com.hai.common.utils.RedisUtil; import com.hai.config.CommonSysConst; -import com.hai.config.HuiLianTongUnionCardConfig; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; - import javax.annotation.Resource; import java.util.HashMap; import java.util.Map; @@ -38,16 +35,19 @@ public class BlxConfig { Map map = new HashMap<>(); map.put("organizeCode" , "dhy"); log.info("============ 比邻星停车券业务-获取TOKEN-START ============="); - JSONObject object = HttpsUtils.doGet("https://vertical-formats-gateway.blx.bodata.cn:18443/admin/api/generateJwt" , map); + JSONObject object = HttpsUtils.doGet(CommonSysConst.getSysConfig().getBlxPostUrl() + "/admin/api/generateJwt" , map); log.info("请求参数: " + map); log.info("响应参数: " + object); log.info("============ 比邻星停车券业务-获取TOKEN-END =============="); + redisUtil.set("BlxToken" , object.getString("data") , 2000); return object.getString("data"); } return token.toString(); } + + /** * @Author Sum1Dream * @Name queryCouponPage @@ -132,4 +132,179 @@ public class BlxConfig { } + /** + * @Author Sum1Dream + * @Name getUserBindCarNo + * @Description // 获取用户绑定车辆信息 + * @Date 10:11 2023/8/25 + * @Param [object] + * @Return com.alibaba.fastjson.JSONObject + */ + public JSONObject getUserBindCarNo(JSONObject object) { + + Map map = new HashMap<>(); + map.put("userMobile" , object.getString("userMobile")); + map.put("organizeCode" , object.getString("organizeCode")); + + Map header = new HashMap<>(); + header.put("token" , generateJw()); + log.info("============ 比邻星停车券业务-获取用户绑定车辆信息-START ============="); + JSONObject data = HttpsUtils.doPost(CommonSysConst.getSysConfig().getBlxPostUrl() + "/peration/member/parking/api/getUserBindCarNo" , map , header); + log.info("头部参数: " + header); + log.info("请求参数: " + map); + log.info("响应参数: " + data); + log.info("============ 比邻星停车券业务-获取用户绑定车辆信息-END ============="); + return data; + + } + + /** + * @Author Sum1Dream + * @Name addUserBindCarNo + * @Description // 用户绑定车辆 + * @Date 10:11 2023/8/25 + * @Param [object] + * @Return com.alibaba.fastjson.JSONObject + */ + public JSONObject addUserBindCarNo(JSONObject object) { + + Map map = new HashMap<>(); + map.put("userMobile" , object.getString("userMobile")); + map.put("organizeCode" , object.getString("organizeCode")); + map.put("plateNumber" , object.getString("plateNumber")); + // 车牌颜色- 0:未知,1:蓝色,2:黄色,3:黑色,4:白色,5:绿色 + map.put("plateColor" , object.getString("plateColor")); + + Map header = new HashMap<>(); + header.put("token" , generateJw()); + log.info("============ 比邻星停车券业务-用户绑定车辆-START ============="); + JSONObject data = HttpsUtils.doPost(CommonSysConst.getSysConfig().getBlxPostUrl() + "/peration/member/parking/api/addUserBindCarNo" , map , header); + log.info("头部参数: " + header); + log.info("请求参数: " + map); + log.info("响应参数: " + data); + log.info("============ 比邻星停车券业务-用户绑定车辆-END ============="); + return data; + + } + + /** + * @Author Sum1Dream + * @Name delUserBindCarNo + * @Description // 删除用户绑定车辆 + * @Date 10:20 2023/8/25 + * @Param [object] + * @Return com.alibaba.fastjson.JSONObject + */ + public JSONObject delUserBindCarNo(JSONObject object) { + + Map map = new HashMap<>(); + map.put("userMobile" , object.getString("userMobile")); + map.put("organizeCode" , object.getString("organizeCode")); + map.put("plateNumber" , object.getString("plateNumber")); + + Map header = new HashMap<>(); + header.put("token" , generateJw()); + log.info("============ 比邻星停车券业务-删除用户绑定车辆-START ============="); + JSONObject data = HttpsUtils.doPost(CommonSysConst.getSysConfig().getBlxPostUrl() + "/peration/member/parking/api/delUserBindCarNo" , map , header); + log.info("头部参数: " + header); + log.info("请求参数: " + map); + log.info("响应参数: " + data); + log.info("============ 比邻星停车券业务-删除用户绑定车辆-END ============="); + return data; + + } + + /** + * @Author Sum1Dream + * @Name queryJsParking + * @Description // 获取附近停车场-捷顺 + * @Date 10:26 2023/8/25 + * @Param [object] + * @Return com.alibaba.fastjson.JSONObject + */ + public JSONObject queryJsParking(JSONObject object) { + + Map map = new HashMap<>(); + map.put("gps" , object.getString("gps")); + map.put("range" , object.getString("range")); + + Map header = new HashMap<>(); + header.put("token" , generateJw()); + log.info("============ 比邻星停车券业务-获取附近停车场-捷顺-START ============="); + JSONObject data = HttpsUtils.doPost(CommonSysConst.getSysConfig().getBlxPostUrl() + "/peration/member/parking/api/queryJsParking" , map , header); + log.info("头部参数: " + header); + log.info("请求参数: " + map); + log.info("响应参数: " + data); + log.info("============ 比邻星停车券业务-获取附近停车场-捷顺-END ============="); + return data; + + } + + /** + * @Author Sum1Dream + * @Name queryJsOrderList + * @Description // 查询车牌订单列表信息 + * @Date 11:42 2023/8/28 + * @Param [object] + * @Return com.alibaba.fastjson.JSONObject + */ + public JSONObject queryJsOrderList(JSONObject object) { + + Map map = new HashMap<>(); + map.put("carNo" , object.getString("carNo")); + map.put("orderStatus" , object.getString("orderStatus")); + + Map header = new HashMap<>(); + header.put("token" , generateJw()); + log.info("============ 比邻星停车券业务-查询车牌订单列表信息--捷顺-START ============="); + JSONObject data = HttpsUtils.doPost(CommonSysConst.getSysConfig().getBlxPostUrl() + "/peration/member/parking/api/queryJsOrderList" , map , header); + log.info("头部参数: " + header); + log.info("请求参数: " + map); + log.info("响应参数: " + data); + log.info("============ 比邻星停车券业务-查询车牌订单列表信息--捷顺-END ============="); + return data; + + } + + /** + * @Author Sum1Dream + * @Name creatOrder + * @Description // 停车添加订单 + * @Date 10:12 2023/8/30 + * @Param [object] + * @Return com.alibaba.fastjson.JSONObject + */ + public JSONObject creatOrder(JSONObject object) { + + Map map = new HashMap<>(); + map.put("organizeCode" , object.getString("organizeCode")); + map.put("userMobile" , object.getString("userMobile")); + map.put("userCouponCode" , object.getString("userCouponCode")); + map.put("parkOrderId" , object.getString("parkOrderId")); + map.put("orderType" , object.getString("orderType")); + map.put("prePrice" , object.getString("prePrice")); + map.put("parkId" , object.getString("parkId")); + map.put("parkName" , object.getString("parkName")); + map.put("parkTime" , object.getString("parkTime")); + map.put("carSeatId" , object.getString("carSeatId")); + map.put("inTime" , object.getString("inTime")); + map.put("outTime" , object.getString("outTime")); + map.put("carNo" , object.getString("carNo")); + map.put("parkType" , object.getString("parkType")); + + Map header = new HashMap<>(); + header.put("token" , generateJw()); + log.info("============ 比邻星停车券业务-查询车牌订单列表信息--捷顺-START ============="); + JSONObject data = HttpsUtils.doPost(CommonSysConst.getSysConfig().getBlxPostUrl() + "/peration/member/parking/api/creatOrder" , map , header); + log.info("头部参数: " + header); + log.info("请求参数: " + map); + log.info("响应参数: " + data); + log.info("============ 比邻星停车券业务-查询车牌订单列表信息--捷顺-END ============="); + return data; + + } + + + + } diff --git a/hai-service/src/main/java/com/hai/service/HighUserCardService.java b/hai-service/src/main/java/com/hai/service/HighUserCardService.java index 8ddc5cff..aa977f73 100644 --- a/hai-service/src/main/java/com/hai/service/HighUserCardService.java +++ b/hai-service/src/main/java/com/hai/service/HighUserCardService.java @@ -1,5 +1,6 @@ package com.hai.service; +import com.alibaba.fastjson.JSONObject; import com.hai.entity.HighUser; import com.hai.entity.HighUserCard; @@ -73,6 +74,6 @@ public interface HighUserCardService { **/ HighUserCard getUserHtlCardNo(Long userId); - Integer getBlxCouponBalance(String phone); + JSONObject getBlxCouponBalance(String phone); } diff --git a/hai-service/src/main/java/com/hai/service/HighUserCouponService.java b/hai-service/src/main/java/com/hai/service/HighUserCouponService.java index f9cba8f7..cb05ea15 100644 --- a/hai-service/src/main/java/com/hai/service/HighUserCouponService.java +++ b/hai-service/src/main/java/com/hai/service/HighUserCouponService.java @@ -94,5 +94,16 @@ public interface HighUserCouponService { **/ void expiredCoupon(Long userCouponId); + /** + * @Author Sum1Dream + * @Name findUserCouponByCode + * @Description // 第三方code查询 + * @Date 15:30 2023/8/24 + * @Param [code] + * @Return com.hai.entity.HighUserCoupon + */ + HighUserCoupon findUserCouponByCode(String code); + + } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java index bc131cd4..552f658d 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java @@ -524,6 +524,7 @@ public class HighCouponCodeServiceImpl implements HighCouponCodeService { highUserCoupon.setOrderId(order.getId()); highUserCoupon.setChildOrderId(childOrder.getId()); highUserCoupon.setUserId(order.getMemId()); + highUserCoupon.setUserPhone(order.getMemPhone()); highUserCoupon.setCreateTime(new Date()); highUserCoupon.setUseEndTime(apiBlxCoupon.getUseEndTime()); highUserCoupon.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用 diff --git a/hai-service/src/main/java/com/hai/service/impl/HighUserCardServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighUserCardServiceImpl.java index 1d54689a..8ff3d1b4 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighUserCardServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighUserCardServiceImpl.java @@ -1,29 +1,28 @@ package com.hai.service.impl; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.security.UserCenter; import com.hai.dao.HighUserCardMapper; -import com.hai.entity.HighFleetOilCard; -import com.hai.entity.HighOilCard; -import com.hai.entity.HighUserCard; -import com.hai.entity.HighUserCardExample; +import com.hai.entity.*; import com.hai.enum_type.OilCardStatusEnum; import com.hai.enum_type.UserCardType; import com.hai.model.HighUserModel; import com.hai.openApi.config.BlxConfig; -import com.hai.service.HighFleetOilCardService; -import com.hai.service.HighOilCardService; -import com.hai.service.HighUserCardService; +import com.hai.service.*; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.Date; +import java.util.HashMap; import java.util.List; +import java.util.Map; @Service("highUserCardService") public class HighUserCardServiceImpl implements HighUserCardService { @@ -32,8 +31,10 @@ public class HighUserCardServiceImpl implements HighUserCardService { private HighUserCardMapper highUserCardMapper; @Resource - private UserCenter userCenter; + private HighUserCouponService highUserCouponService; + @Resource + private HighCouponCodeOtherService couponCodeOtherService; @Resource private BlxConfig blxConfig; @@ -44,6 +45,12 @@ public class HighUserCardServiceImpl implements HighUserCardService { @Resource private HighFleetOilCardService fleetOilCardService; + @Resource + private HighCouponService highCouponService; + + @Resource + private HighUserService highUserService; + @Override public void editCard(HighUserCard highUserCard) { if(highUserCard.getId() == null){ @@ -172,27 +179,92 @@ public class HighUserCardServiceImpl implements HighUserCardService { } @Override - public Integer getBlxCouponBalance(String phone) { + public JSONObject getBlxCouponBalance(String phone) { try { if (phone == null) { - return 0; + return null; } + JSONObject data = new JSONObject(); JSONObject jsonObject = new JSONObject(); jsonObject.put("userMobile" , phone); + HighUser user = highUserService.findByPhone(phone); + + // 获取比邻星接口查询用户停车券内容 JSONObject object = blxConfig.getUserCouponPage(jsonObject); int num = 0; if (object.getInteger("code") == 1) { num = object.getJSONObject("data").getInteger("total"); + + if (num > 0) { + + // 获取停车券内容 + JSONArray blcArray = object.getJSONObject("data").getJSONArray("records"); + data.put("data" , blcArray); + + // 更新停车券状态 + for (Object o : blcArray) { + JSONObject blxData = (JSONObject) o; + // 查询是否存在 + HighUserCoupon userCoupon = highUserCouponService.findUserCouponByCode(blxData.getString("userCouponCode")); + + HighCouponCodeOther couponCodeOther = couponCodeOtherService.getDetailByCouNo(blxData.getString("userCouponCode")); + + // 查询卡券 + HighCoupon coupon = highCouponService.getCouponDetail(blxData.getString("couponCode")); + + if (userCoupon != null) { + userCoupon.setStatus(blxData.getInteger("userCouponStatus")); + highUserCouponService.updateUserCoupon(userCoupon); + } else { + HighUserCoupon highUserCoupon = new HighUserCoupon(); + highUserCoupon.setStatus(blxData.getInteger("userCouponStatus")); + highUserCoupon.setUserPhone(phone); + if (coupon != null ) { + highUserCoupon.setCouponId(coupon.getId()); + } + + if (user != null) { + highUserCoupon.setUserId(user.getId()); + } + highUserCoupon.setCreateTime(new Date()); + highUserCoupon.setQrCodeImg(blxData.getString("userCouponCode")); + highUserCoupon.setUseEndTime(blxData.getDate("expiresTime")); + highUserCoupon.setSource(3); + highUserCouponService.insertUserCoupon(highUserCoupon); + + } + + if (couponCodeOther != null) { + couponCodeOther.setStatus(blxData.getInteger("userCouponStatus") == 1 ? 20:40); + couponCodeOtherService.update(couponCodeOther); + } else { + HighCouponCodeOther codeOther = new HighCouponCodeOther(); + codeOther.setStatus(blxData.getInteger("userCouponStatus") == 1 ? 20:40); + codeOther.setType(4); + codeOther.setActiveTime(blxData.getDate("useStartTime")); + codeOther.setCouNo(blxData.getString("userCouponCode")); + codeOther.setCouTypeCode(blxData.getString("couponCode")); + codeOther.setCreateTime(new Date()); + codeOther.setValidStartDate(blxData.getDate("useStartTime")); + codeOther.setValidEndDate(blxData.getDate("expiresTime")); + couponCodeOtherService.insertCouponCodeOther(codeOther); + } + } + + } + } - return num; + data.put("num" , num); + + return data; } catch (Exception e) { - return 0; + return null; } } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighUserCouponServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighUserCouponServiceImpl.java index 826c265d..8f9adb99 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighUserCouponServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighUserCouponServiceImpl.java @@ -109,6 +109,10 @@ public class HighUserCouponServiceImpl implements HighUserCouponService { criteria.andUserIdEqualTo(MapUtils.getLong(map, "userId")); } + if (MapUtils.getString(map, "userPhone") != null) { + criteria.andUserPhoneEqualTo(MapUtils.getString(map, "userPhone")); + } + if (MapUtils.getLong(map, "merchantId") != null) { criteria.andMerchantIdEqualTo(MapUtils.getLong(map, "merchantId")); } @@ -253,4 +257,19 @@ public class HighUserCouponServiceImpl implements HighUserCouponService { couponCode.setReceiveTime(null); highCouponCodeService.updateCouponCode(couponCode); } + + @Override + public HighUserCoupon findUserCouponByCode(String code) { + HighUserCouponExample example = new HighUserCouponExample(); + example.createCriteria().andQrCodeImgEqualTo(code); + example.setOrderByClause("create_time desc"); + + List userCoupons = highUserCouponMapper.selectByExample(example); + + if (userCoupons.size() > 0) { + return userCoupons.get(0); + } + + return null; + } } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighUserServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighUserServiceImpl.java index e65884a9..e70abe6b 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighUserServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighUserServiceImpl.java @@ -215,7 +215,7 @@ public class HighUserServiceImpl implements HighUserService { user.setIsSetPayPwd(highUserPayPasswordService.isSetPayPwd(userId)); user.setIsSetHltCard(highUserCardService.isBindHtlCard(userId)); user.setHltCardNo(highUserCardService.getUserHtlCardNo(userId)); - user.setBlxCouponBalance(highUserCardService.getBlxCouponBalance(user.getPhone())); + user.setBlxCouponBalance(highUserCardService.getBlxCouponBalance(user.getPhone()).getInteger("num")); // 查询油卡 List oilCardList = highUserCardService.getListByUser(userId, UserCardType.type2.getType()); diff --git a/v1/src/main/java/com/v1/controller/business/BlxCouponController.java b/v1/src/main/java/com/v1/controller/business/BlxCouponController.java index af692296..925212fc 100644 --- a/v1/src/main/java/com/v1/controller/business/BlxCouponController.java +++ b/v1/src/main/java/com/v1/controller/business/BlxCouponController.java @@ -8,11 +8,13 @@ import com.hai.common.exception.SysCode; import com.hai.common.utils.ResponseMsgUtil; import com.hai.entity.ApiMerchants; import com.hai.model.ResponseData; +import com.hai.openApi.config.BlxConfig; import com.hai.openApi.service.ApiBlxCouponService; import com.hai.openApi.service.ApiMobileRechargeProductService; import com.hai.order.type.OrderProductType; import com.hai.service.ApiIpAddressService; import com.hai.service.ApiMerchantsService; +import com.hai.service.HighUserCardService; import com.hai.service.SecConfigService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -23,6 +25,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; +import java.sql.Date; import java.util.HashMap; import java.util.Map; @@ -46,6 +49,12 @@ public class BlxCouponController { @Resource private ApiIpAddressService apiIpAddressService; + @Resource + private HighUserCardService highUserCardService; + + @Resource + private BlxConfig blxConfig; + @RequestMapping(value = "/getCouponList", method = RequestMethod.POST) @ResponseBody @@ -103,4 +112,299 @@ public class BlxCouponController { } } + @RequestMapping(value = "/getUserCouponPage", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "获取用户停车券") + public ResponseData getUserCouponPage(@RequestBody JSONObject object , HttpServletRequest request ) { + try { + + String ip = ""; + // 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for + if (request.getHeader("x-forwarded-for") == null) { + ip = request.getRemoteAddr(); + } else { + ip = request.getHeader("x-forwarded-for"); + } + + if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) { + log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!"); + } + + if ( + StringUtils.isBlank(object.getString("merchId")) || + StringUtils.isBlank(object.getString("phone")) || + StringUtils.isBlank(object.getString("sign")) + ) { + log.error("getRechargeProduct error!", "请求参数校验失败!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR); + } + + ApiMerchants apiMerchants = apiMerchantsService.findByMchId(object.getString("merchId")); + + if (apiMerchants == null) { + log.error("getRechargeProduct error!", "帐户号错误!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_NOT_EXIST); + } + + if (!secConfigService.isConfig(OrderProductType.PRODUCT_TYPE13.getApiCode(), object.getString("merchId"))) { + log.error("getAllCities error!", "当前帐户无权限查询!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOT_AUTHORIZED, ""); + } + + Map map = new HashMap<>(); + map.put("apiKey" , apiMerchants.getApiKey()); + map.put("merchId" , object.getString("merchId")); + map.put("phone" , object.getString("phone")); + + if (!secConfigService.isSignVerify(map , object.getString("sign"))) { + log.error("getRechargeProduct error!", "签名校验失败!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY); + } + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("userMobile" , object.getString("phone")); + + return ResponseMsgUtil.success(highUserCardService.getBlxCouponBalance(object.getString("phone")).getJSONArray("data")); + + } catch (Exception e) { + log.error("HighOpenApiController --> getRechargeProduct() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/queryJsParking", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "获取附近停车场") + public ResponseData queryJsParking(@RequestBody JSONObject object , HttpServletRequest request ) { + try { + + String ip = ""; + // 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for + if (request.getHeader("x-forwarded-for") == null) { + ip = request.getRemoteAddr(); + } else { + ip = request.getHeader("x-forwarded-for"); + } + + if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) { + log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!"); + } + + if ( + StringUtils.isBlank(object.getString("merchId")) || + StringUtils.isBlank(object.getString("gps")) || + StringUtils.isBlank(object.getString("range")) || + StringUtils.isBlank(object.getString("sign")) + ) { + log.error("getRechargeProduct error!", "请求参数校验失败!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR); + } + + ApiMerchants apiMerchants = apiMerchantsService.findByMchId(object.getString("merchId")); + + if (apiMerchants == null) { + log.error("getRechargeProduct error!", "帐户号错误!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_NOT_EXIST); + } + + if (!secConfigService.isConfig(OrderProductType.PRODUCT_TYPE13.getApiCode(), object.getString("merchId"))) { + log.error("getAllCities error!", "当前帐户无权限查询!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOT_AUTHORIZED, ""); + } + + Map map = new HashMap<>(); + map.put("apiKey" , apiMerchants.getApiKey()); + map.put("merchId" , object.getString("merchId")); + map.put("gps" , object.getString("gps")); + map.put("range" , object.getString("range")); + + if (!secConfigService.isSignVerify(map , object.getString("sign"))) { + log.error("getRechargeProduct error!", "签名校验失败!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY); + } + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("range" , object.getString("range")); + jsonObject.put("gps" , object.getString("gps")); + + JSONObject data = blxConfig.queryJsParking(jsonObject); + + if (data.getInteger("code") == 1) { + return ResponseMsgUtil.success(data.getJSONObject("data").getJSONArray("parkList")); + } + + return ResponseMsgUtil.success(null); + + } catch (Exception e) { + log.error("HighOpenApiController --> getRechargeProduct() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/queryJsOrderList", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "查询车牌订单列表信息") + public ResponseData queryJsOrderList(@RequestBody JSONObject object , HttpServletRequest request ) { + try { + + String ip = ""; + // 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for + if (request.getHeader("x-forwarded-for") == null) { + ip = request.getRemoteAddr(); + } else { + ip = request.getHeader("x-forwarded-for"); + } + + if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) { + log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!"); + } + + if ( + StringUtils.isBlank(object.getString("merchId")) || + StringUtils.isBlank(object.getString("carNo")) || + StringUtils.isBlank(object.getString("orderStatus")) || + StringUtils.isBlank(object.getString("sign")) + ) { + log.error("getRechargeProduct error!", "请求参数校验失败!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR); + } + + ApiMerchants apiMerchants = apiMerchantsService.findByMchId(object.getString("merchId")); + + if (apiMerchants == null) { + log.error("getRechargeProduct error!", "帐户号错误!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_NOT_EXIST); + } + + if (!secConfigService.isConfig(OrderProductType.PRODUCT_TYPE13.getApiCode(), object.getString("merchId"))) { + log.error("getAllCities error!", "当前帐户无权限查询!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOT_AUTHORIZED, ""); + } + + Map map = new HashMap<>(); + map.put("apiKey" , apiMerchants.getApiKey()); + map.put("merchId" , object.getString("merchId")); + map.put("carNo" , object.getString("carNo")); + map.put("orderStatus" , object.getString("orderStatus")); + + if (!secConfigService.isSignVerify(map , object.getString("sign"))) { + log.error("getRechargeProduct error!", "签名校验失败!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY); + } + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("carNo" , object.getString("carNo")); + jsonObject.put("orderStatus" , object.getString("orderStatus")); + + JSONObject data = blxConfig.queryJsOrderList(jsonObject); + + if (data.getInteger("code") == 1) { + return ResponseMsgUtil.success(data.getJSONObject("data").getJSONArray("ordlist")); + } + + return ResponseMsgUtil.success(null); + + } catch (Exception e) { + log.error("HighOpenApiController --> getRechargeProduct() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/creatOrder", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "停车添加订单") + public ResponseData creatOrder(@RequestBody JSONObject object , HttpServletRequest request ) { + try { + + String ip = ""; + // 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for + if (request.getHeader("x-forwarded-for") == null) { + ip = request.getRemoteAddr(); + } else { + ip = request.getHeader("x-forwarded-for"); + } + + if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) { + log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!"); + } + + if ( + StringUtils.isBlank(object.getString("merchId")) || + StringUtils.isBlank(object.getString("organizeCode")) || + StringUtils.isBlank(object.getString("userMobile")) || + StringUtils.isBlank(object.getString("userCouponCode")) || + StringUtils.isBlank(object.getString("parkOrderId")) || + StringUtils.isBlank(object.getString("orderType")) || + StringUtils.isBlank(object.getString("prePrice")) || + StringUtils.isBlank(object.getString("parkId")) || + StringUtils.isBlank(object.getString("parkName")) || + StringUtils.isBlank(object.getString("parkTime")) || + StringUtils.isBlank(object.getString("carSeatId")) || + StringUtils.isBlank(object.getString("inTime")) || + StringUtils.isBlank(object.getString("outTime")) || + StringUtils.isBlank(object.getString("carNo")) || + StringUtils.isBlank(object.getString("parkType")) || + StringUtils.isBlank(object.getString("sign")) + ) { + log.error("getRechargeProduct error!", "请求参数校验失败!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR); + } + + ApiMerchants apiMerchants = apiMerchantsService.findByMchId(object.getString("merchId")); + + if (apiMerchants == null) { + log.error("getRechargeProduct error!", "帐户号错误!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_NOT_EXIST); + } + + if (!secConfigService.isConfig(OrderProductType.PRODUCT_TYPE13.getApiCode(), object.getString("merchId"))) { + log.error("getAllCities error!", "当前帐户无权限查询!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOT_AUTHORIZED, ""); + } + + Map map = new HashMap<>(); + map.put("apiKey" , apiMerchants.getApiKey()); + map.put("merchId" , object.getString("merchId")); + map.put("organizeCode" , object.getString("organizeCode")); + map.put("userMobile" , object.getString("userMobile")); + map.put("userCouponCode" , object.getString("userCouponCode")); + map.put("parkOrderId" , object.getString("parkOrderId")); + map.put("orderType" , object.getString("orderType")); + map.put("prePrice" , object.getString("prePrice")); + map.put("parkId" , object.getString("parkId")); + map.put("parkName" , object.getString("parkName")); + map.put("parkTime" , object.getString("parkTime")); + map.put("carSeatId" , object.getString("carSeatId")); + map.put("inTime" , object.getString("inTime")); + map.put("outTime" , object.getString("outTime")); + map.put("carNo" , object.getString("carNo")); + map.put("parkType" , object.getString("parkType")); + + if (!secConfigService.isSignVerify(map , object.getString("sign"))) { + log.error("getRechargeProduct error!", "签名校验失败!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY); + } + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("carNo" , object.getString("carNo")); + jsonObject.put("orderStatus" , object.getString("orderStatus")); + + JSONObject data = blxConfig.queryJsOrderList(jsonObject); + + if (data.getInteger("code") == 1) { + return ResponseMsgUtil.success(data.getJSONObject("data").getJSONArray("ordlist")); + } + + return ResponseMsgUtil.success(null); + + } catch (Exception e) { + log.error("HighOpenApiController --> getRechargeProduct() error!", e); + return ResponseMsgUtil.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 229dd1a1..b009d86e 100644 --- a/v1/src/main/java/com/v1/controller/orderController.java +++ b/v1/src/main/java/com/v1/controller/orderController.java @@ -73,7 +73,7 @@ public class orderController { public ResponseData createOrder(@RequestBody JSONObject object , HttpServletRequest request ) { try { - String ip = ""; + String ip; // 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for if (request.getHeader("x-forwarded-for") == null) { ip = request.getRemoteAddr(); @@ -192,7 +192,7 @@ public class orderController { public ResponseData orderPay(@RequestBody JSONObject object , HttpServletRequest request) { try { - String ip = ""; + String ip; // 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for if (request.getHeader("x-forwarded-for") == null) { ip = request.getRemoteAddr(); @@ -259,7 +259,7 @@ public class orderController { public ResponseData queryOrderDetail(@RequestBody JSONObject object , HttpServletRequest request) { try { - String ip = ""; + String ip; // 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for if (request.getHeader("x-forwarded-for") == null) { ip = request.getRemoteAddr(); @@ -312,7 +312,7 @@ public class orderController { public ResponseData refund(@RequestBody JSONObject object , HttpServletRequest request) { try { - String ip = ""; + String ip; // 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for if (request.getHeader("x-forwarded-for") == null) { ip = request.getRemoteAddr(); @@ -433,23 +433,5 @@ public class orderController { } } - @RequestMapping(value = "/test", method = RequestMethod.POST) - @ResponseBody - @ApiOperation(value = "对外订单退款接口") - public ResponseData test() { - try { - - System.out.println("话费请求订单================================="); - - Thread.currentThread().sleep(30000); - - return ResponseMsgUtil.success("请求成功!"); - - } catch (Exception e) { - log.error("HighOpenApiController --> createOrder() error!", e); - return ResponseMsgUtil.exception(e); - } - } - }