diff --git a/hai-bweb/src/main/java/com/bweb/controller/CommonController.java b/hai-bweb/src/main/java/com/bweb/controller/CommonController.java index 1696f1eb..753e520b 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/CommonController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/CommonController.java @@ -390,24 +390,19 @@ public class CommonController { } } - @RequestMapping(value = "/getLogisticsMsg", method = RequestMethod.GET) + + @RequestMapping(value = "/getRegional", method = RequestMethod.GET) @ResponseBody - @ApiOperation(value = "根据快递单号查询物流信息") - public ResponseData getLogisticsMsg(@RequestParam(name = "num", required = true) String num) { + @ApiOperation(value = "获取区域信息") + public ResponseData getRegional() { try { - Object data = redisUtil.get("logisticsMsg" + num); - if (data == null) { - - JSONObject jsonObjects = CommonConfig.getLogisticsMsg(num); - - if (jsonObjects.getInteger("code") == 200 && jsonObjects.getBoolean("success")) { + Object data = redisUtil.get("regionalB"); - GoodsLogistics logistics = logisticsService.editLogistics((JSONObject) jsonObjects.get("data")); - redisUtil.set("logisticsMsg" + num , logistics ,21600); + if (data == null) { - return ResponseMsgUtil.success(logistics); - } + List jsonObjects = commonService.getRegional("key" , "title" , "children"); + redisUtil.set("regionalB", jsonObjects); return ResponseMsgUtil.success(jsonObjects); @@ -417,30 +412,19 @@ public class CommonController { } catch (Exception e) { - log.error("HighOrderController --> getUserOrderList() error!", e); + log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } - @RequestMapping(value = "/getRegional", method = RequestMethod.GET) + @RequestMapping(value = "/getIndustry", method = RequestMethod.GET) @ResponseBody - @ApiOperation(value = "获取区域信息") - public ResponseData getRegional() { + @ApiOperation(value = "获取行业信息") + public ResponseData getIndustry() { try { - Object data = redisUtil.get("regionalB"); - - if (data == null) { - - List jsonObjects = commonService.getRegional("key" , "title" , "children"); - redisUtil.set("regionalB", jsonObjects); - - return ResponseMsgUtil.success(jsonObjects); - - } else { - return ResponseMsgUtil.success(data); - } - + JSONObject object = commonService.getIndustry(); + return ResponseMsgUtil.success(object); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); diff --git a/hai-bweb/src/main/java/com/bweb/controller/Goods/GoodsDetailController.java b/hai-bweb/src/main/java/com/bweb/controller/Goods/GoodsDetailController.java index f2758f75..65378f8f 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/Goods/GoodsDetailController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/Goods/GoodsDetailController.java @@ -8,13 +8,17 @@ import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.security.SessionObject; import com.hai.common.security.UserCenter; +import com.hai.common.utils.DateUtil; import com.hai.common.utils.ResponseMsgUtil; import com.hai.entity.GoodsDetail; +import com.hai.entity.HighApprove; import com.hai.entity.HighGoodsType; +import com.hai.enum_type.ApproveType; import com.hai.goods.service.GoodsDetailService; import com.hai.model.ResponseData; import com.hai.model.UserInfoModel; +import com.hai.service.HighApproveService; import com.hai.service.HighGoodsTypeService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -44,6 +48,9 @@ public class GoodsDetailController { @Resource private HighGoodsTypeService highGoodsTypeService; + @Resource + private HighApproveService highApproveService; + @Autowired private UserCenter userCenter; @@ -55,15 +62,22 @@ public class GoodsDetailController { @RequestParam(value = "status", required = false) Integer status, @RequestParam(name = "pageNum", required = true) Integer pageNum, @RequestParam(name = "pageSize", required = true) Integer pageSize + , HttpServletRequest request ) { try { + SessionObject sessionObject = userCenter.getSessionObject(request); + UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); Map map = new HashMap<>(); map.put("title", title); map.put("status", status); + if (userInfoModel.getSecUser().getExt3() != null) { + map.put("opId" , userInfoModel.getSecUser().getId()); + } + PageHelper.startPage(pageNum,pageSize); List list = goodsDetailService.getGoodsDetailList(map); @@ -246,7 +260,23 @@ public class GoodsDetailController { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前状态错误,无法操作!"); } - goodsDetail.setStatus(goodsDetail.getStatus() == 1 ? 2:1); + if (goodsDetail.getStatus() == 2) { + HighApprove approve = new HighApprove(); + approve.setObjectType(ApproveType.GOODS_UP_SHELF_APPROVE.getType()); + approve.setObjectId(id); + approve.setObjectName(goodsDetail.getName()); + approve.setApproveSerialNo(DateUtil.date2String(new Date(), "yyyyMMddHHmmss")); + approve.setStatus(1); + approve.setCreateTime(new Date()); + approve.setUpdateTime(new Date()); + approve.setSubmitOperatorId(userInfoModel.getSecUser().getId()); + approve.setSubmitOperatorName(userInfoModel.getSecUser().getUserName()); + + // 增加审批 + highApproveService.insertApprove(approve); + } + + goodsDetail.setStatus(goodsDetail.getStatus() == 1 ? 2:3); goodsDetail.setUpdateTime(new Date()); goodsDetail.setOpId(userInfoModel.getSecUser().getId()); goodsDetail.setOpName(userInfoModel.getSecUser().getLoginName()); diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighAgentController.java b/hai-bweb/src/main/java/com/bweb/controller/HighAgentController.java index 6c77153c..c5820cd5 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighAgentController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighAgentController.java @@ -323,6 +323,7 @@ public class HighAgentController { map.put("status", Integer.toString(status)); } + if (type != null) { map.put("type", Integer.toString(type)); } 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 608eeaac..2bbcb53f 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java @@ -1 +1 @@ - package com.bweb.controller; import com.alibaba.excel.EasyExcel; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.alipay.api.domain.ForbbidenTime; import com.alipay.api.domain.OfferObject; import com.bweb.config.SysConst; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.utils.*; import com.hai.config.*; import com.hai.entity.*; import com.hai.model.OrderRefundModel; import com.hai.model.ResponseData; import com.hai.order.model.ExportOrderMobileModel; import com.hai.order.model.OrderThirdPartyModel; import com.hai.order.service.OrderRefundService; import com.hai.order.service.OrderService; import com.hai.order.type.*; import com.hai.order.utils.OrderUtil; import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.io.File; import java.math.BigDecimal; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/test") @Api(value = "订单接口") public class HighTestController { private static Logger log = LoggerFactory.getLogger(HighTestController.class); @Resource private OutRechargeOrderService outRechargeOrderService; @Autowired private OutRechargeChildOrderService childOrderService; @Resource private CommonService commonService; @Resource private OrderService orderService; @Resource private HighOrderService highOrderService; @Autowired private RedisTemplate redisTemplate; @RequestMapping(value="/resolveResponse",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "解析") public ResponseData resolveResponse( @RequestParam(name = "data", required = false) String data ) { try { JSONObject cardInfoObject = HuiLianTongUnionCardConfig.resolveResponse(data); return ResponseMsgUtil.success(cardInfoObject); } catch (Exception e) { log.error("getUserByTelephone",e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getHuiLianTongCardConsume", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询汇联通工会卡消费记录") public ResponseData getHuiLianTongCardConsume(@RequestParam(name = "businessType", required = true) String businessType, @RequestParam(name = "cardNo", required = true) String cardNo, @RequestParam(name = "sdate", required = true) Long sdate, @RequestParam(name = "edate", required = true) Long edate, @RequestParam(name = "pageNum", required = true) Integer pageNum, @RequestParam(name = "pageSize", required = true) Integer pageSize, HttpServletRequest request) { try { JSONObject consumptionRecord = HuiLianTongUnionCardConfig.queryConsumptionRecordByBusiness(businessType, cardNo, sdate, edate, pageNum, pageSize); if (StringUtils.isBlank(consumptionRecord.getString("data"))) { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQUEST_ERROR, ""); } JSONArray array = HuiLianTongUnionCardConfig.resolveResponse(consumptionRecord.getString("data")).getJSONArray("records"); return ResponseMsgUtil.success(array); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardConsume() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getStationStores", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取油站") public ResponseData getStationStores() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "4B1DF80A2D64376D2807ACA6CFEDE8AA"); mapPost.put("merchId" , "20220896102"); Map map = new HashMap<>(); map.put("apiKey" , "4B1DF80A2D64376D2807ACA6CFEDE8AA"); map.put("merchId" , "20220896102"); 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/refuelOnline/getStationStore" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getRechargeProduct", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取充值产品") public ResponseData getRechargeProduct() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/mobileRecharge/getMobileProduct" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getAllCities", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询可用城市") public ResponseData getAllCities() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/apiMerchants/getAllCities" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/starbucksStore", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询星巴克门店") public ResponseData starbucksStore() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("lat" , "29.56900"); mapPost.put("lon" , "106.55843"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("lat" , "29.56900"); map.put("lon" , "106.55843"); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/starbucks/starbucksStore" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/starbucksProducts", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询星巴克商品") public ResponseData starbucksProducts() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/starbucks/starbucksProducts" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/kfcStoresList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询肯德基门店") public ResponseData kfcStoresList() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/kfc/kfcStoresList" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/kfcProductByStoreCode", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据门店编码查询KFC产品") public ResponseData kfcProductByStoreCode(@RequestParam(name = "storeCode", required = true) String storeCode) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("storeCode" , storeCode); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("storeCode" , storeCode); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/kfc/kfcProductByStoreCode" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getRegional", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询区域信息") public ResponseData getRegional() { try { return ResponseMsgUtil.success(commonService.getRegional("code" , "name" , "childs")); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/memberProducts", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询会员产品") public ResponseData memberProducts() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/memberRecharge/memberProducts" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/createOrder", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "创建订单") public ResponseData createOrder(@RequestBody JSONObject object) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("timetable" , new Date().getTime()); mapPost.put("orderNo" , "TEST" + OrderUtil.generateOrderNo()); mapPost.put("productType" , object.getString("productType")); mapPost.put("notifyUrl" , "test"); mapPost.put("content" , object.toString()); System.out.println(mapPost); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("timetable" , mapPost.get("timetable").toString()); map.put("orderNo" , mapPost.get("orderNo")); map.put("productType" , object.getString("productType")); map.put("content" , object.toString()); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/order/createOrder" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/payOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "支付订单") public ResponseData payOrder(@RequestParam(name = "mchOrderNo", required = true) String mchOrderNo) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("mchOrderNo" , mchOrderNo); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("mchOrderNo" , mchOrderNo); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/order/orderPay" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryOrderDetail", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询订单详情") public ResponseData queryOrderDetail(@RequestParam(name = "mchOrderNo", required = true) String mchOrderNo) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("mchOrderNo" , mchOrderNo); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("mchOrderNo" , mchOrderNo); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/order/queryOrderDetail" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/phoneBillOrderError", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "话费订单错误") public ResponseData phoneBillOrderError() { try { log.info("处理话费订单定时任务开始"); Map map = new HashMap<>(); map.put("payStatus", String.valueOf(102)); map.put("rechargeStatus", String.valueOf(201)); List orderList = outRechargeOrderService.getListRechargeOrder(map); log.info("处理话费订单条数:" + orderList.size()); if (orderList.size() > 0) { for (OutRechargeOrder order : orderList) { // 查询子订单 HighOrder highOrder = highOrderService.getOrderByOrderNo(order.getOrderNo()); // 判断订单是否可以继续充值 1:满足继续充值条件 2:订单满足退款条件 3:订单不可以退款不可以继续充值 4:订单异常 5:订单充值完成 int orderStatus = outRechargeOrderService.orderWhetherRecharge(order); log.info("处理话费订单:" + orderStatus + "订单号" + order.getOrderNo()); if (orderStatus == 2 && highOrder.getOrderStatus() == 4) { order.setRechargeStatus(203); order.setPayStatus(105); } if (orderStatus == 5 && highOrder.getOrderStatus() == 3) { order.setRechargeStatus(202); order.setPayStatus(100); } outRechargeOrderService.updateOrder(order); } } return ResponseMsgUtil.success(""); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/mobileChildOrderByOrderNo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据订单号修改话费订单状态") public ResponseData mobileChildOrderByOrderNo(@RequestParam(name = "orderNo", required = true) String orderNo) { try { OutRechargeOrder order = outRechargeOrderService.findByOrderNo(orderNo); // 查询子订单 HighOrder highOrder = highOrderService.getOrderByOrderNo(order.getOrderNo()); // 判断订单是否可以继续充值 1:满足继续充值条件 2:订单满足退款条件 3:订单不可以退款不可以继续充值 4:订单异常 5:订单充值完成 int orderStatus = outRechargeOrderService.orderWhetherRecharge(order); log.info("处理话费订单:" + orderStatus + "订单号" + order.getOrderNo()); if (orderStatus == 2 && highOrder.getOrderStatus() == 4) { order.setRechargeStatus(203); order.setPayStatus(105); } if (orderStatus == 5 && highOrder.getOrderStatus() == 3) { order.setRechargeStatus(202); order.setPayStatus(100); } outRechargeOrderService.updateOrder(order); return ResponseMsgUtil.success(""); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } // 退款订单号 @RequestMapping(value = "/deposit", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "工会卡充值") public ResponseData deposit(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); HighChildOrder highChildOrder = order.getHighChildOrderList().get(0); if (order.getOrderStatus() != 2) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单状态错误"); } // 汇联通充值 String goodsDesc = "汇联通充值"+order.getPayPrice()+"元"; String tranDesc = ""; String businessType = "ghk_deposit"; String orderNoAgain = OrderUtil.generateOrderNo(); order.setOrderStatus(3); order.setRemarks("工会卡再次充值订单号" + orderNoAgain); highOrderService.updateOrder(order); // 汇联通卡充值 JSONObject deposit = HuiLianTongUnionCardConfig.deposit(orderNoAgain, highChildOrder.getGoodsSpecName(), order.getPayPrice(), businessType, order.getPaySerialNo(), goodsDesc); return ResponseMsgUtil.success( HuiLianTongUnionCardConfig.resolveResponse(deposit.getString("data"))); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/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 = "/mobileDw", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "话费订单下载") public ResponseData mobileDw(@RequestParam(name = "createTimeS", required = false) String createTimeS, @RequestParam(name = "createTimeE", required = false) String createTimeE, @RequestParam(name = "refundTimeS", required = false) String refundTimeS, @RequestParam(name = "refundTimeE", required = false) String refundTimeE ) { try { Map map = new HashMap<>(); map.put("productType" , 9); map.put("createTimeS" , createTimeS); map.put("createTimeE" , createTimeE); map.put("refundTimeS" , refundTimeS); map.put("refundTimeE" , refundTimeE); List order = highOrderService.getOrderListNotChild(map); List list = new ArrayList<>(); ExportOrderMobileModel model; for (HighOrder highOrder : order) { model = new ExportOrderMobileModel(); OutRechargeOrder rechargeOrder = outRechargeOrderService.findByOrderNoNotChild(highOrder.getOrderNo()); if (rechargeOrder != null) { OutRechargeChildOrder childOrder = mobileChildOrderHandle(highOrder,rechargeOrder); model.setRechargeOrderNo(rechargeOrder.getOrderNo()); if (childOrder != null) { model.setChildOrderNo(childOrder.getOrderNo()); if (childOrder.getRechargePlatform() != null) { model.setRechargePlatform(RechargePlatformType.getDataByType(childOrder.getRechargePlatform()).getName()); } model.setRemark(childOrder.getExt1()); } } model.setFinishTime(highOrder.getFinishTime()); model.setOrderStatus(OrderStatus.getDataByType(highOrder.getOrderStatus()).getName()); model.setMemPhone(highOrder.getMemPhone()); model.setCreateTime(highOrder.getCreateTime()); model.setTitle(highOrder.getTitle()); model.setPayablePrice(highOrder.getPayablePrice()); model.setRefundTime(highOrder.getRefundTime()); model.setPayPrice(highOrder.getPayPrice()); model.setOrderNo(highOrder.getOrderNo()); model.setMemCardNo(highOrder.getMemCardNo()); if (highOrder.getPayType() != null) { model.setPayType(OrderPayType.getDataByType(highOrder.getPayType()).getName()); } list.add(model); } String fileUrl = SysConst.getSysConfig().getFileUrl() + "temporary/"; String pathName = System.currentTimeMillis()+".xlsx"; File file = new File(fileUrl); if (!file.exists()) { file.mkdirs(); } EasyExcel.write(fileUrl+pathName) .head(ExportOrderMobileModel.class) .sheet("话费交易订单") .doWrite(list); return ResponseMsgUtil.success(pathName); } catch (Exception e) { log.error("HighUserCardController --> oilCardRefund() error!", e); return ResponseMsgUtil.exception(e); } } public OutRechargeChildOrder mobileChildOrderHandle(HighOrder highOrder , OutRechargeOrder outRechargeOrder) { // 组装查询子订单数据 Map childOrderMap101 = new HashMap<>(); childOrderMap101.put("parent_order_id", outRechargeOrder.getId()); childOrderMap101.put("status", "101,102"); // 查询充值订单 List childOrders = childOrderService.getListRechargeChildOrder(childOrderMap101); OutRechargeChildOrder childOrder; // 判读是否存在多个充值中的订单 if (childOrders.size() > 0) { childOrder = childOrders.get(0); if (childOrders.size() > 1) { childOrder.setExt1("当前订单存在多个充值订单"); } } else { childOrder = childOrderService.findByOrderId(outRechargeOrder.getId()); if (childOrder != null && highOrder != null && childOrder.getStatus() != null && highOrder.getOrderStatus() != null) { if (highOrder.getOrderStatus() == 2 && childOrder.getStatus() != 102) { childOrder.setExt1("主订单充值中,但是充值订单状态不为充值中"); } if (highOrder.getOrderStatus() == 3 && childOrder.getStatus() != 101) { childOrder.setExt1("主订单充值成功,但是充值订单状态不为充值成功"); } if (highOrder.getOrderStatus() == 4 && !(childOrder.getStatus() == 103 || childOrder.getStatus() == 104)) { childOrder.setExt1("主订单退款,但是充值订单状态不为退款"); } } } return childOrder; } @RequestMapping(value = "/externalOrderRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "对外订单退款") public ResponseData externalOrderRefund(@RequestParam(name = "paySerialNo", required = true) String paySerialNo, @RequestParam(name = "WxMchId", required = true) String WxMchId, @RequestParam(name = "payRealPrice", required = true) String payRealPrice) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "B94B5E62807FA56A7260AB581D8A1B48"); mapPost.put("merchId" , "20230394901"); mapPost.put("paySerialNo" , paySerialNo); mapPost.put("wxMchId" , WxMchId); mapPost.put("payRealPrice" , payRealPrice); mapPost.put("refundPrice" , payRealPrice); Map map = new HashMap<>(); map.put("apiKey" , "B94B5E62807FA56A7260AB581D8A1B48"); map.put("merchId" , "20230394901"); map.put("paySerialNo" , paySerialNo); map.put("wxMchId" , WxMchId); map.put("payRealPrice" , payRealPrice); map.put("refundPrice" , payRealPrice); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("https://hsg.dctpay.com/v1/order/externalOrderRefund" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } } \ No newline at end of file + package com.bweb.controller; import com.alibaba.excel.EasyExcel; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.alipay.api.domain.ForbbidenTime; import com.alipay.api.domain.OfferObject; import com.bweb.config.SysConst; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.utils.*; import com.hai.config.*; import com.hai.entity.*; import com.hai.model.OrderRefundModel; import com.hai.model.ResponseData; import com.hai.order.model.ExportOrderMobileModel; import com.hai.order.model.OrderThirdPartyModel; import com.hai.order.service.OrderRefundService; import com.hai.order.service.OrderService; import com.hai.order.type.*; import com.hai.order.utils.OrderUtil; import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.io.File; import java.math.BigDecimal; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/test") @Api(value = "订单接口") public class HighTestController { private static Logger log = LoggerFactory.getLogger(HighTestController.class); @Resource private OutRechargeOrderService outRechargeOrderService; @Autowired private OutRechargeChildOrderService childOrderService; @Resource private BsOrderRebateService bsOrderRebateService; @Resource private CommonService commonService; @Resource private OrderService orderService; @Resource private HighOrderService highOrderService; @Autowired private RedisTemplate redisTemplate; @RequestMapping(value="/resolveResponse",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "解析") public ResponseData resolveResponse( @RequestParam(name = "data", required = false) String data ) { try { JSONObject cardInfoObject = HuiLianTongUnionCardConfig.resolveResponse(data); return ResponseMsgUtil.success(cardInfoObject); } catch (Exception e) { log.error("getUserByTelephone",e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getHuiLianTongCardConsume", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询汇联通工会卡消费记录") public ResponseData getHuiLianTongCardConsume(@RequestParam(name = "businessType", required = true) String businessType, @RequestParam(name = "cardNo", required = true) String cardNo, @RequestParam(name = "sdate", required = true) Long sdate, @RequestParam(name = "edate", required = true) Long edate, @RequestParam(name = "pageNum", required = true) Integer pageNum, @RequestParam(name = "pageSize", required = true) Integer pageSize, HttpServletRequest request) { try { JSONObject consumptionRecord = HuiLianTongUnionCardConfig.queryConsumptionRecordByBusiness(businessType, cardNo, sdate, edate, pageNum, pageSize); if (StringUtils.isBlank(consumptionRecord.getString("data"))) { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQUEST_ERROR, ""); } JSONArray array = HuiLianTongUnionCardConfig.resolveResponse(consumptionRecord.getString("data")).getJSONArray("records"); return ResponseMsgUtil.success(array); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardConsume() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getStationStores", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取油站") public ResponseData getStationStores() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "4B1DF80A2D64376D2807ACA6CFEDE8AA"); mapPost.put("merchId" , "20220896102"); Map map = new HashMap<>(); map.put("apiKey" , "4B1DF80A2D64376D2807ACA6CFEDE8AA"); map.put("merchId" , "20220896102"); 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/refuelOnline/getStationStore" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getRechargeProduct", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取充值产品") public ResponseData getRechargeProduct() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/mobileRecharge/getMobileProduct" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getAllCities", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询可用城市") public ResponseData getAllCities() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/apiMerchants/getAllCities" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/starbucksStore", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询星巴克门店") public ResponseData starbucksStore() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("lat" , "29.56900"); mapPost.put("lon" , "106.55843"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("lat" , "29.56900"); map.put("lon" , "106.55843"); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/starbucks/starbucksStore" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/starbucksProducts", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询星巴克商品") public ResponseData starbucksProducts() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/starbucks/starbucksProducts" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/kfcStoresList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询肯德基门店") public ResponseData kfcStoresList() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/kfc/kfcStoresList" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/kfcProductByStoreCode", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据门店编码查询KFC产品") public ResponseData kfcProductByStoreCode(@RequestParam(name = "storeCode", required = true) String storeCode) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("storeCode" , storeCode); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("storeCode" , storeCode); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/kfc/kfcProductByStoreCode" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getRegional", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询区域信息") public ResponseData getRegional() { try { return ResponseMsgUtil.success(commonService.getRegional("code" , "name" , "childs")); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/memberProducts", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询会员产品") public ResponseData memberProducts() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/memberRecharge/memberProducts" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/createOrder", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "创建订单") public ResponseData createOrder(@RequestBody JSONObject object) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("timetable" , new Date().getTime()); mapPost.put("orderNo" , "TEST" + OrderUtil.generateOrderNo()); mapPost.put("productType" , object.getString("productType")); mapPost.put("notifyUrl" , "test"); mapPost.put("content" , object.toString()); System.out.println(mapPost); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("timetable" , mapPost.get("timetable").toString()); map.put("orderNo" , mapPost.get("orderNo")); map.put("productType" , object.getString("productType")); map.put("content" , object.toString()); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/order/createOrder" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/payOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "支付订单") public ResponseData payOrder(@RequestParam(name = "mchOrderNo", required = true) String mchOrderNo) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("mchOrderNo" , mchOrderNo); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("mchOrderNo" , mchOrderNo); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/order/orderPay" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryOrderDetail", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询订单详情") public ResponseData queryOrderDetail(@RequestParam(name = "mchOrderNo", required = true) String mchOrderNo) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("mchOrderNo" , mchOrderNo); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("mchOrderNo" , mchOrderNo); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/order/queryOrderDetail" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/mobileChildOrderByOrderNo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据订单号修改话费订单状态") public ResponseData mobileChildOrderByOrderNo(@RequestParam(name = "orderNo", required = true) String orderNo) { try { OutRechargeOrder order = outRechargeOrderService.findByOrderNo(orderNo); // 查询子订单 HighOrder highOrder = highOrderService.getOrderByOrderNo(order.getOrderNo()); // 判断订单是否可以继续充值 1:满足继续充值条件 2:订单满足退款条件 3:订单不可以退款不可以继续充值 4:订单异常 5:订单充值完成 int orderStatus = outRechargeOrderService.orderWhetherRecharge(order); log.info("处理话费订单:" + orderStatus + "订单号" + order.getOrderNo()); if (orderStatus == 2 && highOrder.getOrderStatus() == 4) { order.setRechargeStatus(203); order.setPayStatus(105); } if (orderStatus == 5 && highOrder.getOrderStatus() == 3) { order.setRechargeStatus(202); order.setPayStatus(100); } outRechargeOrderService.updateOrder(order); return ResponseMsgUtil.success(""); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } // 退款订单号 @RequestMapping(value = "/deposit", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "工会卡充值") public ResponseData deposit(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); HighChildOrder highChildOrder = order.getHighChildOrderList().get(0); if (order.getOrderStatus() != 2) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单状态错误"); } // 汇联通充值 String goodsDesc = "汇联通充值"+order.getPayPrice()+"元"; String tranDesc = ""; String businessType = "ghk_deposit"; String orderNoAgain = OrderUtil.generateOrderNo(); order.setOrderStatus(3); order.setRemarks("工会卡再次充值订单号" + orderNoAgain); highOrderService.updateOrder(order); // 汇联通卡充值 JSONObject deposit = HuiLianTongUnionCardConfig.deposit(orderNoAgain, highChildOrder.getGoodsSpecName(), order.getPayPrice(), businessType, order.getPaySerialNo(), goodsDesc); return ResponseMsgUtil.success( HuiLianTongUnionCardConfig.resolveResponse(deposit.getString("data"))); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/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 = "/mobileDw", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "话费订单下载") public ResponseData mobileDw(@RequestParam(name = "createTimeS", required = false) String createTimeS, @RequestParam(name = "createTimeE", required = false) String createTimeE, @RequestParam(name = "refundTimeS", required = false) String refundTimeS, @RequestParam(name = "refundTimeE", required = false) String refundTimeE ) { try { Map map = new HashMap<>(); map.put("productType" , 9); map.put("createTimeS" , createTimeS); map.put("createTimeE" , createTimeE); map.put("refundTimeS" , refundTimeS); map.put("refundTimeE" , refundTimeE); List order = highOrderService.getOrderListNotChild(map); List list = new ArrayList<>(); ExportOrderMobileModel model; for (HighOrder highOrder : order) { model = new ExportOrderMobileModel(); OutRechargeOrder rechargeOrder = outRechargeOrderService.findByOrderNoNotChild(highOrder.getOrderNo()); if (rechargeOrder != null) { OutRechargeChildOrder childOrder = mobileChildOrderHandle(highOrder,rechargeOrder); model.setRechargeOrderNo(rechargeOrder.getOrderNo()); if (childOrder != null) { model.setChildOrderNo(childOrder.getOrderNo()); if (childOrder.getRechargePlatform() != null) { model.setRechargePlatform(RechargePlatformType.getDataByType(childOrder.getRechargePlatform()).getName()); } model.setRemark(childOrder.getExt1()); } } model.setFinishTime(highOrder.getFinishTime()); model.setOrderStatus(OrderStatus.getDataByType(highOrder.getOrderStatus()).getName()); model.setMemPhone(highOrder.getMemPhone()); model.setCreateTime(highOrder.getCreateTime()); model.setTitle(highOrder.getTitle()); model.setPayablePrice(highOrder.getPayablePrice()); model.setRefundTime(highOrder.getRefundTime()); model.setPayPrice(highOrder.getPayPrice()); model.setOrderNo(highOrder.getOrderNo()); model.setMemCardNo(highOrder.getMemCardNo()); if (highOrder.getPayType() != null) { model.setPayType(OrderPayType.getDataByType(highOrder.getPayType()).getName()); } list.add(model); } String fileUrl = SysConst.getSysConfig().getFileUrl() + "temporary/"; String pathName = System.currentTimeMillis()+".xlsx"; File file = new File(fileUrl); if (!file.exists()) { file.mkdirs(); } EasyExcel.write(fileUrl+pathName) .head(ExportOrderMobileModel.class) .sheet("话费交易订单") .doWrite(list); return ResponseMsgUtil.success(pathName); } catch (Exception e) { log.error("HighUserCardController --> oilCardRefund() error!", e); return ResponseMsgUtil.exception(e); } } public OutRechargeChildOrder mobileChildOrderHandle(HighOrder highOrder , OutRechargeOrder outRechargeOrder) { // 组装查询子订单数据 Map childOrderMap101 = new HashMap<>(); childOrderMap101.put("parent_order_id", outRechargeOrder.getId()); childOrderMap101.put("status", "101,102"); // 查询充值订单 List childOrders = childOrderService.getListRechargeChildOrder(childOrderMap101); OutRechargeChildOrder childOrder; // 判读是否存在多个充值中的订单 if (childOrders.size() > 0) { childOrder = childOrders.get(0); if (childOrders.size() > 1) { childOrder.setExt1("当前订单存在多个充值订单"); } } else { childOrder = childOrderService.findByOrderId(outRechargeOrder.getId()); if (childOrder != null && highOrder != null && childOrder.getStatus() != null && highOrder.getOrderStatus() != null) { if (highOrder.getOrderStatus() == 2 && childOrder.getStatus() != 102) { childOrder.setExt1("主订单充值中,但是充值订单状态不为充值中"); } if (highOrder.getOrderStatus() == 3 && childOrder.getStatus() != 101) { childOrder.setExt1("主订单充值成功,但是充值订单状态不为充值成功"); } if (highOrder.getOrderStatus() == 4 && !(childOrder.getStatus() == 103 || childOrder.getStatus() == 104)) { childOrder.setExt1("主订单退款,但是充值订单状态不为退款"); } } } return childOrder; } @RequestMapping(value = "/externalOrderRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "对外订单退款") public ResponseData externalOrderRefund(@RequestParam(name = "paySerialNo", required = true) String paySerialNo, @RequestParam(name = "WxMchId", required = true) String WxMchId, @RequestParam(name = "payRealPrice", required = true) String payRealPrice) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "B94B5E62807FA56A7260AB581D8A1B48"); mapPost.put("merchId" , "20230394901"); mapPost.put("paySerialNo" , paySerialNo); mapPost.put("wxMchId" , WxMchId); mapPost.put("payRealPrice" , payRealPrice); mapPost.put("refundPrice" , payRealPrice); Map map = new HashMap<>(); map.put("apiKey" , "B94B5E62807FA56A7260AB581D8A1B48"); map.put("merchId" , "20230394901"); map.put("paySerialNo" , paySerialNo); map.put("wxMchId" , WxMchId); map.put("payRealPrice" , payRealPrice); map.put("refundPrice" , payRealPrice); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("https://hsg.dctpay.com/v1/order/externalOrderRefund" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/test", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "测试") public ResponseData test() { try { JSONObject object = new JSONObject(); object.put("productType" , 102); object.put("userId" , 366); object.put("orderNo" , "202131231237812367126"); object.put("orderId" , 892 ); object.put("title" , "南充大饭店"); object.put("createTime" , new Date()); object.put("payRealPrice" , 50); bsOrderRebateService.insertOrderRebate(object); return ResponseMsgUtil.success(""); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } } \ No newline at end of file diff --git a/hai-bweb/src/main/java/com/bweb/controller/SecUserController.java b/hai-bweb/src/main/java/com/bweb/controller/SecUserController.java index 59093901..efbea380 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/SecUserController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/SecUserController.java @@ -193,6 +193,7 @@ public class SecUserController { secUser.setAdminFlag(user.getAdminFlag()); secUser.setObjectType(user.getObjectType()); secUser.setObjectId(secUser.getCompanyId()); + secUser.setExt3(user.getExt3()); secUser.setStatus(user.getStatus()); secUser.setCreateTime(user.getCreateTime()); secUser.setUpdateTime(new Date()); diff --git a/hai-cweb/src/main/java/com/cweb/controller/CommonController.java b/hai-cweb/src/main/java/com/cweb/controller/CommonController.java index 4934952d..1a3caff8 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/CommonController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/CommonController.java @@ -406,4 +406,19 @@ public class CommonController { } } + @RequestMapping(value = "/getIndustry", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "获取行业信息") + public ResponseData getIndustry() { + try { + + JSONObject object = commonService.getIndustry(); + return ResponseMsgUtil.success(object.getJSONArray("return_data")); + + } catch (Exception e) { + log.error("HighOrderController --> unionStagingPay() 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 7ad6b83c..60876085 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 @@ -209,26 +209,7 @@ public class GoodsController { public ResponseData getLogisticsMsg(@RequestParam(name = "num", required = true) String num) { try { - Object data = redisUtil.get("logisticsMsg" + num); - if (data == null) { - - JSONObject jsonObjects = CommonConfig.getLogisticsMsg(num); - - if (jsonObjects.getInteger("code") == 200 && jsonObjects.getBoolean("success")) { - - GoodsLogistics logistics = logisticsService.editLogistics((JSONObject) jsonObjects.get("data")); - redisUtil.set("logisticsMsg" + num , logistics ,21600); - redisUtil.set("logisticsMsgOl" + num , logistics ,21600); - - return ResponseMsgUtil.success(logistics); - } - - return ResponseMsgUtil.success(jsonObjects); - - } else { - return ResponseMsgUtil.success(data); - } - + return ResponseMsgUtil.success(logisticsService.getLogisticsMsg(num)); } catch (Exception e) { log.error("HighOrderController --> getUserOrderList() error!", e); diff --git a/hai-cweb/src/main/java/com/cweb/controller/Goods/ShoppingCartController.java b/hai-cweb/src/main/java/com/cweb/controller/Goods/ShoppingCartController.java index 620c105d..6e969925 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/Goods/ShoppingCartController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/Goods/ShoppingCartController.java @@ -1,5 +1,6 @@ package com.cweb.controller.Goods; +import com.alipay.api.domain.Shop; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; @@ -76,6 +77,16 @@ public class ShoppingCartController { GoodsSku sku = goodsSkuService.findGoodsSkuById(Long.valueOf(shoppingCart.getSku())); shoppingCartModel.setSkuName(sku.getName()); + GoodsDetail goodsDetail = goodsDetailService.findGoodsDetailById(shoppingCart.getGoodsId()); + + if (goodsDetail.getStatus() != 1) { + shoppingCartModel.setLoseEfficacy(true); + } + + if (sku.getStock() < Integer.parseInt(shoppingCart.getNum())) { + shoppingCartModel.setNum(String.valueOf(sku.getStock())); + } + shoppingCartModels.add(shoppingCartModel); } @@ -117,9 +128,16 @@ public class ShoppingCartController { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "添加商品不存在"); } + if (sku.getStock() < Integer.parseInt(shoppingCart.getNum())) { + log.error("GoodsDetailController -> insertProduct() error!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "超过最大库存!"); + } + shoppingCart.setUserId(userInfoModel.getHighUser().getId()); shoppingCart.setTitle(goodsDetail.getName()); - shoppingCart.setImg(goodsDetail.getListImg()); + shoppingCart.setImg(sku.getShowImg()); + shoppingCart.setOriginalPrice(sku.getOriginalPrice()); + shoppingCart.setLoseEfficacy(false); shoppingCart.setPrice(sku.getPrice()); shoppingCart.setCreateTime(new Date()); shoppingCart.setUpdateTime(new Date()); @@ -190,21 +208,20 @@ public class ShoppingCartController { GoodsShoppingCart shoppingCart = shoppingCartService.findShoppingCartById(id); - - - if (shoppingCart == null) { - log.error("GoodsDetailController -> findGoodsDetailById() error!"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到相关信息"); - } + GoodsSku sku = goodsSkuService.findGoodsSkuById(Long.valueOf(shoppingCart.getSku())); if (!Objects.equals(userInfoModel.getHighUser().getId(), shoppingCart.getUserId())) { log.error("GoodsDetailController -> findGoodsDetailById() error!"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "用户信息错误"); } + if (sku.getStock() < Integer.parseInt(num)) { + log.error("GoodsDetailController -> insertProduct() error!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "超过最大库存!"); + } + shoppingCart.setNum(num); shoppingCart.setUpdateTime(new Date()); - shoppingCartService.updateShoppingCart(shoppingCart); return ResponseMsgUtil.success("增加成功"); diff --git a/hai-order/src/main/java/com/web/controller/OrderController.java b/hai-order/src/main/java/com/web/controller/OrderController.java index fcf66195..86510ba1 100644 --- a/hai-order/src/main/java/com/web/controller/OrderController.java +++ b/hai-order/src/main/java/com/web/controller/OrderController.java @@ -7,10 +7,12 @@ 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.common.utils.BaiduUtils; import com.hai.common.utils.ResponseMsgUtil; -import com.hai.entity.HighChildOrder; -import com.hai.entity.HighOrder; -import com.hai.entity.HighUser; +import com.hai.entity.*; +import com.hai.goods.service.DeliveryAddressService; +import com.hai.goods.service.GoodsOrderExtService; +import com.hai.model.GoodsOrderModel; import com.hai.model.HighUserModel; import com.hai.model.ResponseData; import com.hai.order.model.CreateOrderChildModel; @@ -28,6 +30,7 @@ import org.apache.commons.lang3.StringUtils; import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; @@ -50,6 +53,12 @@ public class OrderController { @Resource private UserCenter userCenter; + @Resource + private GoodsOrderExtService goodsOrderExtService; + + @Resource + private DeliveryAddressService deliveryAddressService; + @RequestMapping(value="/create",method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "创建订单") @@ -70,14 +79,13 @@ public class OrderController { body.setMemName(userModel.getHighUser().getName()); body.setMemPhone(userModel.getHighUser().getPhone()); - if (body == null - || body.getChildOrderList() == null - || body.getChildOrderList().size() == 0) { + if (body.getChildOrderList() == null || body.getChildOrderList().size() == 0) { log.error("OrderController -> create() error!",""); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } for (CreateOrderChildModel childModel : body.getChildOrderList()) { + childModel.setMemId(body.getMemId()); childModel.setMemName(body.getMemName()); childModel.setMemPhone(body.getMemPhone()); @@ -166,7 +174,21 @@ public class OrderController { public ResponseData getDetailByOrderNo(@RequestParam(name = "orderNo", required = true) String orderNo) { try { - return ResponseMsgUtil.success(orderService.getOrderDetailByNo(orderNo)); + HighOrder highOrder = orderService.getOrderDetailByNo(orderNo); + + if (highOrder.getProductType() == 12) { + GoodsOrder order = goodsOrderExtService.findGoodsOrder(highOrder.getOrderNo()); + GoodsDeliveryAddress deliveryAddress = deliveryAddressService.findDeliveryAddressById(order.getDeliveryAddressId()); + + GoodsOrderModel goodsOrderModel = new GoodsOrderModel(); + BeanUtils.copyProperties(highOrder , goodsOrderModel); + goodsOrderModel.setGoodsOrder(order); + goodsOrderModel.setGoodsDeliveryAddress(deliveryAddress); + return ResponseMsgUtil.success(goodsOrderModel); + + } + + return ResponseMsgUtil.success(highOrder); } catch (Exception e) { log.error("OrderController -> getDetailByOrderNo() error!",e); diff --git a/hai-order/src/main/java/com/web/controller/OrderPayController.java b/hai-order/src/main/java/com/web/controller/OrderPayController.java index fd5e79fb..7de9379b 100644 --- a/hai-order/src/main/java/com/web/controller/OrderPayController.java +++ b/hai-order/src/main/java/com/web/controller/OrderPayController.java @@ -256,7 +256,9 @@ public class OrderPayController { } else if (order.getProductType().equals(OrderProductType.PRODUCT_TYPE9.getNumber())) { weChatPayReqInfo.setSub_mch_id(WxOrderConfig.MCH_ID_1614670195); - } else { + } else if (order.getProductType().equals(OrderProductType.PRODUCT_TYPE12.getNumber())) { + weChatPayReqInfo.setSub_mch_id(WxOrderConfig.MCH_ID_1614670195); + }else { weChatPayReqInfo.setSub_mch_id(WxOrderConfig.MCH_ID_1609882817); } @@ -282,7 +284,7 @@ public class OrderPayController { SortedMap sortedMap = wechatPayUtil.goWechatPay(weChatPayReqInfo,payMap); order.setAccountMerchantNum(weChatPayReqInfo.getSub_mch_id()); - order.setProfitSharingStatus(profitSharing.equals("Y")?true:false); + order.setProfitSharingStatus(profitSharing.equals("Y")); orderService.updateOrderData(order); return ResponseMsgUtil.success(sortedMap); diff --git a/hai-order/src/main/java/com/web/controller/OrderRefundController.java b/hai-order/src/main/java/com/web/controller/OrderRefundController.java index 1312645a..4e891864 100644 --- a/hai-order/src/main/java/com/web/controller/OrderRefundController.java +++ b/hai-order/src/main/java/com/web/controller/OrderRefundController.java @@ -53,8 +53,6 @@ public class OrderRefundController { @Resource private UserCenter userCenter; - @Autowired - private RocketMQTemplate rocketMQTemplate; @RequestMapping(value="/refund",method = RequestMethod.POST) @ResponseBody 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 new file mode 100644 index 00000000..e83fe3ed --- /dev/null +++ b/hai-order/src/main/java/com/web/controller/business/GoodsOrderController.java @@ -0,0 +1,198 @@ +package com.web.controller.business; + +import com.alibaba.excel.EasyExcel; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +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.common.utils.DateUtil; +import com.hai.common.utils.PageUtil; +import com.hai.common.utils.ResponseMsgUtil; +import com.hai.entity.*; +import com.hai.enum_type.UserObjectTypeEnum; +import com.hai.goods.model.GoodsModel; +import com.hai.goods.service.GoodsLogisticsService; +import com.hai.goods.service.GoodsOrderExtService; +import com.hai.goods.service.GoodsSkuService; +import com.hai.model.ResponseData; +import com.hai.model.UserInfoModel; +import com.hai.order.model.ExportOrderMobileModel; +import com.hai.order.model.GoodsOrderExtModel; +import com.hai.order.service.OrderService; +import com.hai.order.type.OrderPayType; +import com.hai.order.type.OrderStatus; +import com.hai.order.type.RechargePlatformType; +import com.hai.service.OutRechargeChildOrderService; +import com.hai.service.OutRechargeOrderService; +import com.web.config.SysConst; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.math3.stat.correlation.PearsonsCorrelation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.BeanUtils; +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.io.File; +import java.util.*; +import java.util.stream.Collectors; + +@Controller +@RequestMapping(value = "goodsOrder") +@Api(value = "实物商品业务") +public class GoodsOrderController { + + private static Logger log = LoggerFactory.getLogger(OrderMobileRechargeController.class); + + @Resource + private UserCenter userCenter; + + @Resource + private OrderService orderService; + + @Resource + private GoodsOrderExtService goodsOrderExtService; + + @Resource + private GoodsLogisticsService goodsLogisticsService; + + @RequestMapping(value = "/getOrderList", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询订单列表") + public ResponseData getOrderList(@RequestParam(name = "orderNo", required = false) String orderNo, + @RequestParam(name = "memPhone", required = false) String memPhone, + @RequestParam(name = "memCardNo", required = false) String memCardNo, + @RequestParam(name = "payType", required = false) Integer payType, + @RequestParam(name = "orderStatus", required = false) Integer orderStatus, + @RequestParam(name = "companyId", required = false) Long companyId, + @RequestParam(name = "createTimeS", required = false) Long createTimeS, + @RequestParam(name = "createTimeE", required = false) Long createTimeE, + @RequestParam(name = "refundTimeS", required = false) String refundTimeS, + @RequestParam(name = "refundTimeE", required = false) String refundTimeE, + @RequestParam(name = "payTimeS", required = false) Long payTimeS, + @RequestParam(name = "payTimeE", required = false) Long payTimeE, + @RequestParam(name = "productType", required = false) Integer productType, + @RequestParam(name = "finishTimeS", required = false) Long finishTimeS, + @RequestParam(name = "finishTimeE", required = false) Long finishTimeE, + @RequestParam(name = "pageNum", required = true) Integer pageNum, + @RequestParam(name = "pageSize", required = true) Integer pageSize, + HttpServletRequest request) { + try { + + UserInfoModel userInfoModel = userCenter.getSessionModel(UserInfoModel.class); + if (userInfoModel == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPETENCE_INSUFFICIENT, ""); + } + Map map = new HashMap<>(); + if (userInfoModel.getSecUser().getObjectType().equals(UserObjectTypeEnum.type0.getType())) { + map.put("companyId" , companyId); + } else if (userInfoModel.getSecUser().getObjectType().equals(UserObjectTypeEnum.type1.getType())) { + map.put("companyId", userInfoModel.getBsCompany().getId()); + } else { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPETENCE_INSUFFICIENT, ""); + } + map.put("createTimeS", createTimeS); + map.put("createTimeE", createTimeE); + map.put("payTimeS", payTimeS); + map.put("payTimeE", payTimeE); + map.put("finishTimeS", finishTimeS); + map.put("finishTimeE", finishTimeE); + map.put("refundTimeS" , refundTimeS); + map.put("refundTimeE" , refundTimeE); + map.put("orderNo", orderNo); + map.put("memPhone", memPhone); + map.put("memCardNo", memCardNo); + map.put("productType", 12); + map.put("orderStatus", orderStatus); + map.put("payType", payType); + + List list = orderService.getOrderList(map); + + List goodsOrderExtModels = new ArrayList<>(); + + GoodsOrderExtModel model; + + for (HighOrder order : list) { + model = new GoodsOrderExtModel(); + BeanUtils.copyProperties(order, model); + model.setLogisticsStatus(goodsOrderExtService.findGoodsOrder(order.getOrderNo()).getStatus()); + goodsOrderExtModels.add(model); + } + goodsOrderExtModels = goodsOrderExtModels.stream().sorted(Comparator.comparing(GoodsOrderExtModel::getLogisticsStatus)).collect(Collectors.toList()); + + return ResponseMsgUtil.success(PageUtil.initPageInfoObj(pageNum, goodsOrderExtModels.size(), pageSize, new PageInfo<>(goodsOrderExtModels))); + + } catch (Exception e) { + log.error("OrderCouponController --> getOrderList() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + + + + @RequestMapping(value="/getGoodsOrderDetail",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询订单详情") + public ResponseData getMobileOrderDetail(@RequestParam(name = "orderNo", required = true) String orderNo) { + try { + Map map = new HashMap<>(); + map.put("tradeOrder", orderService.getOrderDetailByNo(orderNo)); + GoodsOrder goodsOrder = goodsOrderExtService.findGoodsOrder(orderNo); + map.put("goodsOrder", goodsOrder); + if (goodsOrder.getLogisticsNo() != null) { + GoodsLogistics logistics = (GoodsLogistics) goodsLogisticsService.getLogisticsMsg(goodsOrder.getLogisticsNo()); + map.put("logistics", logistics); + JSONArray object = JSONArray.parseArray(logistics.getLogisticsTraceDetails()); + map.put("logisticsTraceDetails", object); + } + + return ResponseMsgUtil.success(map); + + } catch (Exception e) { + log.error("OrderExtController -> getGasOrderDetail() error!",e); + return ResponseMsgUtil.exception(e); + } + } + + + @RequestMapping(value="/updateLogisticsNo",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "更新物流订单号") + public ResponseData updateLogisticsNo(@RequestParam(name = "orderNo", required = true) String orderNo, + @RequestParam(name = "logisticsNo", required = true) String logisticsNo + ) { + try { + + GoodsOrder goodsOrder = goodsOrderExtService.findGoodsOrder(orderNo); + + if (goodsOrder == null) { + throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "信息错误!"); + } + + goodsOrder.setLogisticsNo(logisticsNo); + goodsOrder.setUpdateTime(new Date()); + if (Objects.equals(goodsOrder.getStatus(), "1")) { + goodsOrder.setStatus("2"); + } + + goodsOrderExtService.updateGoodsOrder(goodsOrder); + + return ResponseMsgUtil.success("更新成功!"); + + } catch (Exception e) { + log.error("OrderExtController -> getGasOrderDetail() error!",e); + return ResponseMsgUtil.exception(e); + } + } +} diff --git a/hai-order/src/main/java/com/web/controller/business/OrderMobileRechargeController.java b/hai-order/src/main/java/com/web/controller/business/OrderMobileRechargeController.java index 391d5090..7941f54b 100644 --- a/hai-order/src/main/java/com/web/controller/business/OrderMobileRechargeController.java +++ b/hai-order/src/main/java/com/web/controller/business/OrderMobileRechargeController.java @@ -15,9 +15,11 @@ import com.hai.enum_type.OrderStatusEnum; import com.hai.enum_type.UserObjectTypeEnum; import com.hai.model.ResponseData; import com.hai.model.UserInfoModel; +import com.hai.order.model.ExportOrderMobileModel; import com.hai.order.model.OrderThirdPartyModel; import com.hai.order.service.OrderService; import com.hai.order.type.OrderPayType; +import com.hai.order.type.OrderStatus; import com.hai.order.type.RechargePlatformType; import com.hai.service.OutRechargeChildOrderService; import com.hai.service.OutRechargeOrderService; @@ -78,6 +80,8 @@ public class OrderMobileRechargeController { @RequestParam(name = "payTimeE", required = false) Long payTimeE, @RequestParam(name = "finishTimeS", required = false) Long finishTimeS, @RequestParam(name = "finishTimeE", required = false) Long finishTimeE, + @RequestParam(name = "refundTimeS", required = false) String refundTimeS, + @RequestParam(name = "refundTimeE", required = false) String refundTimeE, @RequestParam(name = "pageNum", required = true) Integer pageNum, @RequestParam(name = "pageSize", required = true) Integer pageSize, HttpServletRequest request) { @@ -99,9 +103,11 @@ public class OrderMobileRechargeController { map.put("createTimeE", createTimeE); map.put("payTimeS", payTimeS); map.put("payTimeE", payTimeE); + map.put("refundTimeS" , refundTimeS); + map.put("refundTimeE" , refundTimeE); map.put("finishTimeS", finishTimeS); - map.put("title", title); map.put("finishTimeE", finishTimeE); + map.put("title", title); map.put("orderNo", orderNo); map.put("memPhone", memPhone); map.put("memCardNo", memCardNo); @@ -133,6 +139,8 @@ public class OrderMobileRechargeController { @RequestParam(name = "payTimeS", required = false) Long payTimeS, @RequestParam(name = "payTimeE", required = false) Long payTimeE, @RequestParam(name = "productType", required = false) Integer productType, + @RequestParam(name = "refundTimeS", required = false) String refundTimeS, + @RequestParam(name = "refundTimeE", required = false) String refundTimeE, @RequestParam(name = "finishTimeS", required = false) Long finishTimeS, @RequestParam(name = "finishTimeE", required = false) Long finishTimeE) { try { @@ -155,6 +163,8 @@ public class OrderMobileRechargeController { map.put("payTimeE", payTimeE); map.put("finishTimeS", finishTimeS); map.put("finishTimeE", finishTimeE); + map.put("refundTimeS" , refundTimeS); + map.put("refundTimeE" , refundTimeE); map.put("title", title); map.put("orderNo", orderNo); map.put("memPhone", memPhone); @@ -164,35 +174,45 @@ public class OrderMobileRechargeController { map.put("payType", payType); // 查询数据 - List orderList = orderService.getOrderList(map); - - List dataList = new ArrayList<>(); - OrderThirdPartyModel model; - - for (HighOrder thirdPartyModel : orderList) { - model = new OrderThirdPartyModel(); - model.setOrderNo(thirdPartyModel.getOrderNo()); - OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderNo(thirdPartyModel.getOrderNo()); - if (outRechargeOrder.getOutRechargeChildOrders().size() > 0) { - model.setRegOrderNo(outRechargeOrder.getOutRechargeChildOrders().get(0).getOrderNo()); - model.setRechargePlatform(RechargePlatformType.getDataByType(outRechargeOrder.getOutRechargeChildOrders().get(0).getRechargePlatform()).getName()); + List order = orderService.getOrderList(map); + + List list = new ArrayList<>(); + + ExportOrderMobileModel model; + for (HighOrder highOrder : order) { + model = new ExportOrderMobileModel(); + + OutRechargeOrder rechargeOrder = outRechargeOrderService.findByOrderNoNotChild(highOrder.getOrderNo()); + + if (rechargeOrder != null) { + + OutRechargeChildOrder childOrder = outRechargeOrderService.mobileChildOrderHandle(highOrder,rechargeOrder); + + model.setRechargeOrderNo(rechargeOrder.getOrderNo()); + + if (childOrder != null) { + model.setChildOrderNo(childOrder.getOrderNo()); + if (childOrder.getRechargePlatform() != null) { + model.setRechargePlatform(RechargePlatformType.getDataByType(childOrder.getRechargePlatform()).getName()); + } + model.setRemark(childOrder.getExt1()); + } + } - model.setMemPhone(thirdPartyModel.getMemPhone()); - model.setTitle(thirdPartyModel.getTitle()); - model.setTotalPrice(thirdPartyModel.getTotalPrice()); - model.setTotalDeductionPrice(thirdPartyModel.getTotalDeductionPrice()); - model.setDeductionProductPrice(thirdPartyModel.getDeductionProductPrice()); - model.setPayablePrice(thirdPartyModel.getPayablePrice()); - model.setPayPrice(thirdPartyModel.getPayPrice()); - if (thirdPartyModel.getPayType() != null) { - model.setPayType(OrderPayType.getDataByType(thirdPartyModel.getPayType()).getName()); + model.setFinishTime(highOrder.getFinishTime()); + model.setOrderStatus(OrderStatus.getDataByType(highOrder.getOrderStatus()).getName()); + model.setMemPhone(highOrder.getMemPhone()); + model.setCreateTime(highOrder.getCreateTime()); + model.setTitle(highOrder.getTitle()); + model.setPayablePrice(highOrder.getPayablePrice()); + model.setRefundTime(highOrder.getRefundTime()); + model.setPayPrice(highOrder.getPayPrice()); + model.setOrderNo(highOrder.getOrderNo()); + model.setMemCardNo(highOrder.getMemCardNo()); + if (highOrder.getPayType() != null) { + model.setPayType(OrderPayType.getDataByType(highOrder.getPayType()).getName()); } - model.setOrderStatus(OrderStatusEnum.getNameByType(thirdPartyModel.getOrderStatus())); - model.setCreateTime(thirdPartyModel.getCreateTime()); - model.setPayTime(thirdPartyModel.getPayTime()); - model.setRefundTime(thirdPartyModel.getRefundTime()); - model.setMemCardNo(thirdPartyModel.getMemCardNo()); - dataList.add(model); + list.add(model); } String fileUrl = SysConst.getSysConfig().getFileUrl() + "temporary/"; @@ -203,9 +223,9 @@ public class OrderMobileRechargeController { } EasyExcel.write(fileUrl+pathName) - .head(OrderThirdPartyModel.class) - .sheet("交易订单") - .doWrite(dataList); + .head(ExportOrderMobileModel.class) + .sheet("话费交易订单") + .doWrite(list); return ResponseMsgUtil.success(pathName); } catch (Exception e) { diff --git a/hai-order/src/main/java/com/web/controller/business/OrderThirdPartyController.java b/hai-order/src/main/java/com/web/controller/business/OrderThirdPartyController.java index 4f1c0b71..6bd4c910 100644 --- a/hai-order/src/main/java/com/web/controller/business/OrderThirdPartyController.java +++ b/hai-order/src/main/java/com/web/controller/business/OrderThirdPartyController.java @@ -65,6 +65,8 @@ public class OrderThirdPartyController { @RequestParam(name = "companyId", required = false) Long companyId, @RequestParam(name = "createTimeS", required = false) Long createTimeS, @RequestParam(name = "createTimeE", required = false) Long createTimeE, + @RequestParam(name = "refundTimeS", required = false) String refundTimeS, + @RequestParam(name = "refundTimeE", required = false) String refundTimeE, @RequestParam(name = "payTimeS", required = false) Long payTimeS, @RequestParam(name = "payTimeE", required = false) Long payTimeE, @RequestParam(name = "productType", required = false) Integer productType, @@ -93,6 +95,8 @@ public class OrderThirdPartyController { map.put("payTimeE", payTimeE); map.put("finishTimeS", finishTimeS); map.put("finishTimeE", finishTimeE); + map.put("refundTimeS" , refundTimeS); + map.put("refundTimeE" , refundTimeE); map.put("orderNo", orderNo); map.put("memPhone", memPhone); map.put("memCardNo", memCardNo); @@ -139,6 +143,8 @@ public class OrderThirdPartyController { @RequestParam(name = "createTimeE", required = false) Long createTimeE, @RequestParam(name = "payTimeS", required = false) Long payTimeS, @RequestParam(name = "payTimeE", required = false) Long payTimeE, + @RequestParam(name = "refundTimeS", required = false) String refundTimeS, + @RequestParam(name = "refundTimeE", required = false) String refundTimeE, @RequestParam(name = "productType", required = false) Integer productType, @RequestParam(name = "finishTimeS", required = false) Long finishTimeS, @RequestParam(name = "finishTimeE", required = false) Long finishTimeE) { @@ -162,6 +168,8 @@ public class OrderThirdPartyController { map.put("payTimeE", payTimeE); map.put("finishTimeS", finishTimeS); map.put("finishTimeE", finishTimeE); + map.put("refundTimeS" , refundTimeS); + map.put("refundTimeE" , refundTimeE); map.put("orderNo", orderNo); map.put("memPhone", memPhone); map.put("memCardNo", memCardNo); diff --git a/hai-order/src/main/java/com/web/rocketmq/consumer/OrderRefundSuccessConsumer.java b/hai-order/src/main/java/com/web/rocketmq/consumer/OrderRefundSuccessConsumer.java index e89d0f57..ab451f10 100644 --- a/hai-order/src/main/java/com/web/rocketmq/consumer/OrderRefundSuccessConsumer.java +++ b/hai-order/src/main/java/com/web/rocketmq/consumer/OrderRefundSuccessConsumer.java @@ -29,8 +29,6 @@ public class OrderRefundSuccessConsumer implements RocketMQListener + */ + List getGoodsOrderList(Map map); + + + /** + * @Author Sum1Dream + * @Name findGoodsOrderById + * @Description // 根据id查询详情 + * @Date 16:19 2023/4/11 + * @Param [id] + * @Return com.hai.entity.GoodsOrder + */ + GoodsOrder findGoodsOrderById(Long id); + + /** + * @Author Sum1Dream + * @Name findGoodsOrder + * @Description // 查询详情 + * @Date 15:44 2023/4/20 + * @Param [orderNo] + * @Return com.hai.entity.GoodsOrder + */ + GoodsOrder findGoodsOrder(String orderNo); + + /** + * @Author Sum1Dream + * @Name findGoodsOrderByLogisticsNo + * @Description // 根据运单号查询订单 + * @Date 17:20 2023/4/20 + * @Param [logisticsNo] + * @Return com.hai.entity.GoodsOrder + */ + GoodsOrder findGoodsOrderByLogisticsNo(String logisticsNo); + + /** + * @Author Sum1Dream + * @Name deleteGoodsOrder + * @Description // 删除 + * @Date 17:37 2023/4/13 + * @Param [id] + * @Return void + */ + void deleteGoodsOrder(Long id); + +} diff --git a/hai-service/src/main/java/com/hai/goods/service/GoodsSkuService.java b/hai-service/src/main/java/com/hai/goods/service/GoodsSkuService.java index 45b5af9e..1b6f6ef9 100644 --- a/hai-service/src/main/java/com/hai/goods/service/GoodsSkuService.java +++ b/hai-service/src/main/java/com/hai/goods/service/GoodsSkuService.java @@ -55,5 +55,15 @@ public interface GoodsSkuService { * @Return com.hai.entity.GoodsSku */ GoodsSku findGoodsSkuById(Long id); + + /** + * @Author Sum1Dream + * @Name decreaseStockNum + * @Description // 减少库存 + * @Date 17:34 2023/4/19 + * @Param [skuId, num] + * @Return void + */ + void decreaseStockNum(Long skuId , Integer num); } diff --git a/hai-service/src/main/java/com/hai/goods/service/impl/GoodsDetailServiceImpl.java b/hai-service/src/main/java/com/hai/goods/service/impl/GoodsDetailServiceImpl.java index 8345831a..d15c2ee9 100644 --- a/hai-service/src/main/java/com/hai/goods/service/impl/GoodsDetailServiceImpl.java +++ b/hai-service/src/main/java/com/hai/goods/service/impl/GoodsDetailServiceImpl.java @@ -46,11 +46,16 @@ public class GoodsDetailServiceImpl implements GoodsDetailService { if (MapUtils.getLong(map, "goodsType") != null) { criteria.andGoodsTypeEqualTo(MapUtils.getLong(map, "goodsType") ); } + if (MapUtils.getLong(map, "opId") != null) { + criteria.andOpIdEqualTo(MapUtils.getLong(map, "opId") ); + } if (MapUtils.getInteger(map, "status") != null) { criteria.andStatusEqualTo(MapUtils.getInteger(map, "status") ); } else { criteria.andStatusNotEqualTo(0); } + + example.setOrderByClause("create_time desc"); return goodsDetailMapper.selectByExample(example); } diff --git a/hai-service/src/main/java/com/hai/goods/service/impl/GoodsLogisticsServiceImpl.java b/hai-service/src/main/java/com/hai/goods/service/impl/GoodsLogisticsServiceImpl.java index 7a279763..2c8286e3 100644 --- a/hai-service/src/main/java/com/hai/goods/service/impl/GoodsLogisticsServiceImpl.java +++ b/hai-service/src/main/java/com/hai/goods/service/impl/GoodsLogisticsServiceImpl.java @@ -1,16 +1,22 @@ package com.hai.goods.service.impl; import com.alibaba.fastjson.JSONObject; +import com.hai.common.utils.RedisUtil; +import com.hai.common.utils.ResponseMsgUtil; +import com.hai.config.CommonConfig; import com.hai.dao.GoodsLogisticsMapper; import com.hai.entity.GoodsLogistics; import com.hai.entity.GoodsLogisticsExample; +import com.hai.entity.GoodsOrder; import com.hai.goods.service.GoodsLogisticsService; +import com.hai.goods.service.GoodsOrderExtService; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.Date; import java.util.List; import java.util.Map; +import java.util.Objects; @Service("goodsLogisticsService") public class GoodsLogisticsServiceImpl implements GoodsLogisticsService { @@ -18,6 +24,12 @@ public class GoodsLogisticsServiceImpl implements GoodsLogisticsService { @Resource private GoodsLogisticsMapper goodsLogisticsMapper; + @Resource + private RedisUtil redisUtil; + + @Resource + private GoodsOrderExtService goodsOrderExtService; + @Override public void insertGoodsLogistics(GoodsLogistics goodsLogistics) { goodsLogisticsMapper.insert(goodsLogistics); @@ -85,4 +97,40 @@ public class GoodsLogisticsServiceImpl implements GoodsLogisticsService { return logistics; } + + @Override + public Object getLogisticsMsg(String num) { + Object data = redisUtil.get("logisticsMsg" + num); + if (data == null) { + + JSONObject jsonObjects = CommonConfig.getLogisticsMsg(num); + redisUtil.set("logisticsMsgOl" + num , jsonObjects ,21600); + if (jsonObjects.getInteger("code") == 200 && jsonObjects.getBoolean("success")) { + + GoodsLogistics logistics = editLogistics((JSONObject) jsonObjects.get("data")); + + GoodsOrder goodsOrder = goodsOrderExtService.findGoodsOrderByLogisticsNo(num); + if (goodsOrder != null) { + goodsOrder.setUpdateTime(new Date()); + if (Objects.equals(logistics.getLogisticsStatus(), "TRANSPORT")) { + goodsOrder.setStatus("3"); + } + if (Objects.equals(logistics.getLogisticsStatus(), "AGENT_SIGN") || Objects.equals(logistics.getLogisticsStatus(), "SIGN")) { + goodsOrder.setStatus("4"); + } + goodsOrderExtService.updateGoodsOrder(goodsOrder); + } + + + redisUtil.set("logisticsMsg" + num , logistics ,21600); + + return logistics; + } + + return jsonObjects; + + } else { + return data; + } + } } diff --git a/hai-service/src/main/java/com/hai/goods/service/impl/GoodsOrderServiceImpl.java b/hai-service/src/main/java/com/hai/goods/service/impl/GoodsOrderServiceImpl.java new file mode 100644 index 00000000..86a258d8 --- /dev/null +++ b/hai-service/src/main/java/com/hai/goods/service/impl/GoodsOrderServiceImpl.java @@ -0,0 +1,72 @@ +package com.hai.goods.service.impl; + +import com.hai.dao.GoodsOrderMapper; +import com.hai.entity.GoodsOrder; +import com.hai.entity.GoodsOrderExample; +import com.hai.goods.service.GoodsOrderExtService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; +import java.util.Map; + +@Service("goodsOrderExtService") +public class GoodsOrderServiceImpl implements GoodsOrderExtService { + + @Resource + private GoodsOrderMapper goodsOrderMapper; + + @Override + public void insertGoodsOrder(GoodsOrder goodsOrder) { + goodsOrderMapper.insert(goodsOrder); + } + + @Override + public void updateGoodsOrder(GoodsOrder goodsOrder) { + goodsOrderMapper.updateByPrimaryKey(goodsOrder); + } + + @Override + public List getGoodsOrderList(Map map) { + return null; + } + + @Override + public GoodsOrder findGoodsOrderById(Long id) { + return null; + } + + @Override + public GoodsOrder findGoodsOrder(String orderNo) { + + GoodsOrderExample example = new GoodsOrderExample(); + example.createCriteria().andStatusNotEqualTo("0").andOrderNoEqualTo(orderNo); + + List list = goodsOrderMapper.selectByExample(example); + + if (list.size() > 0) { + return list.get(0); + } + + return null; + } + + @Override + public GoodsOrder findGoodsOrderByLogisticsNo(String logisticsNo) { + GoodsOrderExample example = new GoodsOrderExample(); + example.createCriteria().andStatusNotEqualTo("0").andLogisticsNoEqualTo(logisticsNo); + + List list = goodsOrderMapper.selectByExample(example); + + if (list.size() > 0) { + return list.get(0); + } + + return null; + } + + @Override + public void deleteGoodsOrder(Long id) { + + } +} diff --git a/hai-service/src/main/java/com/hai/goods/service/impl/GoodsSkuServiceImpl.java b/hai-service/src/main/java/com/hai/goods/service/impl/GoodsSkuServiceImpl.java index 6a5cfe7b..03505c29 100644 --- a/hai-service/src/main/java/com/hai/goods/service/impl/GoodsSkuServiceImpl.java +++ b/hai-service/src/main/java/com/hai/goods/service/impl/GoodsSkuServiceImpl.java @@ -1,11 +1,17 @@ package com.hai.goods.service.impl; +import com.hai.common.exception.ErrorCode; +import com.hai.common.exception.ErrorHelp; +import com.hai.common.exception.SysCode; import com.hai.dao.GoodsSkuMapper; import com.hai.entity.GoodsDetailExample; import com.hai.entity.GoodsSku; import com.hai.entity.GoodsSkuExample; +import com.hai.entity.HighOrder; import com.hai.goods.service.GoodsSkuService; import org.apache.commons.collections4.MapUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -18,6 +24,9 @@ public class GoodsSkuServiceImpl implements GoodsSkuService { @Resource private GoodsSkuMapper goodsSkuMapper; + @Autowired + private RedisTemplate redisTemplate; + @Override public void insertGoodsSku(GoodsSku goodsSku) { goodsSkuMapper.insert(goodsSku); @@ -44,6 +53,9 @@ public class GoodsSkuServiceImpl implements GoodsSkuService { if (MapUtils.getLong(map, "goodsId") != null) { criteria.andGoodsIdEqualTo(MapUtils.getLong(map, "goodsId") ); } + if (MapUtils.getLong(map, "id") != null) { + criteria.andIdEqualTo(MapUtils.getLong(map, "id") ); + } return goodsSkuMapper.selectByExample(example); } @@ -61,4 +73,38 @@ public class GoodsSkuServiceImpl implements GoodsSkuService { public GoodsSku findGoodsSkuById(Long id) { return goodsSkuMapper.selectByPrimaryKey(id); } + + @Override + public void decreaseStockNum(Long skuId, Integer num){ + String key = "GOODS_STOCK_NUM"; + + GoodsSku goodsSku = findGoodsSkuById(skuId); + + try { + // 分布式锁占坑 + Boolean lock = redisTemplate.opsForValue().setIfAbsent(key, skuId); + + if(Boolean.TRUE.equals(lock)) { + if (goodsSku.getStock() < num) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, goodsSku.getName() + "库存不足"); + } + // 加锁成功,处理业务 + goodsSku.setStock(goodsSku.getStock() - num); + + updateGoodsSku(goodsSku); + + } else { + // 加锁失败,重试 + Thread.sleep(100); + decreaseStockNum(skuId , num); + } + + } catch (Exception e) { + e.printStackTrace(); + } finally { + // 删除key,释放锁 + redisTemplate.delete(key); + } + + } } diff --git a/hai-service/src/main/java/com/hai/model/GoodsOrderModel.java b/hai-service/src/main/java/com/hai/model/GoodsOrderModel.java new file mode 100644 index 00000000..99060258 --- /dev/null +++ b/hai-service/src/main/java/com/hai/model/GoodsOrderModel.java @@ -0,0 +1,28 @@ +package com.hai.model; + +import com.hai.entity.GoodsDeliveryAddress; +import com.hai.entity.GoodsOrder; +import com.hai.entity.HighOrder; + +public class GoodsOrderModel extends HighOrder { + + GoodsOrder goodsOrder; + + GoodsDeliveryAddress goodsDeliveryAddress; + + public GoodsOrder getGoodsOrder() { + return goodsOrder; + } + + public void setGoodsOrder(GoodsOrder goodsOrder) { + this.goodsOrder = goodsOrder; + } + + public GoodsDeliveryAddress getGoodsDeliveryAddress() { + return goodsDeliveryAddress; + } + + public void setGoodsDeliveryAddress(GoodsDeliveryAddress goodsDeliveryAddress) { + this.goodsDeliveryAddress = goodsDeliveryAddress; + } +} diff --git a/hai-service/src/main/java/com/hai/order/model/CreateOrderModel.java b/hai-service/src/main/java/com/hai/order/model/CreateOrderModel.java index e369a4e6..b7d5ca98 100644 --- a/hai-service/src/main/java/com/hai/order/model/CreateOrderModel.java +++ b/hai-service/src/main/java/com/hai/order/model/CreateOrderModel.java @@ -65,7 +65,7 @@ public class CreateOrderModel { private String remarks; /** - * 收货地址 + * 收货地址 */ private Long deliveryAddressId; diff --git a/hai-service/src/main/java/com/hai/order/model/GoodsOrderExtModel.java b/hai-service/src/main/java/com/hai/order/model/GoodsOrderExtModel.java new file mode 100644 index 00000000..0c03f2b0 --- /dev/null +++ b/hai-service/src/main/java/com/hai/order/model/GoodsOrderExtModel.java @@ -0,0 +1,19 @@ +package com.hai.order.model; + +import com.hai.entity.HighOrder; + +public class GoodsOrderExtModel extends HighOrder { + + /** + * 1:待发货 2:已发货 3:配送中 4:已送达 5:已取消 6:退货中 7:已退货 8:待支付 0:删除'; + */ + private String logisticsStatus; + + public String getLogisticsStatus() { + return logisticsStatus; + } + + public void setLogisticsStatus(String logisticsStatus) { + this.logisticsStatus = logisticsStatus; + } +} diff --git a/hai-service/src/main/java/com/hai/order/service/OrderCancelHandleService.java b/hai-service/src/main/java/com/hai/order/service/OrderCancelHandleService.java index 19c4feb0..92de7fb7 100644 --- a/hai-service/src/main/java/com/hai/order/service/OrderCancelHandleService.java +++ b/hai-service/src/main/java/com/hai/order/service/OrderCancelHandleService.java @@ -2,6 +2,7 @@ package com.hai.order.service; import com.hai.entity.HighChildOrder; import com.hai.entity.HighDiscountUserRel; +import com.hai.entity.HighOrder; import com.hai.model.ResponseData; import com.hai.order.model.CreateOrderChildModel; @@ -29,4 +30,6 @@ public interface OrderCancelHandleService { */ void oilHandle(HighChildOrder childOrder) ; + void goodsHandle(HighChildOrder childOrder); + } 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 1c6b3957..11f6f459 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 @@ -76,4 +76,14 @@ public interface OrderCreateHandleService { */ HighChildOrder mobileRecharge(HighOrder order , JSONObject object) throws Exception; + /** + * @Author Sum1Dream + * @Name goods + * @Description // 实物订单校验 + * @Date 17:32 2023/4/18 + * @Param [order, createOrderChild] + * @Return com.hai.entity.HighChildOrder + */ + HighChildOrder goods(HighOrder order, CreateOrderChildModel createOrderChild) throws Exception; + } diff --git a/hai-service/src/main/java/com/hai/order/service/OrderRefundHandleService.java b/hai-service/src/main/java/com/hai/order/service/OrderRefundHandleService.java index d4a0c8f0..c63cc3b7 100644 --- a/hai-service/src/main/java/com/hai/order/service/OrderRefundHandleService.java +++ b/hai-service/src/main/java/com/hai/order/service/OrderRefundHandleService.java @@ -25,4 +25,14 @@ public interface OrderRefundHandleService { */ void oilHandle(HighOrderRefund orderRefund) ; + /** + * @Author Sum1Dream + * @Name goodsHandle + * @Description // 商品操作 + * @Date 10:41 2023/4/20 + * @Param [orderRefund] + * @Return void + */ + void goodsHandle(HighOrderRefund orderRefund); + } diff --git a/hai-service/src/main/java/com/hai/order/service/impl/OrderCancelHandleServiceImpl.java b/hai-service/src/main/java/com/hai/order/service/impl/OrderCancelHandleServiceImpl.java index eb01fcde..95ed1470 100644 --- a/hai-service/src/main/java/com/hai/order/service/impl/OrderCancelHandleServiceImpl.java +++ b/hai-service/src/main/java/com/hai/order/service/impl/OrderCancelHandleServiceImpl.java @@ -1,8 +1,10 @@ package com.hai.order.service.impl; +import com.hai.entity.GoodsSku; import com.hai.entity.HighChildOrder; import com.hai.entity.HighCouponCode; import com.hai.entity.HighGasOrder; +import com.hai.goods.service.GoodsSkuService; import com.hai.order.service.OrderCancelHandleService; import com.hai.order.type.OrderChildStatus; import com.hai.order.type.OrderOilStatus; @@ -27,6 +29,9 @@ public class OrderCancelHandleServiceImpl implements OrderCancelHandleService { @Resource private HighGasOrderService gasOrderService; + @Resource + private GoodsSkuService goodsSkuService; + @Override public void couponHandle(HighChildOrder childOrder) { // 解除兑换码与订单的关系 @@ -48,4 +53,11 @@ public class OrderCancelHandleServiceImpl implements OrderCancelHandleService { gasOrderService.updateGasOrder(gasOrder); } } + + @Override + public void goodsHandle(HighChildOrder childOrder) { + GoodsSku goodsSku = goodsSkuService.findGoodsSkuById(childOrder.getSkuId()); + goodsSku.setStock(goodsSku.getStock() + childOrder.getSaleCount()); + goodsSkuService.updateGoodsSku(goodsSku); + } } 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 a9c3d1e5..0f621312 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 @@ -7,17 +7,15 @@ import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.security.AESEncodeUtil; -import com.hai.common.security.UserCenter; -import com.hai.common.utils.DateUtil; -import com.hai.common.utils.IDGenerator; import com.hai.config.*; import com.hai.dao.OutRechargeOrderMapper; import com.hai.entity.*; import com.hai.enum_type.*; +import com.hai.goods.service.GoodsDetailService; +import com.hai.goods.service.GoodsSkuService; +import com.hai.goods.service.ShoppingCartService; import com.hai.model.GasPayPriceModel; -import com.hai.model.HighMerchantModel; import com.hai.model.OutRechargePriceModel; -import com.hai.model.ResponseData; import com.hai.order.model.CreateOrderChildModel; import com.hai.order.model.CreateOrderModel; import com.hai.order.service.OrderCreateHandleService; @@ -129,6 +127,17 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService { @Resource private HighDiscountPackageActualService discountPackageActualService; + + @Resource + private GoodsDetailService goodsDetailService; + + @Resource + private GoodsSkuService goodsSkuService; + + + @Resource + private ShoppingCartService shoppingCartService; + @Override public List couponHandle(HighDiscountUserRel discountUserRel, CreateOrderChildModel createOrderChild) throws Exception { if (createOrderChild.getSaleCount() != 1) { @@ -891,4 +900,54 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService { outRechargeOrderMapper.insert(outRechargeOrder); return childOrder; } + + @Override + public HighChildOrder goods(HighOrder order, CreateOrderChildModel createOrderChild) throws Exception{ + + + GoodsDetail goods = goodsDetailService.findGoodsDetailById(createOrderChild.getGoodsId()); + GoodsSku goodsSku = goodsSkuService.findGoodsSkuById(createOrderChild.getSkuId()); + + Map map = new HashMap<>(); + map.put("goodsId" , createOrderChild.getGoodsId()); + map.put("id" , createOrderChild.getSkuId()); + + List goodsSkuList = goodsSkuService.getGoodsSkuList(map); + + if (goodsSkuList.size() == 0) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "商品信息错误! "); + } + + // 生成交易子订单 + 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.TYPE11.getNumber()); + childOrder.setGoodsId(createOrderChild.getGoodsId()); + childOrder.setGoodsName(goods.getName()); + childOrder.setSkuId(createOrderChild.getSkuId()); + childOrder.setGoodsSpecName(goodsSku.getName()); + childOrder.setGoodsPrice(goodsSku.getOriginalPrice()); + childOrder.setGoodsActualPrice(goodsSku.getPrice()); + childOrder.setGoodsImg(goodsSku.getShowImg()); + childOrder.setSaleCount(createOrderChild.getSaleCount()); + childOrder.setGiveawayType(false); + childOrder.setChildOrderStatus(OrderChildStatus.STATUS1.getNumber()); + childOrder.setTotalPrice(childOrder.getGoodsPrice().multiply(new BigDecimal(childOrder.getSaleCount()))); + childOrder.setTotalActualPrice(childOrder.getGoodsActualPrice().multiply(new BigDecimal(childOrder.getSaleCount()))); + childOrder.setTotalDeductionPrice(childOrder.getTotalPrice().subtract(childOrder.getTotalActualPrice())); + childOrder.setPraiseStatus(0); + childOrder.setCreateTime(new Date()); + + if (createOrderChild.getShopCartId() != null) { + shoppingCartService.deleteShoppingCart(createOrderChild.getShopCartId()); + } + + goodsSkuService.decreaseStockNum(createOrderChild.getSkuId(), createOrderChild.getSaleCount()); + + 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 ed0b1083..1285dd3f 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 @@ -9,6 +9,7 @@ import com.hai.config.*; import com.hai.dao.HighGasOrderPushMapper; import com.hai.entity.*; import com.hai.enum_type.*; +import com.hai.goods.service.GoodsOrderExtService; import com.hai.msg.entity.MsgTopic; import com.hai.order.service.OrderPaySuccessService; import com.hai.order.service.OrderService; @@ -76,7 +77,7 @@ public class OrderPaySuccessServiceImpl implements OrderPaySuccessService { private PayloService payloService; @Resource - private HighGasOrderPushMapper highGasOrderPushMapper; + private GoodsOrderExtService goodsOrderExtService; @Resource private HighDiscountPackageDiscountActualService discountPackageDiscountActualService; @@ -216,6 +217,8 @@ public class OrderPaySuccessServiceImpl implements OrderPaySuccessService { } else if (childOrder.getGoodsType().equals(OrderChildGoodsType.TYPE10.getNumber())) { thirdOrderHandle(order); + } else if (childOrder.getGoodsType().equals(OrderChildGoodsType.TYPE11.getNumber())) { + goodsRecharge(order); } } } @@ -495,4 +498,19 @@ public class OrderPaySuccessServiceImpl implements OrderPaySuccessService { outRechargeOrderService.getPrepaidRechargeApi(outRechargeOrder); } + /** + * @Author Sum1Dream + * @Name goodsRecharge + * @Description // 实物商品订单操作 + * @Date 17:13 2023/4/20 + * @Param [order] + * @Return void + */ + private void goodsRecharge(HighOrder order) { + GoodsOrder goodsOrder = goodsOrderExtService.findGoodsOrder(order.getOrderNo()); + goodsOrder.setUpdateTime(new Date()); + goodsOrder.setStatus("1"); + goodsOrderExtService.updateGoodsOrder(goodsOrder); + } + } diff --git a/hai-service/src/main/java/com/hai/order/service/impl/OrderRefundHandleServiceImpl.java b/hai-service/src/main/java/com/hai/order/service/impl/OrderRefundHandleServiceImpl.java index 9c341ced..52939b4e 100644 --- a/hai-service/src/main/java/com/hai/order/service/impl/OrderRefundHandleServiceImpl.java +++ b/hai-service/src/main/java/com/hai/order/service/impl/OrderRefundHandleServiceImpl.java @@ -6,25 +6,25 @@ import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.config.PayloService; import com.hai.config.ShellGroupService; -import com.hai.entity.HighChildOrder; -import com.hai.entity.HighGasOrder; -import com.hai.entity.HighMerchantStore; -import com.hai.entity.HighOrderRefund; +import com.hai.entity.*; import com.hai.enum_type.GasChannel; import com.hai.enum_type.GasChannelPayPlatformType; import com.hai.enum_type.MerStoreAmountSourceTypeEnum; import com.hai.enum_type.MerStoreAmountTypeEnum; import com.hai.msg.entity.MsgTopic; +import com.hai.order.service.OrderCancelHandleService; import com.hai.order.service.OrderRefundHandleService; import com.hai.order.type.OrderOilStatus; import com.hai.service.HighGasOrderService; import com.hai.service.HighMerchantStoreService; +import com.hai.service.HighOrderService; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.Date; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -47,6 +47,13 @@ public class OrderRefundHandleServiceImpl implements OrderRefundHandleService { @Resource private PayloService payloService; + @Resource + private HighOrderService highOrderService; + + @Resource + private OrderCancelHandleService orderCancelHandleService; + + @Override public void couponHandle(HighOrderRefund orderRefund) { @@ -113,4 +120,18 @@ public class OrderRefundHandleServiceImpl implements OrderRefundHandleService { } } + + + @Override + public void goodsHandle(HighOrderRefund orderRefund) { + + HighOrder order = highOrderService.getOrderByOrderNo(orderRefund.getOrderNo()); + + List childOrderList = order.getHighChildOrderList(); + + for (HighChildOrder childOrder : childOrderList) { + orderCancelHandleService.goodsHandle(childOrder); + } + + } } 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 c0bc336f..c1114fa5 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 @@ -8,11 +8,16 @@ import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.security.AESEncodeUtil; +import com.hai.common.utils.DateUtil; import com.hai.config.ThirdProductConfig; import com.hai.dao.HighChildOrderMapper; import com.hai.dao.HighOrderMapper; import com.hai.entity.*; import com.hai.enum_type.DiscountUseScope; +import com.hai.goods.service.DeliveryAddressService; +import com.hai.goods.service.GoodsOrderExtService; +import com.hai.goods.service.GoodsRegionFreightService; +import com.hai.goods.service.GoodsSkuService; import com.hai.order.model.CreateOrderChildModel; import com.hai.order.model.CreateOrderModel; import com.hai.order.model.RefundPriceModel; @@ -85,6 +90,18 @@ public class OrderServiceImpl implements OrderService { @Resource private HighDiscountPackageActualService discountPackageActualService; + @Resource + private DeliveryAddressService deliveryAddressService; + + @Resource + private GoodsRegionFreightService goodsRegionFreightService; + + + @Resource + private GoodsOrderExtService goodsOrderExtService; + + + @Override public HighOrder insertOrderData(HighOrder order) { @@ -282,6 +299,21 @@ public class OrderServiceImpl implements OrderService { } } order.setRemarks(object.getString("customerMobile")); + // 实物商品 + } else if (child.getGoodsType().equals(OrderChildGoodsType.TYPE11.getNumber())) { + + HighChildOrder childOrder = orderCreateHandleService.goods(order , child); + childOrderList.add(childOrder); + order.setProductType(OrderProductType.PRODUCT_TYPE12.getNumber()); + + if (StringUtils.isBlank(order.getTitle())) { + order.setTitle(childOrder.getGoodsName()); + order.setExt6(childOrder.getGoodsImg()); + } else { + order.setTitle(order.getTitle() + "+" +childOrder.getGoodsName()); + order.setExt6(order.getExt6() + "," +childOrder.getGoodsImg()); + } + } else { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知业务类型"); } @@ -289,11 +321,16 @@ public class OrderServiceImpl implements OrderService { order.setHighChildOrderList(childOrderList); /*********** 组装处理子订单 商品业务************/ + + // 计算订单金额 Map calculateOrderPrice = OrderUtil.calculateOrderPrice(order.getHighChildOrderList()); + order.setTotalPrice(new BigDecimal(calculateOrderPrice.get("totalPrice").toString())); order.setPayablePrice(new BigDecimal(calculateOrderPrice.get("payablePrice").toString())); + + // 是否使用了优惠券 if (discountUserRel != null) { order.setMemDiscountId(discountUserRel.getId()); @@ -325,6 +362,10 @@ public class OrderServiceImpl implements OrderService { if (!order.getProductType().equals(OrderProductType.PRODUCT_TYPE6.getNumber())) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "此优惠券只能加油订单中使用"); } + } else if (discountUserRel.getHighDiscount().getUseScope().equals(DiscountUseScope.type9.getType())) { + if (!order.getProductType().equals(OrderProductType.PRODUCT_TYPE12.getNumber())) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "此优惠券只能是实物订单中使用"); + } } else { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂时无法使用此优惠券"); } @@ -372,6 +413,34 @@ public class OrderServiceImpl implements OrderService { order.setTotalDeductionPrice(order.getDeductionCouponPrice().add(order.getDeductionProductPrice())); order.setPayPrice(order.getPayablePrice()); + + if (order.getProductType().equals(OrderProductType.PRODUCT_TYPE12.getNumber())) { + + GoodsDeliveryAddress deliveryAddress = deliveryAddressService.findDeliveryAddressById(createOrderModel.getDeliveryAddressId()); + + // 生成实物专属订单实体 + GoodsOrder goodsOrder = new GoodsOrder(); + + JSONObject object = goodsRegionFreightService.getRegionFreight(deliveryAddress.getRegionId()); + + if (object.getBigDecimal("freePostPrice").compareTo(order.getPayablePrice()) > 0) { + order.setTotalPrice(order.getTotalPrice().add(object.getBigDecimal("freightPrice"))); + order.setPayablePrice(order.getPayablePrice().add(object.getBigDecimal("freightPrice"))); + order.setPayPrice(order.getPayPrice().add(object.getBigDecimal("freightPrice"))); + goodsOrder.setFreightPrice(object.getBigDecimal("freightPrice")); + } + + goodsOrder.setStatus("8"); + goodsOrder.setOpName("系统生成"); + goodsOrder.setUpdateTime(new Date()); + goodsOrder.setCreateTime(new Date()); + goodsOrder.setDeliveryAddressId(createOrderModel.getDeliveryAddressId()); + goodsOrder.setOrderNo(order.getOrderNo()); + goodsOrder.setDeliveryAddress(deliveryAddress.getRegionName() + deliveryAddress.getAddress()); + + goodsOrderExtService.insertGoodsOrder(goodsOrder); + } + // 积分抵扣 if (createOrderModel.getPayGold() != null && createOrderModel.getPayGold() > 0) { // 查询用户 @@ -379,13 +448,13 @@ public class OrderServiceImpl implements OrderService { if (user == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到用户信息"); } - if (createOrderModel.getPayGold().compareTo(user.getGold()) == 1) { + if (createOrderModel.getPayGold().compareTo(user.getGold()) > 0) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "抵扣积分大于用户拥有积分"); } // 积分转换成金额 BigDecimal goldPrice = new BigDecimal(createOrderModel.getPayGold().toString()).divide(new BigDecimal(100)); // 积分金额大于应付金额 - if (goldPrice.compareTo(order.getPayablePrice()) == 1) { + if (goldPrice.compareTo(order.getPayablePrice()) > 0) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "支付的积分金额大于支付金额"); } // 支付金额 减去 积分抵扣金额 = 应付金额 @@ -517,6 +586,9 @@ public class OrderServiceImpl implements OrderService { } else if (childOrder.getGoodsType().equals(OrderChildGoodsType.TYPE3.getNumber())) { orderCancelHandleService.oilHandle(childOrder); + } else if (childOrder.getGoodsType().equals(OrderChildGoodsType.TYPE11.getNumber())) { + orderCancelHandleService.goodsHandle(childOrder); + } else if (childOrder.getGoodsType().equals(OrderChildGoodsType.TYPE7.getNumber())) { } @@ -559,6 +631,7 @@ public class OrderServiceImpl implements OrderService { childOrder.setRefundTime(new Date()); childOrder.setChildOrderStatus(OrderChildStatus.STATUS4.getNumber()); } + } order.setSurplusRefundIntegral(0); @@ -747,6 +820,11 @@ public class OrderServiceImpl implements OrderService { if (MapUtils.getLong(param, "finishTimeE") != null) { criteria.andCreateTimeLessThan(new Date(MapUtils.getLong(param, "finishTimeE"))); } + if (StringUtils.isNotBlank(MapUtils.getString(param, "refundTimeS")) && StringUtils.isNotBlank(MapUtils.getString(param, "refundTimeE"))) { + criteria.andRefundTimeBetween( + DateUtil.format(MapUtils.getString(param, "refundTimeS"), "yyyy-MM-dd HH:mm:ss"), + DateUtil.format(MapUtils.getString(param, "refundTimeE"), "yyyy-MM-dd HH:mm:ss")); + } example.setOrderByClause("create_time desc"); return orderMapper.selectByExample(example); 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 facf27b0..cd789016 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 @@ -20,6 +20,9 @@ public enum OrderProductType { PRODUCT_TYPE9(9, "话费充值" , "orderLogo/calls.png", "CALLS_CONFIG"), PRODUCT_TYPE10(10, "电影票" ,"" , ""), PRODUCT_TYPE11(11, "贵州中石化" , "", "GZ_SINOPEC_CONFIG"), + PRODUCT_TYPE12(12, "实物商品" , "orderLogo/goods.png", "GOODS"), + PRODUCT_TYPE101(101, "惠支付" , "orderLogo/pay.png", "PAY"), + PRODUCT_TYPE102(102, "门店活动" , "orderLogo/store_activity.png", "STORE_ACTIVITY"), ; private Integer number; diff --git a/hai-service/src/main/java/com/hai/service/BsOrderRebateService.java b/hai-service/src/main/java/com/hai/service/BsOrderRebateService.java index 306e3156..33515987 100644 --- a/hai-service/src/main/java/com/hai/service/BsOrderRebateService.java +++ b/hai-service/src/main/java/com/hai/service/BsOrderRebateService.java @@ -1,5 +1,6 @@ package com.hai.service; +import com.alibaba.fastjson.JSONObject; import com.hai.entity.BsOperationLog; import com.hai.entity.BsOrderRebate; import com.hai.entity.HighOrder; @@ -65,4 +66,14 @@ public interface BsOrderRebateService { * @Return void */ void insertOrderRebate(HighOrder highOrder); + + /** + * @Author Sum1Dream + * @Name insertOrderRebate + * @Description // 插入积分返利记录 + * @Date 14:53 2023/4/24 + * @Param [object] + * @Return void + */ + void insertOrderRebate(JSONObject object); } diff --git a/hai-service/src/main/java/com/hai/service/CommonService.java b/hai-service/src/main/java/com/hai/service/CommonService.java index f16e6a0f..fc87321f 100644 --- a/hai-service/src/main/java/com/hai/service/CommonService.java +++ b/hai-service/src/main/java/com/hai/service/CommonService.java @@ -328,4 +328,14 @@ public interface CommonService { * @Return java.util.List */ List getSecRegion(Long parentId); + + /** + * @Author Sum1Dream + * @Name getIndustry + * @Description // 获取行业数据 + * @Date 14:16 2023/4/26 + * @Param [] + * @Return com.alibaba.fastjson.JSONObject + */ + JSONObject getIndustry(); } diff --git a/hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java b/hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java index 002cb21b..b8ead430 100644 --- a/hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java +++ b/hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java @@ -208,4 +208,6 @@ public interface OutRechargeOrderService { * @Return java.lang.Integer 1:满足继续充值条件 2:订单满足退款条件 3:订单不可以退款不可以继续充值 4:订单异常 5:订单充值完成 */ Integer orderWhetherRecharge(OutRechargeOrder rechargeOrder) throws Exception; + + OutRechargeChildOrder mobileChildOrderHandle(HighOrder highOrder , OutRechargeOrder outRechargeOrder); } diff --git a/hai-service/src/main/java/com/hai/service/impl/BsDistributionUserRelServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/BsDistributionUserRelServiceImpl.java index 904463c6..e72c165c 100644 --- a/hai-service/src/main/java/com/hai/service/impl/BsDistributionUserRelServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/BsDistributionUserRelServiceImpl.java @@ -113,7 +113,6 @@ public class BsDistributionUserRelServiceImpl implements BsDistributionUserRelSe } } - } catch (Exception e) { e.printStackTrace(); } diff --git a/hai-service/src/main/java/com/hai/service/impl/BsOrderRebateServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/BsOrderRebateServiceImpl.java index 5841bd46..8d1eafa8 100644 --- a/hai-service/src/main/java/com/hai/service/impl/BsOrderRebateServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/BsOrderRebateServiceImpl.java @@ -1,12 +1,12 @@ package com.hai.service.impl; 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.DateUtil; import com.hai.dao.BsOrderRebateMapper; -import com.hai.entity.BsIntegralRebate; -import com.hai.entity.BsOrderRebate; -import com.hai.entity.BsOrderRebateExample; -import com.hai.entity.HighOrder; +import com.hai.entity.*; import com.hai.order.type.OrderProductType; import com.hai.service.*; import org.springframework.stereotype.Service; @@ -36,6 +36,9 @@ public class BsOrderRebateServiceImpl implements BsOrderRebateService { @Resource private HighUserService highUserService; + @Resource + private HighGoldRecService highGoldRecService; + @Override public List getOrderRebateByList(Map map) { @@ -115,4 +118,92 @@ public class BsOrderRebateServiceImpl implements BsOrderRebateService { } + + @Override + public void insertOrderRebate(JSONObject jsonObject) { + + if (jsonObject.getInteger("productType") ==null + || jsonObject.getLong("userId") == null + || jsonObject.getString("orderNo") == null + || jsonObject.getLong("orderId") == null + || jsonObject.getString("title") == null + || jsonObject.getDate("createTime") == null + || jsonObject.getBigDecimal("price") == null + ) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "缺少参数!"); + } + + HighUser highUser = highUserService.findByUserId(jsonObject.getLong("userId")); + // 计算返利积分数量 + // 查询是否配置返利 + Map map = new HashMap<>(); + map.put("type" , jsonObject.getInteger("productType")); + map.put("companyId" ,2); + + BsIntegralRebate bsIntegralRebate = bsIntegralRebateService.findIntegralRebateByMap(map); + + // 判断是否配置返利内容 + if (bsIntegralRebate != null) { + + // 查询是否存在积分记录 + Map mapGold = new HashMap<>(); + mapGold.put("goldType", 1); + mapGold.put("resType", jsonObject.getInteger("productType")); + mapGold.put("userId", highUser.getId()); + mapGold.put("resId", jsonObject.getLong("orderId")); + + List goldRecs = highGoldRecService.getGoldRec(mapGold); + + // 判断是否重复赠送积分 + if (goldRecs.size() > 0) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "重复赠送!"); + } + + // 判断是否在返利条件 + if (DateUtil.isEffectiveDate(jsonObject.getDate("createTime"), bsIntegralRebate.getStartTime() , bsIntegralRebate.getEndTime())) { + + // 定义请求对象 + JSONObject object = new JSONObject(); + + // 积分返利积分 + BigDecimal integralNum = jsonObject.getBigDecimal("price").multiply(bsIntegralRebate.getPercentage()).setScale( 0, BigDecimal.ROUND_HALF_UP ); + if (bsIntegralRebate.getSecondDistribution() !=null || bsIntegralRebate.getFirstDistribution() != null) { + // 1级分销 + BigDecimal integralNumFirst = jsonObject.getBigDecimal("price").multiply(bsIntegralRebate.getFirstDistribution()).setScale( 0, BigDecimal.ROUND_HALF_UP ); + // 2级分销 + BigDecimal integralNumSecond = jsonObject.getBigDecimal("price").multiply(bsIntegralRebate.getSecondDistribution()).setScale( 0, BigDecimal.ROUND_HALF_UP ); + object.put("integralNumFirst" , integralNumFirst); + object.put("integralNumSecond" , integralNumSecond); + + } + + // 拼接分销返利对象 + object.put("userId" , jsonObject.getLong("userId")); + object.put("orderNo" , jsonObject.getString("orderNo")); + + object.put("companyId", 2); + object.put("remark" , OrderProductType.getDataByType(jsonObject.getInteger("productType")).getName() + "下单:"+ jsonObject.getString("title") + "-" + jsonObject.getString("orderNo") + "积分返利:"); + object.put("name" , "下单" + OrderProductType.getDataByType(jsonObject.getInteger("productType")).getName() + ":" + jsonObject.getString("title")); + object.put("logoImg" , OrderProductType.getDataByType(jsonObject.getInteger("productType")).getImgUrl()); + + bsDistributionUserRelService.distributionRebate(object); + highUserService.goldHandle(jsonObject.getLong("userId"), integralNum.intValue(), 1, jsonObject.getInteger("productType"), jsonObject.getLong("orderId"), object.getString("remark") + integralNum); + + // 查询积分返利记录 + BsOrderRebate orderRebate = new BsOrderRebate(); + orderRebate.setOrderId(jsonObject.getLong("orderId")); + orderRebate.setOrderNo(jsonObject.getString("orderNo")); + orderRebate.setCreateTime(new Date()); + orderRebate.setUpdateTime(new Date()); + orderRebate.setStatus(1); + orderRebate.setIntegralNum(integralNum.intValue()); + orderRebate.setUserId(highUser.getId()); + orderRebate.setUserName(highUser.getName()); + bsOrderRebateMapper.insert(orderRebate); + } + + } else { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前未配置积分返利规则!"); + } + } } diff --git a/hai-service/src/main/java/com/hai/service/impl/CommonServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/CommonServiceImpl.java index 643609cd..2e84edcc 100644 --- a/hai-service/src/main/java/com/hai/service/impl/CommonServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/CommonServiceImpl.java @@ -9,6 +9,7 @@ import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.utils.HttpsUtils; +import com.hai.config.CommonSysConst; import com.hai.dao.*; import com.hai.dao.order.OrderStatisticsMapperExt; import com.hai.entity.*; @@ -793,4 +794,9 @@ public class CommonServiceImpl implements CommonService { return regionMapper.selectByExample(example); } + + @Override + public JSONObject getIndustry() { + return HttpsUtils.doGet(CommonSysConst.getSysConfig().getPayPostUrl() + "/common/getIndustry"); + } } 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 3b65dfc7..0586d07e 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 @@ -871,9 +871,6 @@ public class HighOrderServiceImpl implements HighOrderService { DateUtil.format(MapUtils.getString(map, "refundTimeE"), "yyyy-MM-dd HH:mm:ss")); } -// example.setOrderByClause("create_time desc"); - - return highOrderMapper.selectByExample(example); } 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 c0ded440..a8dfa436 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 @@ -198,7 +198,6 @@ public class HighUserServiceImpl implements HighUserService { user.setUnpaid(highOrderService.countOrderByUserId(userId , 1)); user.setOrderPayNum(highOrderService.countOrderByUserId(userId , 2)); user.setWhetherCheckNum(highOrderService.whetherCheck(userId , 3)); - // user.setRechargeOrderNum(outRechargeOrderService.rechargeOrderNum(userId)); user.setUnusedDiscount(highOrderService.countUnusedDiscountByUserId(userId , 1)); user.setIsSetPayPwd(highUserPayPasswordService.isSetPayPwd(userId)); user.setIsSetHltCard(highUserCardService.isBindHtlCard(userId)); diff --git a/hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java index 49a5e72d..c05a3824 100644 --- a/hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java @@ -84,6 +84,9 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { @Autowired private RedisTemplate redisTemplate; + @Autowired + private OutRechargeChildOrderService childOrderService; + @Override public List getListRechargeOrder(Map map) { OutRechargeOrderExample example = new OutRechargeOrderExample(); @@ -713,6 +716,9 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { // 查询子订单 List childOrderList = outRechargeChildOrderService.getListRechargeChildOrderByOrderId(rechargeOrder.getId()); + if (childOrderList.size() == 0) { + return 4; + } // 充值订单充值时间 Date rechargeTime = rechargeOrder.getCreateTimed(); @@ -813,4 +819,41 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { rechargeChildOrder.setStatus(status); outRechargeChildOrderService.updateOrder(rechargeChildOrder); } + + @Override + public OutRechargeChildOrder mobileChildOrderHandle(HighOrder highOrder, OutRechargeOrder outRechargeOrder) { + // 组装查询子订单数据 + Map childOrderMap101 = new HashMap<>(); + childOrderMap101.put("parent_order_id", outRechargeOrder.getId()); + childOrderMap101.put("status", "101,102"); + // 查询充值订单 + List childOrders = childOrderService.getListRechargeChildOrder(childOrderMap101); + + OutRechargeChildOrder childOrder; + + // 判读是否存在多个充值中的订单 + if (childOrders.size() > 0) { + childOrder = childOrders.get(0); + if (childOrders.size() > 1) { + childOrder.setExt1("当前订单存在多个充值订单"); + } + + } else { + childOrder = childOrderService.findByOrderId(outRechargeOrder.getId()); + if (childOrder != null && highOrder != null && childOrder.getStatus() != null && highOrder.getOrderStatus() != null) { + if (highOrder.getOrderStatus() == 2 && childOrder.getStatus() != 102) { + childOrder.setExt1("主订单充值中,但是充值订单状态不为充值中"); + } + if (highOrder.getOrderStatus() == 3 && childOrder.getStatus() != 101) { + childOrder.setExt1("主订单充值成功,但是充值订单状态不为充值成功"); + } + if (highOrder.getOrderStatus() == 4 && !(childOrder.getStatus() == 103 || childOrder.getStatus() == 104)) { + childOrder.setExt1("主订单退款,但是充值订单状态不为退款"); + } + } + + } + + return childOrder; + } } diff --git a/hai-service/src/main/resources/dev/commonConfig.properties b/hai-service/src/main/resources/dev/commonConfig.properties index 56716f61..6918a75b 100644 --- a/hai-service/src/main/resources/dev/commonConfig.properties +++ b/hai-service/src/main/resources/dev/commonConfig.properties @@ -120,6 +120,9 @@ wxAppSecret=d8d6dcaef77d3b659258a01b5ddba5df wxH5AppId=wxa075e8509802f826 wxH5AppSecret=0e606fc1378d35e359fcf3f15570b2c5 - logisticsAppKey=5d806a99fbcc48e19717beef11fa1700 logisticsAppSecret=5ba7552b194e4147b7db1c34143e3317 + +#PAY +#payPostUrl=https://gratia-pay.dctpay.com/crest/ +payPostUrl=http://localhost:9601//crest/ diff --git a/v1/src/main/java/com/v1/config/AuthConfig.java b/v1/src/main/java/com/v1/config/AuthConfig.java index 863c83a8..c38c8b84 100644 --- a/v1/src/main/java/com/v1/config/AuthConfig.java +++ b/v1/src/main/java/com/v1/config/AuthConfig.java @@ -96,6 +96,7 @@ public class AuthConfig implements WebMvcConfigurer { .excludePathPatterns("/selfOilStation/*") .excludePathPatterns("/order/*") .excludePathPatterns("/wxMsg/*") + .excludePathPatterns("/orderRebate/*") .excludePathPatterns("/refuelOnline/*") ; } diff --git a/v1/src/main/java/com/v1/controller/WxMsgController.java b/v1/src/main/java/com/v1/controller/WxMsgController.java index 5adfe57f..73dda188 100644 --- a/v1/src/main/java/com/v1/controller/WxMsgController.java +++ b/v1/src/main/java/com/v1/controller/WxMsgController.java @@ -126,152 +126,10 @@ public class WxMsgController { // 二维码参数 String eventKey = map.get("EventKey"); log.info("二维码参数:" + eventKey); - // 判断用户是否是新用户 - HighUser user = highUserService.findByOpenIdH5(userOpenId); String linkContent = ""; - String newUserContent = ""; String content = ""; - if (eventKey != null && eventKey.length() != 0) { - JSONObject object = weChatQrcodeUtils.paramPars(eventKey); - // type = 1 推广扫码 - if (Objects.equals(object.getString("qrscene_type"), WxQrCodeTypeEnum.type1.getType()) || Objects.equals(object.getString("type"), WxQrCodeTypeEnum.type1.getType())) { -// linkContent = "打开小程序"; - linkContent ="扫码领取\n\n"; - - System.out.println(linkContent); - - // todo 推广扫码 - } - // type = 2 在线加油门店扫码 - if (Objects.equals(object.getString("qrscene_type"), WxQrCodeTypeEnum.type2.getType()) || Objects.equals(object.getString("type"), WxQrCodeTypeEnum.type2.getType())){ - // 商户门店 - HighMerchantStoreModel store = merchantStoreService.getMerchantStoreByKey(object.getString("code")); - linkContent = - "欢迎来到" + store.getStoreName()+"" - + "[哇][哇][哇]\n\n点击这里一键加油\n\n"; - } - // 3:查看视频教程 - if (Objects.equals(object.getString("qrscene_type"), WxQrCodeTypeEnum.type3.getType()) || Objects.equals(object.getString("type"), WxQrCodeTypeEnum.type3.getType())){ - // 重庆 - if ( Objects.equals(object.getString("code"), "1")) { - linkContent = - "加油优惠选我们,你的出行不再忧愁\uD83D\uDC97\n\n" - + "查看中石油操作流程\n\n" - + "走得更远,看得更美的风景,加油添生活![太阳]\n\n" - + "好车要好油,优惠更加牛![發]\n\n"; - } - // 贵州 - if (Objects.equals(object.getString("code"), "2")) { - linkContent = - "加满好油,一路畅游!✨✨\n\n" - + "查看中石化操作流程\n\n" - + "用心为您着想,诚意为您服务。\uD83C\uDF39\n\n" - + "油客来自五湖四海,在这里祝您一路顺风。\n\n"; - - } - - } - // 4:支付码牌扫码 - if (Objects.equals(object.getString("qrscene_type"), WxQrCodeTypeEnum.type4.getType()) || Objects.equals(object.getString("type"), WxQrCodeTypeEnum.type4.getType())){ - // 支付码码牌上的二维码 - if (Objects.equals(object.getString("codeType"), "PAYMENT_CODE")) { - linkContent = - "点击领取优惠券,享受更多优惠[礼物]\n\n" - + "立即领取优惠券\n\n"; - - - } - - // 支付成功生成的二维码 - if (Objects.equals(object.getString("codeType"), "PAYMENT_SUCCESS")) { - linkContent = - "支付分享,享受更高优惠[礼物]\n\n" - + "分享好友\n\n"; - } - // 扫码分享二维码进入 - if (Objects.equals(object.getString("codeType"), "SHARE")) { - linkContent = - "支付分享,享受更高优惠[礼物]\n\n" - + "分享好友\n\n"; - } - } - - // 5:扫码贵州中石化优惠券二维码 - if (Objects.equals(object.getString("qrscene_type"), WxQrCodeTypeEnum.type5.getType()) || Objects.equals(object.getString("type"), WxQrCodeTypeEnum.type5.getType())){ - mapQrCode.put("type", object.getString("encryptType")); - // 二维码参数 - mapQrCode.put("id", object.getString("code")); - // 商户门店 - linkContent = - "山高水远,相伴致远[爱心][爱心]\n\n" - + "领取中石化加油券\n\n" - + "您追求实惠的折扣,我们追求高超的品质\uD83D\uDD16\n\n" - + "迎南来北往宾朋尊驾,[福]\n\n" - + "送平安顺遂诚意祝福![福]\n\n"; - } - // 6:扫码重庆中石油优惠券二维码 - if (Objects.equals(object.getString("qrscene_type"), WxQrCodeTypeEnum.type6.getType()) || Objects.equals(object.getString("type"), WxQrCodeTypeEnum.type6.getType())){ - mapQrCode.put("type", object.getString("encryptType")); - // 二维码参数 - mapQrCode.put("id", object.getString("code")); - log.info("map参数:" + mapQrCode); - // 商户门店 - linkContent = - "加好油,添好运,我们更适意[礼物]\n\n" - + "领取中石油加油券\n\n" - + "致力于质量与福利,赢得客户心。\n\n" - + "一路精彩,“油”我相伴!\uD83C\uDF1F\n\n"; - } - } - else { - linkContent = "点击查看更多优惠\n\n"; - } - - System.out.println("===================" + linkContent); - // 判断是否是新用户 -// if (user == null) { -// newUserContent = "特意为您奉上" + -// "5张优惠券" + -// ",放在您的"+ -// "优惠券"+ -// "里面,记得及时使用哦[爱心][爱心][爱心]\n\n"; -// } log.info("二维码参数:" + eventKey); @@ -289,7 +147,6 @@ public class WxMsgController { else if ("event".equals(msgType)) { // 用户关注公众号 if ("subscribe".equals(event)) { - log.info("进入扫码关注流程:" + event); content = "您好,感谢关注嗨森逛商城!\n\n" + linkContent + @@ -299,10 +156,128 @@ public class WxMsgController { } // 用户扫码进入公众号 else if ("SCAN".equals(event)) { + if (eventKey != null && eventKey.length() != 0) { + JSONObject object = weChatQrcodeUtils.paramPars(eventKey); + // type = 1 推广扫码 + if (Objects.equals(object.getString("qrscene_type"), WxQrCodeTypeEnum.type1.getType()) || Objects.equals(object.getString("type"), WxQrCodeTypeEnum.type1.getType())) { + linkContent ="扫码领取\n\n"; + // todo 推广扫码 + } + // type = 2 在线加油门店扫码 + if (Objects.equals(object.getString("qrscene_type"), WxQrCodeTypeEnum.type2.getType()) || Objects.equals(object.getString("type"), WxQrCodeTypeEnum.type2.getType())){ + // 商户门店 + HighMerchantStoreModel store = merchantStoreService.getMerchantStoreByKey(object.getString("code")); + linkContent = + "欢迎来到" + store.getStoreName()+"" + + "[哇][哇][哇]\n\n点击这里一键加油\n\n"; + } + // 3:查看视频教程 + if (Objects.equals(object.getString("qrscene_type"), WxQrCodeTypeEnum.type3.getType()) || Objects.equals(object.getString("type"), WxQrCodeTypeEnum.type3.getType())){ + // 重庆 + if ( Objects.equals(object.getString("code"), "1")) { + linkContent = + "加油优惠选我们,你的出行不再忧愁\uD83D\uDC97\n\n" + + "查看中石油操作流程\n\n" + + "走得更远,看得更美的风景,加油添生活![太阳]\n\n" + + "好车要好油,优惠更加牛![發]\n\n"; + } + // 贵州 + if (Objects.equals(object.getString("code"), "2")) { + linkContent = + "加满好油,一路畅游!✨✨\n\n" + + "查看中石化操作流程\n\n" + + "用心为您着想,诚意为您服务。\uD83C\uDF39\n\n" + + "油客来自五湖四海,在这里祝您一路顺风。\n\n"; + + } + + } + // 4:支付码牌扫码 + if (Objects.equals(object.getString("qrscene_type"), WxQrCodeTypeEnum.type4.getType()) || Objects.equals(object.getString("type"), WxQrCodeTypeEnum.type4.getType())){ + // 支付码码牌上的二维码 + if (Objects.equals(object.getString("codeType"), "PAYMENT_CODE")) { + linkContent = + "点击领取优惠券,享受更多优惠[礼物]\n\n" + + "立即领取优惠券\n\n"; + + + } + + // 支付成功生成的二维码 + if (Objects.equals(object.getString("codeType"), "PAYMENT_SUCCESS")) { + linkContent = + "支付分享,享受更高优惠[礼物]\n\n" + + "分享好友\n\n"; + } + // 扫码分享二维码进入 + if (Objects.equals(object.getString("codeType"), "SHARE")) { + linkContent = + "支付分享,享受更高优惠[礼物]\n\n" + + "分享好友\n\n"; + } + } + + // 5:扫码贵州中石化优惠券二维码 + if (Objects.equals(object.getString("qrscene_type"), WxQrCodeTypeEnum.type5.getType()) || Objects.equals(object.getString("type"), WxQrCodeTypeEnum.type5.getType())){ + mapQrCode.put("type", object.getString("encryptType")); + // 二维码参数 + mapQrCode.put("id", object.getString("code")); + // 商户门店 + linkContent = + "山高水远,相伴致远[爱心][爱心]\n\n" + + "领取中石化加油券\n\n" + + "您追求实惠的折扣,我们追求高超的品质\uD83D\uDD16\n\n" + + "迎南来北往宾朋尊驾,[福]\n\n" + + "送平安顺遂诚意祝福![福]\n\n"; + } + // 6:扫码重庆中石油优惠券二维码 + if (Objects.equals(object.getString("qrscene_type"), WxQrCodeTypeEnum.type6.getType()) || Objects.equals(object.getString("type"), WxQrCodeTypeEnum.type6.getType())){ + mapQrCode.put("type", object.getString("encryptType")); + // 二维码参数 + mapQrCode.put("id", object.getString("code")); + log.info("map参数:" + mapQrCode); + // 商户门店 + linkContent = + "加好油,添好运,我们更适意[礼物]\n\n" + + "领取中石油加油券\n\n" + + "致力于质量与福利,赢得客户心。\n\n" + + "一路精彩,“油”我相伴!\uD83C\uDF1F\n\n"; + } + } + else { + linkContent = "点击查看更多优惠\n\n"; + } content = linkContent + "服务热线:400-023-6806"; }else if ("unsubscribe".equals(event)) { // todo 取消关注 业务处理 + }else if ("CLICK".equals(event)) { + content = linkContent + "服务热线:400-023-6806"; } map.put("content" , content); String mapToXml = weChatQrcodeUtils.handleEventSubscribe(map); diff --git a/v1/src/main/java/com/v1/controller/business/ApiMerchantsController.java b/v1/src/main/java/com/v1/controller/business/ApiMerchantsController.java index 4b0beae5..e64978f6 100644 --- a/v1/src/main/java/com/v1/controller/business/ApiMerchantsController.java +++ b/v1/src/main/java/com/v1/controller/business/ApiMerchantsController.java @@ -55,7 +55,7 @@ public class ApiMerchantsController { ip = request.getHeader("x-forwarded-for"); } - if (!secConfigService.isConfig("IP_WHITE" , ip)) { + if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) { log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!"); throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!"); } diff --git a/v1/src/main/java/com/v1/controller/business/GzSinopecController.java b/v1/src/main/java/com/v1/controller/business/GzSinopecController.java index f6ab3a16..12f2a23a 100644 --- a/v1/src/main/java/com/v1/controller/business/GzSinopecController.java +++ b/v1/src/main/java/com/v1/controller/business/GzSinopecController.java @@ -14,6 +14,7 @@ import com.hai.entity.HighGasOrderPush; import com.hai.enum_type.OrderPushType; import com.hai.model.ResponseData; import com.hai.order.type.OrderProductType; +import com.hai.service.ApiIpAddressService; import com.hai.service.ApiMerchantsService; import com.hai.service.SecConfigService; import com.v1.config.ToolConfig; @@ -41,8 +42,9 @@ public class GzSinopecController { @Resource private ApiMerchantsService apiMerchantsService; + @Resource - private HighGasOrderPushMapper highGasOrderPushMapper; + private ApiIpAddressService apiIpAddressService; @Resource private SecConfigService secConfigService; @@ -61,9 +63,9 @@ public class GzSinopecController { ip = request.getHeader("x-forwarded-for"); } - if (!secConfigService.isConfig("IP_WHITE", ip)) { - log.error("getGuizhouSinopec error!", "非法ip地址,请联系管理人员!"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "非法ip地址,请联系管理人员!"); + if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) { + log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!"); } @@ -229,9 +231,9 @@ public class GzSinopecController { ip = request.getHeader("x-forwarded-for"); } - if (!secConfigService.isConfig("IP_WHITE", ip)) { - log.error("getGuizhouSinopec error!", "非法ip地址,请联系管理人员!"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "非法ip地址,请联系管理人员!"); + if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) { + log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!"); } diff --git a/v1/src/main/java/com/v1/controller/business/OrderRebateController.java b/v1/src/main/java/com/v1/controller/business/OrderRebateController.java new file mode 100644 index 00000000..37d4e8f8 --- /dev/null +++ b/v1/src/main/java/com/v1/controller/business/OrderRebateController.java @@ -0,0 +1,110 @@ +package com.v1.controller.business; + +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.ResponseMsgUtil; +import com.hai.entity.ApiMerchants; +import com.hai.model.ResponseData; +import com.hai.service.ApiIpAddressService; +import com.hai.service.ApiMerchantsService; +import com.hai.service.BsOrderRebateService; +import com.hai.service.SecConfigService; +import com.hai.service.impl.OutRechargeOrderServiceImpl; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +@Controller +@RequestMapping(value = "/orderRebate") +@Api(value = "订单返利") +public class OrderRebateController { + + private static final Logger log = LoggerFactory.getLogger(OutRechargeOrderServiceImpl.class); + + @Resource + private BsOrderRebateService bsOrderRebateService; + + @Resource + private ApiMerchantsService apiMerchantsService; + + @Resource + private SecConfigService secConfigService; + + @Resource + private ApiIpAddressService apiIpAddressService; + + @RequestMapping(value = "/rebate", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "积分返利") + public ResponseData rebate(@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("apiKey")) || + StringUtils.isBlank(object.getString("merchId")) || + 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); + } + + Map map = new HashMap<>(); + map.put("apiKey" , object.getString("apiKey")); + map.put("merchId" , object.getString("merchId")); + map.put("userId" , object.getString("userId")); + map.put("productType" , object.getInteger("productType")); + map.put("orderNo" , object.getString("orderNo")); + map.put("orderId" , object.getLong("orderId")); + map.put("price" , object.getBigDecimal("price")); + map.put("title" , object.getString("title")); + map.put("createTime" , object.getDate("createTime")); + + if (!secConfigService.isSignVerify(map , object.getString("sign"))) { + log.error("getRechargeProduct error!", "签名校验失败!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY); + } + + bsOrderRebateService.insertOrderRebate(object); + + return ResponseMsgUtil.success("赠送成功"); + } catch (Exception e) { + log.error("HighOrderController --> getBackendToken() error!", e); + return ResponseMsgUtil.exception(e); + } + } + +}