From 3accfad213302bd36d7bddfa7b25f7a106d53d0f Mon Sep 17 00:00:00 2001 From: Sum1Dream <418471657@qq.com> Date: Mon, 17 Apr 2023 14:04:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E5=AE=9E=E7=89=A9=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/bweb/controller/CommonController.java | 62 +++ .../Goods/GoodsDetailController.java | 2 +- .../Goods/GoodsRegionFreightController.java | 233 ++++++++ .../bweb/controller/HighTestController.java | 2 +- .../com/cweb/controller/CommonController.java | 518 +++++++++--------- .../Goods/DeliveryAddressController.java | 206 +++++++ .../controller/Goods/GoodsController.java | 44 ++ .../Goods/ShoppingCartController.java | 2 +- .../java/com/hai/config/CommonConfig.java | 18 + .../java/com/hai/config/CommonSysConfig.java | 3 + .../goods/service/DeliveryAddressService.java | 77 +++ .../hai/goods/service/GoodsDetailService.java | 2 + .../goods/service/GoodsLogisticsService.java | 77 +++ .../service/GoodsRegionFreightService.java | 89 +++ .../impl/DeliveryAddressServiceImpl.java | 69 +++ .../service/impl/GoodsDetailServiceImpl.java | 6 + .../impl/GoodsLogisticsServiceImpl.java | 88 +++ .../impl/GoodsRegionFreightServiceImpl.java | 186 +++++++ .../java/com/hai/service/CommonService.java | 2 +- .../hai/service/impl/CommonServiceImpl.java | 19 +- .../resources/dev/commonConfig.properties | 4 + 21 files changed, 1438 insertions(+), 271 deletions(-) create mode 100644 hai-bweb/src/main/java/com/bweb/controller/Goods/GoodsRegionFreightController.java create mode 100644 hai-cweb/src/main/java/com/cweb/controller/Goods/DeliveryAddressController.java create mode 100644 hai-service/src/main/java/com/hai/goods/service/DeliveryAddressService.java create mode 100644 hai-service/src/main/java/com/hai/goods/service/GoodsLogisticsService.java create mode 100644 hai-service/src/main/java/com/hai/goods/service/GoodsRegionFreightService.java create mode 100644 hai-service/src/main/java/com/hai/goods/service/impl/DeliveryAddressServiceImpl.java create mode 100644 hai-service/src/main/java/com/hai/goods/service/impl/GoodsLogisticsServiceImpl.java create mode 100644 hai-service/src/main/java/com/hai/goods/service/impl/GoodsRegionFreightServiceImpl.java 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 21feb168..1696f1eb 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/CommonController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/CommonController.java @@ -7,9 +7,12 @@ import com.hai.common.exception.SysCode; import com.hai.common.utils.DateUtil; import com.hai.common.utils.RedisUtil; import com.hai.common.utils.ResponseMsgUtil; +import com.hai.config.CommonConfig; import com.hai.config.TuanYouConfig; +import com.hai.entity.GoodsLogistics; import com.hai.entity.SecConfig; import com.hai.entity.SecDictionary; +import com.hai.goods.service.GoodsLogisticsService; import com.hai.model.*; import com.hai.service.CommonService; import com.hai.service.SecConfigService; @@ -45,6 +48,9 @@ public class CommonController { @Resource private RedisUtil redisUtil; + @Resource + private GoodsLogisticsService logisticsService; + @RequestMapping(value="/getRedisValueByType",method= RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询redis中的value") @@ -384,5 +390,61 @@ public class CommonController { } } + @RequestMapping(value = "/getLogisticsMsg", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "根据快递单号查询物流信息") + 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); + + return ResponseMsgUtil.success(logistics); + } + + return ResponseMsgUtil.success(jsonObjects); + + } else { + return ResponseMsgUtil.success(data); + } + + + } catch (Exception e) { + log.error("HighOrderController --> getUserOrderList() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/getRegional", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "获取区域信息") + public ResponseData getRegional() { + 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); + } + + + } catch (Exception e) { + log.error("HighOrderController --> unionStagingPay() error!", e); + return ResponseMsgUtil.exception(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 e4a92583..f2758f75 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 @@ -164,7 +164,7 @@ public class GoodsDetailController { @RequestMapping(value = "/findGoodsDetailById", method = RequestMethod.GET) @ResponseBody - @ApiOperation(value = "查询商品列表") + @ApiOperation(value = "查询商品") public ResponseData findGoodsDetailById( @RequestParam(value = "id", required = true) Long id ) { diff --git a/hai-bweb/src/main/java/com/bweb/controller/Goods/GoodsRegionFreightController.java b/hai-bweb/src/main/java/com/bweb/controller/Goods/GoodsRegionFreightController.java new file mode 100644 index 00000000..f75812f4 --- /dev/null +++ b/hai-bweb/src/main/java/com/bweb/controller/Goods/GoodsRegionFreightController.java @@ -0,0 +1,233 @@ +package com.bweb.controller.Goods; + +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.SessionObject; +import com.hai.common.security.UserCenter; +import com.hai.common.utils.ResponseMsgUtil; +import com.hai.entity.GoodsDetail; +import com.hai.entity.GoodsRegionFreight; +import com.hai.entity.HighGoodsType; +import com.hai.entity.SecRegion; +import com.hai.goods.service.GoodsRegionFreightService; +import com.hai.model.ResponseData; +import com.hai.model.UserInfoModel; +import com.hai.service.CommonService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.util.*; + +@Controller +@RequestMapping(value = "/regionFreight") +@Api(value = "区域运费业务") +public class GoodsRegionFreightController { + + Logger log = LoggerFactory.getLogger(GoodsRegionFreightController.class); + + @Resource + private GoodsRegionFreightService regionFreightService; + + @Autowired + private UserCenter userCenter; + + @Resource + private CommonService commonService; + + @RequestMapping(value = "/getListRegionFreight", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询列表") + public ResponseData getListRegionFreight( + @RequestParam(value = "regionName", required = false) String regionName, + @RequestParam(value = "regionId", required = false) String regionId, + @RequestParam(name = "pageNum", required = true) Integer pageNum, + @RequestParam(name = "pageSize", required = true) Integer pageSize + ) { + try { + + + Map map = new HashMap<>(); + + map.put("regionName", regionName); + map.put("regionId", regionId); + + PageHelper.startPage(pageNum,pageSize); + + List list = regionFreightService.getRegionFreightList(map); + return ResponseMsgUtil.success(new PageInfo<>(list)); + + } catch (Exception e) { + log.error("GoodsDetailController --> getListUser() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/insertRegionFreight", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "新增产品") + public ResponseData insertRegionFreight(@RequestBody GoodsRegionFreight regionFreight, HttpServletRequest request) { + try { + + SessionObject sessionObject = userCenter.getSessionObject(request); + UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); + + if (regionFreight == null || + regionFreight.getRegionId() == null || + regionFreight.getFreightPrice() == null || + regionFreight.getFreePostPrice() == null + ) { + log.error("GoodsDetailController -> insertProduct() error!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + GoodsRegionFreight goodsRegionFreight = regionFreightService.findRegionFreightByRegionId(regionFreight.getRegionId()); + + if (goodsRegionFreight != null) { + log.error("GoodsDetailController -> insertProduct() error!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前区域已经配置!"); + } + + SecRegion region = commonService.getRegionsById(Long.valueOf(regionFreight.getRegionId())); + + if (region == null) { + log.error("GoodsDetailController -> insertProduct() error!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "区域错误!"); + } + + regionFreight.setRegionName(region.getRegionName()); + regionFreight.setOpId(userInfoModel.getSecUser().getId()); + regionFreight.setStatus(1); + regionFreight.setOpName(userInfoModel.getSecUser().getLoginName()); + regionFreight.setCreateTime(new Date()); + regionFreight.setUpdateTime(new Date()); + + regionFreightService.insertRegionFreight(regionFreight); + + return ResponseMsgUtil.success("新增成功"); + + } catch (Exception e) { + log.error("GoodsDetailController --> insertPrice() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/updateRegionFreight", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "修改产品") + public ResponseData updateRegionFreight(@RequestBody GoodsRegionFreight regionFreight, HttpServletRequest request) { + try { + + SessionObject sessionObject = userCenter.getSessionObject(request); + UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); + + if (regionFreight == null || + regionFreight.getId() == null || + regionFreight.getRegionId() == null || + regionFreight.getFreightPrice() == null || + regionFreight.getFreePostPrice() == null + ) { + log.error("GoodsDetailController -> insertProduct() error!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + GoodsRegionFreight goodsRegionFreight = regionFreightService.findRegionFreightById(regionFreight.getId()); + + GoodsRegionFreight freightByRegionId = regionFreightService.findRegionFreightByRegionId(regionFreight.getRegionId()); + + + + if (goodsRegionFreight != null && !Objects.equals(freightByRegionId.getId(), goodsRegionFreight.getId())) { + log.error("GoodsDetailController -> insertProduct() error!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前区域已经配置!"); + + } + + SecRegion region = commonService.getRegionsById(Long.valueOf(regionFreight.getRegionId())); + + if (region == null) { + log.error("GoodsDetailController -> insertProduct() error!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "区域错误!"); + } + + if (goodsRegionFreight == null) { + log.error("GoodsDetailController -> insertProduct() error!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到相关信息!"); + } + + regionFreight.setRegionName(region.getRegionName()); + regionFreight.setOpId(userInfoModel.getSecUser().getId()); + regionFreight.setStatus(goodsRegionFreight.getStatus()); + regionFreight.setOpName(userInfoModel.getSecUser().getLoginName()); + regionFreight.setCreateTime(goodsRegionFreight.getCreateTime()); + regionFreight.setUpdateTime(new Date()); + + regionFreightService.updateRegionFreight(regionFreight); + + return ResponseMsgUtil.success("修改成功"); + + } catch (Exception e) { + log.error("GoodsDetailController --> insertPrice() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/findRegionFreightById", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询商品") + public ResponseData findRegionFreightById( + @RequestParam(value = "id", required = true) Long id + ) { + try { + + GoodsRegionFreight goodsRegionFreight = regionFreightService.findRegionFreightById(id); + + + if (goodsRegionFreight == null) { + log.error("GoodsDetailController -> findGoodsDetailById() error!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到相关信息"); + } + + return ResponseMsgUtil.success(goodsRegionFreight); + + } catch (Exception e) { + log.error("GoodsDetailController --> findGoodsDetailById() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/deleteRegionFreight", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "删除") + public ResponseData deleteRegionFreight( + @RequestParam(value = "id", required = true) Long id + ) { + try { + + GoodsRegionFreight goodsRegionFreight = regionFreightService.findRegionFreightById(id); + + + if (goodsRegionFreight == null) { + log.error("GoodsDetailController -> findGoodsDetailById() error!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到相关信息"); + } + + regionFreightService.deleteRegionFreight(goodsRegionFreight.getId()); + + return ResponseMsgUtil.success("删除成功"); + + } catch (Exception e) { + log.error("GoodsDetailController --> findGoodsDetailById() error!", e); + return ResponseMsgUtil.exception(e); + } + } +} diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java b/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java index b9072a02..7f322a1e 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 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 = "/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 = "/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 CommonService commonService; @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 = "/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 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 899146ff..4934952d 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/CommonController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/CommonController.java @@ -11,6 +11,7 @@ import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.WxUtils; import com.hai.config.WeChatQrcodeUtils; import com.hai.entity.*; +import com.hai.goods.service.GoodsRegionFreightService; import com.hai.model.ResponseData; import com.hai.service.*; import io.swagger.annotations.Api; @@ -31,20 +32,20 @@ import java.util.Map; @RestController -@RequestMapping(value="/common") -@Api(value="共用接口") +@RequestMapping(value = "/common") +@Api(value = "共用接口") public class CommonController { - Logger log = LoggerFactory.getLogger(CommonController.class); - - @Resource - private CommonService commonService; + Logger log = LoggerFactory.getLogger(CommonController.class); - @Resource - private SecConfigService secConfigService; + @Resource + private CommonService commonService; - @Resource - private BsCompanyService bsCompanyService; + @Resource + private SecConfigService secConfigService; + + @Resource + private BsCompanyService bsCompanyService; @Autowired private RedisUtil redisUtil; @@ -52,190 +53,188 @@ public class CommonController { @Resource private BsIntegralRebateService bsIntegralRebateService; - @RequestMapping(value="/getDredgeProvince",method= RequestMethod.GET) - @ResponseBody - @ApiOperation(value = "查询已开通的省份") - public ResponseData getDredgeProvince(){ - try { - List list = bsCompanyService.getCompany(new HashMap<>()); - List> mapList = new ArrayList<>(); - Map map; - if (list.size() > 0) { - for (BsCompany company : list) { - map = new HashMap<>(); - if (StringUtils.isNotBlank(company.getRegionId())) { - map.put("companyId", company.getId()); - map.put("regionId", company.getRegionId()); - SecRegion secRegion = commonService.getRegionsById(Long.parseLong(company.getRegionId())); - if (secRegion != null) { - map.put("regionName", secRegion.getRegionName()); - } - mapList.add(map); - } - } - } - return ResponseMsgUtil.success(mapList); - } catch (Exception e) { - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value="/getRegionsByParentId",method= RequestMethod.GET) - @ResponseBody - @ApiOperation(value = "分级查询区域信息") - public ResponseData getRegionsByParentId(@RequestParam(name = "regionId", required = false) Long regionId){ - try { - if (regionId == null){ - return ResponseMsgUtil.success(commonService.getCities()); - } - return ResponseMsgUtil.success(commonService.getRegionsByParentId(regionId)); - } catch (Exception e) { - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value="/getParentInfosByRegionId",method= RequestMethod.GET) - @ResponseBody - @ApiOperation(value = "查询父级区域信息") - public ResponseData getParentInfosByRegionId(@RequestParam(name = "regionId", required = true) Long regionId) { - try { - return ResponseMsgUtil.success(commonService.getParentInfoByRegionId(regionId)); - } catch (Exception e) { - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value="/getRegionsById",method= RequestMethod.GET) - @ResponseBody - @ApiOperation(value = "查询区域详细信息") - public ResponseData getRegionsById(@RequestParam(name = "regionId", required = true) Long regionId){ - try { - return ResponseMsgUtil.success(commonService.getRegionsById(regionId)); - } catch (Exception e) { - return ResponseMsgUtil.exception(e); - } - } - - - @RequestMapping(value="/getDictionaries",method= RequestMethod.GET) - @ResponseBody - @ApiOperation(value = "查询数据字典") - public ResponseData getDictionaries(){ - try { - return ResponseMsgUtil.success(commonService.getDictionaries()); - } catch (Exception e) { - return ResponseMsgUtil.exception(e); - } - } - - - - @RequestMapping(value="/getDictionaryByCodeType",method = RequestMethod.GET) - @ResponseBody - @ApiOperation(value = "根据 码值类型 查询数据字典") - public ResponseData getDictionaryByCodeType(@RequestParam(name = "codeType", required = true) String codeType) { - try { - - return ResponseMsgUtil.success(commonService.getDictionarys(codeType)); - - } catch (Exception e) { - log.error("CommonController --> getDictionaryByCodeType() error!", e); - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value="/mappingSysNameOl",method = RequestMethod.GET) - @ResponseBody - @ApiOperation(value = "根据 码值类型 查询数据字典") - public ResponseData mappingSysNameOl(@RequestParam(name = "codeType", required = true) String codeType) { - try { - - return ResponseMsgUtil.success(commonService.mappingSysNameOl(codeType)); - - } catch (Exception e) { - log.error("CommonController --> getDictionaryByCodeType() error!", e); - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value="/getDictionaryByCodeTypeOl",method = RequestMethod.GET) - @ResponseBody - @ApiOperation(value = "根据 码值类型 查询数据字典") - public ResponseData getDictionaryByCodeTypeOl(@RequestParam(name = "codeType", required = true) String codeType) { - try { - - return ResponseMsgUtil.success(secConfigService.findByCodeType(codeType)); - - } catch (Exception e) { - log.error("CommonController --> getDictionaryByCodeType() error!", e); - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value="/updateDictionary",method = RequestMethod.GET) - @ResponseBody - @ApiOperation(value = "根据 码值类型 查询数据字典") - public ResponseData updateDictionary( - @RequestParam(name = "codeType", required = true) String codeType, - @RequestParam(name = "codeValue", required = true) String codeValue - ) { - try { - - SecConfig secConfig = secConfigService.findByCodeType(codeType); - secConfig.setCodeValue(codeValue); - secConfigService.updateSecConfig(secConfig); - - return ResponseMsgUtil.success("修改成功"); - } catch (Exception e) { - log.error("CommonController --> getDictionaryByCodeType() error!", e); - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value="/getDictionaryByCodeTypeAndExt",method = RequestMethod.GET) - @ResponseBody - @ApiOperation(value = "根据 码值类型 查询数据字典") - public ResponseData getDictionaryByCodeTypeAndExt(@RequestParam(name = "codeType", required = true) String codeType, String ext1) { - try { - - return ResponseMsgUtil.success(commonService.getDictionarysAndExt(codeType,ext1)); - - } catch (Exception e) { - log.error("CommonController --> getDictionaryByCodeType() error!", e); - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value="/getIdAndNameByCodeType",method = RequestMethod.GET) - @ResponseBody - @ApiOperation(value = "根据 码值类型 查询数据字典的id和name") - public ResponseData getIdAndNameByCodeType(@RequestParam(name = "codeType", required = true) String codeType) { - try { - - return ResponseMsgUtil.success(commonService.getIdAndName(codeType)); - - } catch (Exception e) { - log.error("CommonController --> getIdAndNameByCodeType() error!", e); - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value="/getDictionaryByCodeTypeAndValue",method = RequestMethod.GET) - @ResponseBody - @ApiOperation(value = "根据码值类型及value查询数据字典") - public ResponseData getDictionaryByCodeType(@RequestParam(name = "codeType", required = true) String codeType, - @RequestParam(name = "codeValue", required = true) String codeValue) { - try { - - return ResponseMsgUtil.success(commonService.mappingSysCode(codeType,codeValue)); - - } catch (Exception e) { - log.error("CommonController --> getDictionaryByCodeTypeAndValue() error!", e); - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value="/findSecConfigByType",method = RequestMethod.GET) + @Resource + private GoodsRegionFreightService goodsRegionFreightService; + + @RequestMapping(value = "/getDredgeProvince", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询已开通的省份") + public ResponseData getDredgeProvince() { + try { + List list = bsCompanyService.getCompany(new HashMap<>()); + List> mapList = new ArrayList<>(); + Map map; + if (list.size() > 0) { + for (BsCompany company : list) { + map = new HashMap<>(); + if (StringUtils.isNotBlank(company.getRegionId())) { + map.put("companyId", company.getId()); + map.put("regionId", company.getRegionId()); + SecRegion secRegion = commonService.getRegionsById(Long.parseLong(company.getRegionId())); + if (secRegion != null) { + map.put("regionName", secRegion.getRegionName()); + } + mapList.add(map); + } + } + } + return ResponseMsgUtil.success(mapList); + } catch (Exception e) { + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/getRegionsByParentId", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "分级查询区域信息") + public ResponseData getRegionsByParentId(@RequestParam(name = "regionId", required = false) Long regionId) { + try { + if (regionId == null) { + return ResponseMsgUtil.success(commonService.getCities()); + } + return ResponseMsgUtil.success(commonService.getRegionsByParentId(regionId)); + } catch (Exception e) { + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/getParentInfosByRegionId", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询父级区域信息") + public ResponseData getParentInfosByRegionId(@RequestParam(name = "regionId", required = true) Long regionId) { + try { + return ResponseMsgUtil.success(commonService.getParentInfoByRegionId(regionId)); + } catch (Exception e) { + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/getRegionsById", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询区域详细信息") + public ResponseData getRegionsById(@RequestParam(name = "regionId", required = true) Long regionId) { + try { + return ResponseMsgUtil.success(commonService.getRegionsById(regionId)); + } catch (Exception e) { + return ResponseMsgUtil.exception(e); + } + } + + + @RequestMapping(value = "/getDictionaries", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询数据字典") + public ResponseData getDictionaries() { + try { + return ResponseMsgUtil.success(commonService.getDictionaries()); + } catch (Exception e) { + return ResponseMsgUtil.exception(e); + } + } + + + @RequestMapping(value = "/getDictionaryByCodeType", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "根据 码值类型 查询数据字典") + public ResponseData getDictionaryByCodeType(@RequestParam(name = "codeType", required = true) String codeType) { + try { + + return ResponseMsgUtil.success(commonService.getDictionarys(codeType)); + + } catch (Exception e) { + log.error("CommonController --> getDictionaryByCodeType() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/mappingSysNameOl", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "根据 码值类型 查询数据字典") + public ResponseData mappingSysNameOl(@RequestParam(name = "codeType", required = true) String codeType) { + try { + + return ResponseMsgUtil.success(commonService.mappingSysNameOl(codeType)); + + } catch (Exception e) { + log.error("CommonController --> getDictionaryByCodeType() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/getDictionaryByCodeTypeOl", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "根据 码值类型 查询数据字典") + public ResponseData getDictionaryByCodeTypeOl(@RequestParam(name = "codeType", required = true) String codeType) { + try { + + return ResponseMsgUtil.success(secConfigService.findByCodeType(codeType)); + + } catch (Exception e) { + log.error("CommonController --> getDictionaryByCodeType() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/updateDictionary", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "根据 码值类型 查询数据字典") + public ResponseData updateDictionary(@RequestParam(name = "codeType", required = true) String codeType, @RequestParam(name = "codeValue", required = true) String codeValue) { + try { + + SecConfig secConfig = secConfigService.findByCodeType(codeType); + secConfig.setCodeValue(codeValue); + secConfigService.updateSecConfig(secConfig); + + return ResponseMsgUtil.success("修改成功"); + } catch (Exception e) { + log.error("CommonController --> getDictionaryByCodeType() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/getDictionaryByCodeTypeAndExt", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "根据 码值类型 查询数据字典") + public ResponseData getDictionaryByCodeTypeAndExt(@RequestParam(name = "codeType", required = true) String codeType, String ext1) { + try { + + return ResponseMsgUtil.success(commonService.getDictionarysAndExt(codeType, ext1)); + + } catch (Exception e) { + log.error("CommonController --> getDictionaryByCodeType() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/getIdAndNameByCodeType", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "根据 码值类型 查询数据字典的id和name") + public ResponseData getIdAndNameByCodeType(@RequestParam(name = "codeType", required = true) String codeType) { + try { + + return ResponseMsgUtil.success(commonService.getIdAndName(codeType)); + + } catch (Exception e) { + log.error("CommonController --> getIdAndNameByCodeType() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/getDictionaryByCodeTypeAndValue", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "根据码值类型及value查询数据字典") + public ResponseData getDictionaryByCodeType(@RequestParam(name = "codeType", required = true) String codeType, @RequestParam(name = "codeValue", required = true) String codeValue) { + try { + + return ResponseMsgUtil.success(commonService.mappingSysCode(codeType, codeValue)); + + } catch (Exception e) { + log.error("CommonController --> getDictionaryByCodeTypeAndValue() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/findSecConfigByType", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据码值类型查询数据") public ResponseData findSecConfigByType(@RequestParam(name = "codeType", required = true) String codeType) { @@ -253,44 +252,41 @@ public class CommonController { @RequestMapping(value = "/findByLatAndLng", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取定位信息") - public ResponseData findByLatAndLng( - @RequestParam(name = "lng", required = true) String lng, - @RequestParam(name = "lat", required = true) String lat - ) { + public ResponseData findByLatAndLng(@RequestParam(name = "lng", required = true) String lng, @RequestParam(name = "lat", required = true) String lat) { try { - JSONObject jsonObjectR = commonService.findByLatAndLng(lng , lat); + JSONObject jsonObjectR = commonService.findByLatAndLng(lng, lat); if (!jsonObjectR.getString("status").equals("0")) { - log.error("findByLatAndLng error!", "定位错误,请重新定位" ); + log.error("findByLatAndLng error!", "定位错误,请重新定位"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "定位错误,请重新定位"); } - JSONObject object = commonService.findByLatAndLng(lng , lat).getJSONObject("result").getJSONObject("addressComponent"); + JSONObject object = commonService.findByLatAndLng(lng, lat).getJSONObject("result").getJSONObject("addressComponent"); - ApiCity apiCity = commonService.findCityByName(object.getString("city")); + ApiCity apiCity = commonService.findCityByName(object.getString("city")); - if (apiCity == null) { - log.error("findByLatAndLng error!", "当前城市暂未开通任何服务" ); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前城市暂未开通任何服务,请选择其他城市"); - } + if (apiCity == null) { + log.error("findByLatAndLng error!", "当前城市暂未开通任何服务"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前城市暂未开通任何服务,请选择其他城市"); + } - BsCompany company = bsCompanyService.selectCompanyByRegion(apiCity.getProvinceCode()); + BsCompany company = bsCompanyService.selectCompanyByRegion(apiCity.getProvinceCode()); - if (company == null) { - log.error("findByLatAndLng error!", "当前城市暂未开通任何服务" ); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前城市暂未开通任何服务,请选择其他城市"); - } + if (company == null) { + log.error("findByLatAndLng error!", "当前城市暂未开通任何服务"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前城市暂未开通任何服务,请选择其他城市"); + } - JSONObject jsonObject = new JSONObject(); + JSONObject jsonObject = new JSONObject(); - jsonObject.put("cityName" , apiCity.getCityName()); - jsonObject.put("provinceName" , apiCity.getProvinceName()); - jsonObject.put("regionId" , company.getRegionId()); - jsonObject.put("companyName" , company.getName()); - jsonObject.put("companyId" , company.getId()); + jsonObject.put("cityName", apiCity.getCityName()); + jsonObject.put("provinceName", apiCity.getProvinceName()); + jsonObject.put("regionId", company.getRegionId()); + jsonObject.put("companyName", company.getName()); + jsonObject.put("companyId", company.getId()); return ResponseMsgUtil.success(jsonObject); @@ -300,43 +296,41 @@ public class CommonController { } } - @RequestMapping(value = "/findCompanyByCityName", method = RequestMethod.GET) - @ResponseBody - @ApiOperation(value = "获取定位信息") - public ResponseData findCompanyByCityName( - @RequestParam(name = "cityName", required = true) String cityName - ) { - try { + @RequestMapping(value = "/findCompanyByCityName", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "获取定位信息") + public ResponseData findCompanyByCityName(@RequestParam(name = "cityName", required = true) String cityName) { + try { - ApiCity apiCity = commonService.findCityByName(cityName); + ApiCity apiCity = commonService.findCityByName(cityName); - if (apiCity == null) { - log.error("findByLatAndLng error!", "当前城市暂未开通任何服务" ); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前城市暂未开通任何服务,请选择其他城市"); - } + if (apiCity == null) { + log.error("findByLatAndLng error!", "当前城市暂未开通任何服务"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前城市暂未开通任何服务,请选择其他城市"); + } - BsCompany company = bsCompanyService.selectCompanyByRegion(apiCity.getProvinceCode()); + BsCompany company = bsCompanyService.selectCompanyByRegion(apiCity.getProvinceCode()); - if (company == null) { - log.error("findByLatAndLng error!", "当前城市暂未开通任何服务" ); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前城市暂未开通任何服务,请选择其他城市"); - } + if (company == null) { + log.error("findByLatAndLng error!", "当前城市暂未开通任何服务"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前城市暂未开通任何服务,请选择其他城市"); + } - JSONObject jsonObject = new JSONObject(); + JSONObject jsonObject = new JSONObject(); - jsonObject.put("cityName" , apiCity.getCityName()); - jsonObject.put("provinceName" , apiCity.getProvinceName()); - jsonObject.put("regionId" , company.getRegionId()); - jsonObject.put("companyName" , company.getName()); - jsonObject.put("companyId" , company.getId()); + jsonObject.put("cityName", apiCity.getCityName()); + jsonObject.put("provinceName", apiCity.getProvinceName()); + jsonObject.put("regionId", company.getRegionId()); + jsonObject.put("companyName", company.getName()); + jsonObject.put("companyId", company.getId()); - return ResponseMsgUtil.success(jsonObject); + return ResponseMsgUtil.success(jsonObject); - } catch (Exception e) { - log.error("HighOrderController --> unionStagingPay() error!", e); - return ResponseMsgUtil.exception(e); - } - } + } catch (Exception e) { + log.error("HighOrderController --> unionStagingPay() error!", e); + return ResponseMsgUtil.exception(e); + } + } @RequestMapping(value = "/getRebateIntegral", method = RequestMethod.POST) @ResponseBody @@ -346,26 +340,23 @@ public class CommonController { System.out.println(object); - if (object.getInteger("type") == null || - object.getLong("companyId") == null || - object.getBigDecimal("price") == null - ) { - log.error("CommonController -> getRebateIntegral() error!","请求参数校验失败"); + if (object.getInteger("type") == null || object.getLong("companyId") == null || object.getBigDecimal("price") == null) { + log.error("CommonController -> getRebateIntegral() error!", "请求参数校验失败"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR); } // 查询订单来源 Map map = new HashMap<>(); - map.put("type" , object.getInteger("type")); - map.put("companyId" , object.getLong("companyId")); + map.put("type", object.getInteger("type")); + map.put("companyId", object.getLong("companyId")); BsIntegralRebate bsIntegralRebate = bsIntegralRebateService.findIntegralRebateByMap(map); if (bsIntegralRebate == null) { - throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "暂无积分返利活动"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂无积分返利活动"); } - BigDecimal integralNum = object.getBigDecimal("price").multiply(bsIntegralRebate.getPercentage()).setScale( 0, BigDecimal.ROUND_HALF_UP ); + BigDecimal integralNum = object.getBigDecimal("price").multiply(bsIntegralRebate.getPercentage()).setScale(0, BigDecimal.ROUND_HALF_UP); return ResponseMsgUtil.success(integralNum); @@ -385,8 +376,8 @@ public class CommonController { if (data == null) { - List jsonObjects = commonService.getRegional(); - redisUtil.set("regional" , jsonObjects); + List jsonObjects = commonService.getRegional("code" , "name" , "childs"); + redisUtil.set("regional", jsonObjects); return ResponseMsgUtil.success(jsonObjects); @@ -395,7 +386,19 @@ public class CommonController { } + } catch (Exception e) { + log.error("HighOrderController --> unionStagingPay() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/getRegionFreight", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "获取区域运费") + public ResponseData getRegionFreight(@RequestParam(name = "regionId", required = true) String regionId) { + try { + return ResponseMsgUtil.success(goodsRegionFreightService.getRegionFreight(regionId)); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); @@ -403,5 +406,4 @@ public class CommonController { } } - } diff --git a/hai-cweb/src/main/java/com/cweb/controller/Goods/DeliveryAddressController.java b/hai-cweb/src/main/java/com/cweb/controller/Goods/DeliveryAddressController.java new file mode 100644 index 00000000..6a2ff021 --- /dev/null +++ b/hai-cweb/src/main/java/com/cweb/controller/Goods/DeliveryAddressController.java @@ -0,0 +1,206 @@ +package com.cweb.controller.Goods; + +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.SessionObject; +import com.hai.common.security.UserCenter; +import com.hai.common.utils.ResponseMsgUtil; +import com.hai.entity.GoodsDeliveryAddress; +import com.hai.entity.GoodsDetail; +import com.hai.entity.GoodsShoppingCart; +import com.hai.entity.GoodsSku; +import com.hai.goods.model.ShoppingCartModel; +import com.hai.goods.service.DeliveryAddressService; +import com.hai.model.HighUserModel; +import com.hai.model.ResponseData; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +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.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.util.*; + +@Controller +@RequestMapping(value = "/deliveryAddress") +@Api(value = "收货地址") +public class DeliveryAddressController { + Logger log = LoggerFactory.getLogger(DeliveryAddressController.class); + @Resource + private DeliveryAddressService deliveryAddressService; + + @Autowired + private UserCenter userCenter; + + @RequestMapping(value = "/getDeliveryAddressList", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询收货地址列表") + public ResponseData getDeliveryAddressList( + HttpServletRequest request + ) { + try { + + // 用户 + SessionObject sessionObject = userCenter.getSessionObject(request); + HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject(); + + Map map = new HashMap<>(); + + map.put("userId", userInfoModel.getHighUser().getId()); + + return ResponseMsgUtil.success(deliveryAddressService.getDeliveryAddressList(map)); + + } catch (Exception e) { + log.error("GoodsDetailController --> getListUser() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + + @RequestMapping(value = "/insertDeliveryAddress", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "新增收货地址") + public ResponseData insertDeliveryAddress(@RequestBody GoodsDeliveryAddress deliveryAddress, HttpServletRequest request) { + try { + + // 用户 + SessionObject sessionObject = userCenter.getSessionObject(request); + HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject(); + + if (deliveryAddress == null || + deliveryAddress.getAddress() == null || + deliveryAddress.getWhetherDefault() == null || + deliveryAddress.getConsignee() == null || + deliveryAddress.getPhone() == null || + deliveryAddress.getRegionName() == null || + deliveryAddress.getRegionId() == null + ) { + log.error("GoodsDetailController -> insertProduct() error!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + deliveryAddress.setUserId(userInfoModel.getHighUser().getId()); + deliveryAddress.setCreateTime(new Date()); + deliveryAddress.setUpdateTime(new Date()); + deliveryAddressService.insertDeliveryAddress(deliveryAddress); + + return ResponseMsgUtil.success("新增成功"); + + } catch (Exception e) { + log.error("GoodsDetailController --> insertPrice() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/updateDeliveryAddress", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "修改收货地址") + public ResponseData updateDeliveryAddress(@RequestBody GoodsDeliveryAddress deliveryAddress, HttpServletRequest request) { + try { + + // 用户 + SessionObject sessionObject = userCenter.getSessionObject(request); + HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject(); + + if (deliveryAddress == null || + deliveryAddress.getId() == null || + deliveryAddress.getAddress() == null || + deliveryAddress.getWhetherDefault() == null || + deliveryAddress.getConsignee() == null || + deliveryAddress.getPhone() == null || + deliveryAddress.getRegionName() == null || + deliveryAddress.getRegionId() == null + ) { + log.error("GoodsDetailController -> insertProduct() error!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + if (deliveryAddress.getWhetherDefault()) { + deliveryAddressService.cleanDeliveryAddressDefault(deliveryAddress.getUserId()); + } + + GoodsDeliveryAddress goodsDeliveryAddress = deliveryAddressService.findDeliveryAddressById(deliveryAddress.getId()); + + if (goodsDeliveryAddress == null) { + log.error("GoodsDetailController -> insertProduct() error!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前收货地址异常!"); + } + + deliveryAddress.setUserId(userInfoModel.getHighUser().getId()); + deliveryAddress.setCreateTime(goodsDeliveryAddress.getCreateTime()); + deliveryAddress.setUpdateTime(new Date()); + deliveryAddressService.updateDeliveryAddress(deliveryAddress); + + return ResponseMsgUtil.success("修改成功"); + + } catch (Exception e) { + log.error("GoodsDetailController --> insertPrice() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/findDeliveryAddressById", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询收货地址详情") + public ResponseData findDeliveryAddressById( + @RequestParam(value = "id", required = true) Long id + ) { + try { + + GoodsDeliveryAddress deliveryAddress = deliveryAddressService.findDeliveryAddressById(id); + + if (deliveryAddress == null) { + log.error("GoodsDetailController -> findGoodsDetailById() error!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到相信息"); + } + + return ResponseMsgUtil.success(deliveryAddress); + + } catch (Exception e) { + log.error("GoodsDetailController --> findGoodsDetailById() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/deleteShoppingCart", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "删除购物车信息") + public ResponseData deleteShoppingCart( + @RequestParam(value = "id", required = true) Long id, HttpServletRequest request + ) { + try { + + // 用户 + SessionObject sessionObject = userCenter.getSessionObject(request); + HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject(); + + GoodsDeliveryAddress deliveryAddress = deliveryAddressService.findDeliveryAddressById(id); + + if (deliveryAddress == null) { + log.error("GoodsDetailController -> findGoodsDetailById() error!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到相关信息"); + } + + if (!Objects.equals(userInfoModel.getHighUser().getId(), deliveryAddress.getUserId())) { + log.error("GoodsDetailController -> findGoodsDetailById() error!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "用户信息错误"); + } + + deliveryAddressService.deleteDeliveryAddress(id); + + return ResponseMsgUtil.success("删除成功"); + + } catch (Exception e) { + log.error("GoodsDetailController --> findGoodsDetailById() 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 8fa03726..56f1f475 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 @@ -1,5 +1,6 @@ package com.cweb.controller.Goods; +import com.alibaba.fastjson.JSONObject; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.hai.common.exception.ErrorCode; @@ -7,11 +8,15 @@ 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.RedisUtil; import com.hai.common.utils.ResponseMsgUtil; +import com.hai.config.CommonConfig; import com.hai.entity.GoodsDetail; +import com.hai.entity.GoodsLogistics; import com.hai.entity.GoodsSku; import com.hai.goods.model.GoodsModel; import com.hai.goods.service.GoodsDetailService; +import com.hai.goods.service.GoodsLogisticsService; import com.hai.goods.service.GoodsSkuService; import com.hai.model.ResponseData; import com.hai.model.UserInfoModel; @@ -39,9 +44,15 @@ public class GoodsController { @Resource private GoodsDetailService goodsDetailService; + @Autowired + private RedisUtil redisUtil; + @Autowired private UserCenter userCenter; + @Resource + private GoodsLogisticsService logisticsService; + @Resource private HighGoodsTypeService highGoodsTypeService; @@ -166,5 +177,38 @@ public class GoodsController { } } + @RequestMapping(value = "/getLogisticsMsg", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "根据快递单号查询物流信息") + 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); + } + + + } catch (Exception e) { + log.error("HighOrderController --> getUserOrderList() error!", e); + return ResponseMsgUtil.exception(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 d29ad975..6791eab1 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 @@ -86,7 +86,7 @@ public class ShoppingCartController { } - return ResponseMsgUtil.success(new PageInfo<>(shoppingCartModels)); + return ResponseMsgUtil.success(shoppingCartModels); } catch (Exception e) { log.error("GoodsDetailController --> getListUser() error!", e); diff --git a/hai-service/src/main/java/com/hai/config/CommonConfig.java b/hai-service/src/main/java/com/hai/config/CommonConfig.java index 74fca6f6..5d598e9d 100644 --- a/hai-service/src/main/java/com/hai/config/CommonConfig.java +++ b/hai-service/src/main/java/com/hai/config/CommonConfig.java @@ -1,5 +1,12 @@ package com.hai.config; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.hai.common.utils.HttpUtils; +import com.hai.common.utils.HttpsUtils; +import org.apache.http.HttpEntity; +import org.apache.http.HttpResponse; +import org.apache.http.util.EntityUtils; import org.springframework.context.annotation.Configuration; import sun.font.FontDesignMetrics; @@ -10,6 +17,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.OutputStream; +import java.util.HashMap; import java.util.Map; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; @@ -164,6 +172,16 @@ public class CommonConfig { } } + public static JSONObject getLogisticsMsg(String num) { + + String appcode = "f9ace4c915054ca697a76fb9a4e1e8c0"; + Map headers = new HashMap<>(); + headers.put("Authorization", "APPCODE " + appcode); + Map querys = new HashMap<>(); + querys.put("number", num); + + return HttpsUtils.doGet("https://express3.market.alicloudapi.com/express3" , querys ,headers); + } } diff --git a/hai-service/src/main/java/com/hai/config/CommonSysConfig.java b/hai-service/src/main/java/com/hai/config/CommonSysConfig.java index 083a869a..4f41f5c9 100644 --- a/hai-service/src/main/java/com/hai/config/CommonSysConfig.java +++ b/hai-service/src/main/java/com/hai/config/CommonSysConfig.java @@ -127,4 +127,7 @@ public class CommonSysConfig { private String wxH5AppId; private String wxH5AppSecret; + private String LogisticsAppKey; + private String logisticsAppSecret; + } diff --git a/hai-service/src/main/java/com/hai/goods/service/DeliveryAddressService.java b/hai-service/src/main/java/com/hai/goods/service/DeliveryAddressService.java new file mode 100644 index 00000000..1fed4477 --- /dev/null +++ b/hai-service/src/main/java/com/hai/goods/service/DeliveryAddressService.java @@ -0,0 +1,77 @@ +package com.hai.goods.service; + +import com.hai.entity.GoodsDeliveryAddress; + +import java.util.List; +import java.util.Map; + +/** + * @serviceName deliveryAddressService.java + * @author Sum1Dream + * @version 1.0.0 + * @Description // 收货地址业务 + * @createTime 17:33 2023/4/13 + **/ +public interface DeliveryAddressService { + + /** + * @Author Sum1Dream + * @Name insertGoodsDeliveryAddress + * @Description // 新增收货地址 + * @Date 15:08 2023/4/11 + * @Param [GoodsDeliveryAddress] + * @Return void + */ + void insertDeliveryAddress(GoodsDeliveryAddress deliveryAddress); + + /** + * @Author Sum1Dream + * @Name updateGoodsDeliveryAddress + * @Description // 更新收货地址 + * @Date 15:14 2023/4/11 + * @Param [GoodsDeliveryAddress] + * @Return void + */ + void updateDeliveryAddress(GoodsDeliveryAddress deliveryAddress); + + /** + * @Author Sum1Dream + * @Name getGoodsDeliveryAddressList + * @Description // 查询收货地址 + * @Date 15:17 2023/4/11 + * @Param [map] + * @Return java.util.List + */ + List getDeliveryAddressList(Map map); + + + /** + * @Author Sum1Dream + * @Name findGoodsDeliveryAddressById + * @Description // 根据id查询详情 + * @Date 16:19 2023/4/11 + * @Param [id] + * @Return com.hai.entity.GoodsDeliveryAddress + */ + GoodsDeliveryAddress findDeliveryAddressById(Long id); + + /** + * @Author Sum1Dream + * @Name deleteDeliveryAddress + * @Description // 删除收货地址 + * @Date 17:37 2023/4/13 + * @Param [id] + * @Return void + */ + void deleteDeliveryAddress(Long id); + + /** + * @Author Sum1Dream + * @Name cleanDeliveryAddressDefault + * @Description // 清空所有的默认收货地址 + * @Date 10:33 2023/4/17 + * @Param [userId] + * @Return void + */ + void cleanDeliveryAddressDefault(Long userId); +} diff --git a/hai-service/src/main/java/com/hai/goods/service/GoodsDetailService.java b/hai-service/src/main/java/com/hai/goods/service/GoodsDetailService.java index 99d00d3f..5f774f33 100644 --- a/hai-service/src/main/java/com/hai/goods/service/GoodsDetailService.java +++ b/hai-service/src/main/java/com/hai/goods/service/GoodsDetailService.java @@ -2,6 +2,7 @@ package com.hai.goods.service; import com.hai.entity.ApiMchProduct; import com.hai.entity.GoodsDetail; +import com.hai.entity.GoodsLogistics; import java.util.List; import java.util.Map; @@ -55,4 +56,5 @@ public interface GoodsDetailService { * @Return com.hai.entity.GoodsDetail */ GoodsDetail findGoodsDetailById(Long id); + } diff --git a/hai-service/src/main/java/com/hai/goods/service/GoodsLogisticsService.java b/hai-service/src/main/java/com/hai/goods/service/GoodsLogisticsService.java new file mode 100644 index 00000000..33b88b0f --- /dev/null +++ b/hai-service/src/main/java/com/hai/goods/service/GoodsLogisticsService.java @@ -0,0 +1,77 @@ +package com.hai.goods.service; + +import com.alibaba.fastjson.JSONObject; +import com.hai.entity.GoodsLogistics; + +import java.util.List; +import java.util.Map; + +/** + * @serviceName GoodsLogisticsService.java + * @author Sum1Dream + * @version 1.0.0 + * @Description // 物流信息业务 + * @createTime 18:39 2023/4/13 + **/ +public interface GoodsLogisticsService { + /** + * @Author Sum1Dream + * @Name insertGoodsLogistics + * @Description // 新增物流信息 + * @Date 15:08 2023/4/11 + * @Param [GoodsLogistics] + * @Return void + */ + void insertGoodsLogistics(GoodsLogistics goodsLogistics); + + /** + * @Author Sum1Dream + * @Name updateGoodsLogistics + * @Description // 更新物流信息 + * @Date 15:14 2023/4/11 + * @Param [GoodsLogistics] + * @Return void + */ + void updateGoodsLogistics(GoodsLogistics goodsLogistics); + + /** + * @Author Sum1Dream + * @Name getGoodsLogisticsList + * @Description // 查询物流信息列表 + * @Date 15:17 2023/4/11 + * @Param [map] + * @Return java.util.List + */ + List getGoodsLogisticsList(Map map); + + + /** + * @Author Sum1Dream + * @Name findGoodsLogisticsById + * @Description // 根据id查询物流信息 + * @Date 16:19 2023/4/11 + * @Param [id] + * @Return com.hai.entity.GoodsLogistics + */ + GoodsLogistics findGoodsLogisticsById(Long id); + + /** + * @Author Sum1Dream + * @Name findGoodsLogisticsByNum + * @Description // 根据快递单号查询物流信息 + * @Date 11:41 2023/4/14 + * @Param [num] + * @Return com.hai.entity.GoodsLogistics + */ + GoodsLogistics findGoodsLogisticsByNum(String num); + + /** + * @Author Sum1Dream + * @Name editLogistics + * @Description // 编辑物流信息 + * @Date 11:33 2023/4/14 + * @Param [goodsLogistics] + * @Return void + */ + GoodsLogistics editLogistics(JSONObject object); +} diff --git a/hai-service/src/main/java/com/hai/goods/service/GoodsRegionFreightService.java b/hai-service/src/main/java/com/hai/goods/service/GoodsRegionFreightService.java new file mode 100644 index 00000000..00b73df9 --- /dev/null +++ b/hai-service/src/main/java/com/hai/goods/service/GoodsRegionFreightService.java @@ -0,0 +1,89 @@ +package com.hai.goods.service; + +import com.alibaba.fastjson.JSONObject; +import com.hai.entity.GoodsRegionFreight; + +import java.math.BigDecimal; +import java.util.List; +import java.util.Map; + +/** + * @serviceName GoodsRegionFreightService.java + * @author Sum1Dream + * @version 1.0.0 + * @Description // 区域运费业务 + * @createTime 15:11 2023/4/14 + **/ +public interface GoodsRegionFreightService { + + /** + * @Author Sum1Dream + * @Name insertRegionFreight + * @Description // 新增 + * @Date 15:08 2023/4/11 + * @Param [RegionFreight] + * @Return void + */ + void insertRegionFreight(GoodsRegionFreight regionFreight); + + /** + * @Author Sum1Dream + * @Name updateRegionFreight + * @Description // 更新 + * @Date 15:14 2023/4/11 + * @Param [RegionFreight] + * @Return void + */ + void updateRegionFreight(GoodsRegionFreight regionFreight); + + /** + * @Author Sum1Dream + * @Name getRegionFreightList + * @Description // 查询列表 + * @Date 15:17 2023/4/11 + * @Param [map] + * @Return java.util.List + */ + List getRegionFreightList(Map map); + + /** + * @Author Sum1Dream + * @Name findGoodsDetailById + * @Description // 查询详情 + * @Date 16:19 2023/4/11 + * @Param [id] + * @Return com.hai.entity.GoodsDetail + */ + GoodsRegionFreight findRegionFreightById(Long id); + + /** + * @Author Sum1Dream + * @Name findRegionFreightByRegionId + * @Description // 获取区域运费根据区域编码 + * @Date 19:08 2023/4/14 + * @Param [regionId] + * @Return com.hai.entity.GoodsRegionFreight + */ + GoodsRegionFreight findRegionFreightByRegionId(String regionId); + + /** + * @Author Sum1Dream + * @Name DeleteRegionFreight + * @Description // 删除 + * @Date 15:09 2023/4/13 + * @Param [id] + * @Return void + */ + void deleteRegionFreight(Long id); + + /** + * @Author Sum1Dream + * @Name getRegionFreight + * @Description // 获取运费 + * @Date 19:03 2023/4/14 + * @Param [regionId] + * @Return java.math.BigDecimal + */ + JSONObject getRegionFreight(String regionId) throws Exception; + +} diff --git a/hai-service/src/main/java/com/hai/goods/service/impl/DeliveryAddressServiceImpl.java b/hai-service/src/main/java/com/hai/goods/service/impl/DeliveryAddressServiceImpl.java new file mode 100644 index 00000000..20cc9161 --- /dev/null +++ b/hai-service/src/main/java/com/hai/goods/service/impl/DeliveryAddressServiceImpl.java @@ -0,0 +1,69 @@ +package com.hai.goods.service.impl; + +import com.hai.dao.GoodsDeliveryAddressMapper; +import com.hai.entity.GoodsDeliveryAddress; +import com.hai.entity.GoodsDeliveryAddressExample; +import com.hai.goods.service.DeliveryAddressService; +import org.apache.commons.collections4.MapUtils; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service("deliveryAddressService") +public class DeliveryAddressServiceImpl implements DeliveryAddressService { + + @Resource + private GoodsDeliveryAddressMapper deliveryAddressMapper; + + @Override + public void insertDeliveryAddress(GoodsDeliveryAddress deliveryAddress) { + deliveryAddressMapper.insert(deliveryAddress); + } + + @Override + public void updateDeliveryAddress(GoodsDeliveryAddress deliveryAddress) { + deliveryAddressMapper.updateByPrimaryKey(deliveryAddress); + } + + @Override + public List getDeliveryAddressList(Map map) { + + GoodsDeliveryAddressExample example = new GoodsDeliveryAddressExample(); + GoodsDeliveryAddressExample.Criteria criteria = example.createCriteria(); + + if (MapUtils.getLong(map, "userId") != null) { + criteria.andUserIdEqualTo(MapUtils.getLong(map, "userId")); + } + + return deliveryAddressMapper.selectByExample(example); + } + + @Override + public GoodsDeliveryAddress findDeliveryAddressById(Long id) { + return deliveryAddressMapper.selectByPrimaryKey(id); + } + + @Override + public void deleteDeliveryAddress(Long id) { + deliveryAddressMapper.deleteByPrimaryKey(id); + } + + @Override + public void cleanDeliveryAddressDefault(Long userId) { + + Map map = new HashMap<>(); + map.put("userId" , userId); + List list = getDeliveryAddressList(map); + + if (list.size()>1) { + for (GoodsDeliveryAddress deliveryAddress : list) { + deliveryAddress.setWhetherDefault(false); + updateDeliveryAddress(deliveryAddress); + } + } + + } +} 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 1e8b7bef..0a36ed4f 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 @@ -1,9 +1,11 @@ package com.hai.goods.service.impl; import com.hai.dao.GoodsDetailMapper; +import com.hai.dao.GoodsLogisticsMapper; import com.hai.entity.ApiMerchantsExample; import com.hai.entity.GoodsDetail; import com.hai.entity.GoodsDetailExample; +import com.hai.entity.GoodsLogistics; import com.hai.goods.service.GoodsDetailService; import org.apache.commons.collections4.MapUtils; import org.springframework.stereotype.Service; @@ -19,6 +21,9 @@ public class GoodsDetailServiceImpl implements GoodsDetailService { @Resource private GoodsDetailMapper goodsDetailMapper; + @Resource + private GoodsLogisticsMapper logisticsMapper; + @Override public void insertGoodsDetail(GoodsDetail goodsDetail) { goodsDetailMapper.insert(goodsDetail); @@ -53,4 +58,5 @@ public class GoodsDetailServiceImpl implements GoodsDetailService { public GoodsDetail findGoodsDetailById(Long id) { return goodsDetailMapper.selectByPrimaryKey(id); } + } 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 new file mode 100644 index 00000000..7a279763 --- /dev/null +++ b/hai-service/src/main/java/com/hai/goods/service/impl/GoodsLogisticsServiceImpl.java @@ -0,0 +1,88 @@ +package com.hai.goods.service.impl; + +import com.alibaba.fastjson.JSONObject; +import com.hai.dao.GoodsLogisticsMapper; +import com.hai.entity.GoodsLogistics; +import com.hai.entity.GoodsLogisticsExample; +import com.hai.goods.service.GoodsLogisticsService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.Date; +import java.util.List; +import java.util.Map; + +@Service("goodsLogisticsService") +public class GoodsLogisticsServiceImpl implements GoodsLogisticsService { + + @Resource + private GoodsLogisticsMapper goodsLogisticsMapper; + + @Override + public void insertGoodsLogistics(GoodsLogistics goodsLogistics) { + goodsLogisticsMapper.insert(goodsLogistics); + } + + @Override + public void updateGoodsLogistics(GoodsLogistics goodsLogistics) { + goodsLogisticsMapper.updateByPrimaryKey(goodsLogistics); + } + + @Override + public List getGoodsLogisticsList(Map map) { + return null; + } + + @Override + public GoodsLogistics findGoodsLogisticsById(Long id) { + return goodsLogisticsMapper.selectByPrimaryKey(id); + } + + @Override + public GoodsLogistics findGoodsLogisticsByNum(String num) { + GoodsLogisticsExample example = new GoodsLogisticsExample(); + GoodsLogisticsExample.Criteria criteria = example.createCriteria(); + + criteria.andNumberEqualTo(num).andStatusEqualTo(1); + + List logistics = goodsLogisticsMapper.selectByExample(example); + + if (logistics.size() > 0) { + return logistics.get(0); + } + + return null; + } + + @Override + public GoodsLogistics editLogistics(JSONObject jsonObject) { + + JSONObject info = (JSONObject) jsonObject.getJSONArray("info").get(0); + + GoodsLogistics logistics = findGoodsLogisticsByNum(info.getString("mailNo")); + + if (logistics == null) { + logistics = new GoodsLogistics(); + } + + logistics.setTaskNo(jsonObject.getString("orderNo")); + logistics.setTheLastTime(info.getDate("theLastTime")); + logistics.setTheLastMessage(info.getString("theLastMessage")); + logistics.setTakeTime(info.getString("takeTime")); + logistics.setNumber(info.getString("mailNo")); + logistics.setLogisticsStatus(info.getString("logisticsStatus")); + logistics.setExpressCompanyName(info.getString("logisticsCompanyName")); + logistics.setLogisticsStatusDesc(info.getString("logisticsStatusDesc")); + logistics.setLogisticsTraceDetails(info.getString("logisticsTraceDetailList")); + logistics.setStatus(1); + + if ( logistics.getId() == null) { + logistics.setCreateTime(new Date()); + insertGoodsLogistics(logistics); + } else { + updateGoodsLogistics(logistics); + } + + return logistics; + } +} diff --git a/hai-service/src/main/java/com/hai/goods/service/impl/GoodsRegionFreightServiceImpl.java b/hai-service/src/main/java/com/hai/goods/service/impl/GoodsRegionFreightServiceImpl.java new file mode 100644 index 00000000..2760b771 --- /dev/null +++ b/hai-service/src/main/java/com/hai/goods/service/impl/GoodsRegionFreightServiceImpl.java @@ -0,0 +1,186 @@ +package com.hai.goods.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.dao.GoodsRegionFreightMapper; +import com.hai.entity.GoodsRegionFreight; +import com.hai.entity.GoodsRegionFreightExample; +import com.hai.entity.SecRegion; +import com.hai.goods.service.GoodsRegionFreightService; +import com.hai.service.CommonService; +import com.hai.service.SecConfigService; +import org.apache.commons.collections4.MapUtils; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.List; +import java.util.Map; + +@Service("goodsRegionFreightService") +public class GoodsRegionFreightServiceImpl implements GoodsRegionFreightService { + + @Resource + private GoodsRegionFreightMapper regionFreightMapper; + + @Resource + private SecConfigService secConfigService; + + @Resource + private CommonService commonService; + + @Override + public void insertRegionFreight(GoodsRegionFreight regionFreight) { + regionFreightMapper.insert(regionFreight); + } + + @Override + public void updateRegionFreight(GoodsRegionFreight regionFreight) { + regionFreightMapper.updateByPrimaryKey(regionFreight); + } + + @Override + public List getRegionFreightList(Map map) { + + GoodsRegionFreightExample example = new GoodsRegionFreightExample(); + GoodsRegionFreightExample.Criteria criteria = example.createCriteria(); + + if (MapUtils.getString(map, "regionName") != null) { + criteria.andRegionNameLike("%" + MapUtils.getString(map, "regionName") + "%"); + } + if (MapUtils.getString(map, "regionId") != null) { + criteria.andRegionIdEqualTo(MapUtils.getString(map, "regionId")); + } + criteria.andStatusEqualTo(1); + + return regionFreightMapper.selectByExample(example); + } + + @Override + public GoodsRegionFreight findRegionFreightById(Long id) { + return regionFreightMapper.selectByPrimaryKey(id); + } + + @Override + public GoodsRegionFreight findRegionFreightByRegionId(String regionId) { + + GoodsRegionFreightExample example = new GoodsRegionFreightExample(); + example.createCriteria().andRegionIdEqualTo(regionId).andStatusEqualTo(1); + + List list = regionFreightMapper.selectByExample(example); + + if (list.size() > 0 ) { + return list.get(0); + } + + return null; + } + + @Override + public void deleteRegionFreight(Long id) { + regionFreightMapper.deleteByPrimaryKey(id); + } + + @Override + public JSONObject getRegionFreight(String regionId) { + + // 获取默认包邮价格 , 运费 + BigDecimal freePostPrice = new BigDecimal(secConfigService.findByCodeType("FREE_POST_PRICE").getCodeValue()); + BigDecimal freightPrice = new BigDecimal(secConfigService.findByCodeType("FREIGHT_PRICE").getCodeValue()); + + JSONObject jsonObject = new JSONObject(); + + // 查询当前登记 + GoodsRegionFreight goodsRegionFreight = findRegionFreightByRegionId(regionId); + + SecRegion region = commonService.getRegionsById(Long.parseLong(regionId)); + + if (region == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无效区域编码!"); + } + + if (goodsRegionFreight != null) { + jsonObject.put("freePostPrice" , goodsRegionFreight.getFreePostPrice()); + jsonObject.put("freightPrice" , goodsRegionFreight.getFreightPrice()); + return jsonObject; + } + + if (region.getParentId() == null) { + jsonObject.put("freePostPrice" , freePostPrice); + jsonObject.put("freightPrice" , freightPrice); + return jsonObject; + } + + getRegionFreight(region.getParentId().toString()); + + return jsonObject; + } + +// @Override +// public JSONObject getRegionFreight(String regionId) throws Exception { +// +// // 获取默认包邮价格 , 运费 +// BigDecimal freePostPrice = new BigDecimal(secConfigService.findByCodeType("FREE_POST_PRICE").getCodeValue()); +// BigDecimal freightPrice = new BigDecimal(secConfigService.findByCodeType("FREIGHT_PRICE").getCodeValue()); +// +// JSONObject jsonObject = new JSONObject(); +// +// // 查询当前登记 +// GoodsRegionFreight goodsRegionFreight = findRegionFreightByRegionId(regionId); +// +// SecRegion region = commonService.getRegionsById(Long.parseLong(regionId)); +// +// if (region == null) { +// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无效区域编码!"); +// } +// +// if (goodsRegionFreight != null) { +// jsonObject.put("freePostPrice" , goodsRegionFreight.getFreePostPrice()); +// jsonObject.put("freightPrice" , goodsRegionFreight.getFreightPrice()); +// return jsonObject; +// } +// +// if (region.getParentId() == null) { +// jsonObject.put("freePostPrice" , freePostPrice); +// jsonObject.put("freightPrice" , freightPrice); +// return jsonObject; +// } +// +// GoodsRegionFreight goodsRegionFreight1 = findRegionFreightByRegionId(region.getParentId().toString()); +// SecRegion region1 = commonService.getRegionsById(region.getParentId()); +// +// if (goodsRegionFreight1 != null) { +// jsonObject.put("freePostPrice" , goodsRegionFreight1.getFreePostPrice()); +// jsonObject.put("freightPrice" , goodsRegionFreight1.getFreightPrice()); +// return jsonObject; +// } +// +// if (region1.getParentId() == null) { +// jsonObject.put("freePostPrice" , freePostPrice); +// jsonObject.put("freightPrice" , freightPrice); +// return jsonObject; +// } +// +// GoodsRegionFreight goodsRegionFreight2 = findRegionFreightByRegionId(region1.getParentId().toString()); +// SecRegion region2 = commonService.getRegionsById(region1.getParentId()); +// +// if (goodsRegionFreight2 != null) { +// jsonObject.put("freePostPrice" , goodsRegionFreight2.getFreePostPrice()); +// jsonObject.put("freightPrice" , goodsRegionFreight2.getFreightPrice()); +// return jsonObject; +// } +// +// if (region2.getParentId() == null) { +// jsonObject.put("freePostPrice" , freePostPrice); +// jsonObject.put("freightPrice" , freightPrice); +// return jsonObject; +// } +// +// jsonObject.put("freePostPrice" , freePostPrice); +// jsonObject.put("freightPrice" , freightPrice); +// +// return jsonObject; +// } +} 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 07e6f297..f16e6a0f 100644 --- a/hai-service/src/main/java/com/hai/service/CommonService.java +++ b/hai-service/src/main/java/com/hai/service/CommonService.java @@ -317,7 +317,7 @@ public interface CommonService { * @Param [] * @Return com.alibaba.fastjson.JSONObject */ - List getRegional(); + List getRegional(String code , String name ,String child); /** * @Author Sum1Dream 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 e79380c2..643609cd 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 @@ -731,7 +731,7 @@ public class CommonServiceImpl implements CommonService { } @Override - public List getRegional() { + public List getRegional(String code , String name , String child) { // 获取父类 List regionListParent = getSecRegion(null); @@ -740,8 +740,8 @@ public class CommonServiceImpl implements CommonService { for (SecRegion secRegion : regionListParent) { JSONObject provinceObject = new JSONObject(); - provinceObject.put("code" , secRegion.getRegionId()); - provinceObject.put("name" , secRegion.getRegionName()); + provinceObject.put(code , secRegion.getRegionId()); + provinceObject.put(name , secRegion.getRegionName()); List regionList = getSecRegion(secRegion.getRegionId()); @@ -749,8 +749,8 @@ public class CommonServiceImpl implements CommonService { List jsonCity = new ArrayList<>(); for (SecRegion city : regionList) { JSONObject objectCity = new JSONObject(); - objectCity.put("code" , city.getRegionId()); - objectCity.put("name" , city.getRegionName()); + objectCity.put(code , city.getRegionId()); + objectCity.put(name , city.getRegionName()); List areaList = getSecRegion(city.getRegionId()); @@ -758,15 +758,16 @@ public class CommonServiceImpl implements CommonService { List jsonArea = new ArrayList<>(); for (SecRegion area : areaList) { JSONObject objectArea = new JSONObject(); - objectArea.put("code" , area.getRegionId()); - objectArea.put("name" , area.getRegionName()); + objectArea.put(code , area.getRegionId()); + objectArea.put(name , area.getRegionName()); + objectArea.put("isLeaf" , true); jsonArea.add(objectArea); } - provinceObject.put("childs" , jsonArea); + objectCity.put(child , jsonArea); } jsonCity.add(objectCity); } - provinceObject.put("childs" , jsonCity); + provinceObject.put(child , jsonCity); } jsonProvince.add(provinceObject); diff --git a/hai-service/src/main/resources/dev/commonConfig.properties b/hai-service/src/main/resources/dev/commonConfig.properties index 71cd949b..56716f61 100644 --- a/hai-service/src/main/resources/dev/commonConfig.properties +++ b/hai-service/src/main/resources/dev/commonConfig.properties @@ -119,3 +119,7 @@ wxAppSecret=d8d6dcaef77d3b659258a01b5ddba5df wxH5AppId=wxa075e8509802f826 wxH5AppSecret=0e606fc1378d35e359fcf3f15570b2c5 + + +logisticsAppKey=5d806a99fbcc48e19717beef11fa1700 +logisticsAppSecret=5ba7552b194e4147b7db1c34143e3317