From 8e20bb270d832ec67d8cfa97d0426647be113af0 Mon Sep 17 00:00:00 2001 From: yuanye <418471657@qq.com> Date: Thu, 2 Jan 2025 10:01:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B1=87=E8=81=94=E9=80=9Adi?= =?UTF-8?q?stributorId=20=20=E5=8E=9F=E5=8F=82=E6=95=B0aNId4A3X=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=B8=BAorjuOND7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/bweb/controller/TestController.java | 88 ++++++++++++++++++- .../discount/DiscountPackageController.java | 42 ++++++++- .../goods/GoodPresentController.java | 20 +++-- .../controller/goods/GoodsController.java | 28 ++---- .../controller/cms/CmsContentController.java | 41 +++------ .../goods/DeliveryAddressController.java | 54 ++++++------ .../controller/goods/GoodsController.java | 87 +++++------------- .../com/order/controller/OrderController.java | 78 ++++++++++++++-- .../controller/notify/MeiTuanController.java | 2 +- .../com/hfkj/schedule/JdGoodsSchedule.java | 22 ++--- .../java/com/hfkj/dao/GoodsMsgMapperExt.java | 61 +++++++++---- .../com/hfkj/dao/GoodsSpecsMapperExt.java | 11 ++- .../java/com/hfkj/haioil/HaiOilService.java | 39 ++++++++ .../java/com/hfkj/jd/Impl/JdServiceImpl.java | 1 + .../main/java/com/hfkj/jd/JdPostService.java | 24 ++++- .../java/com/hfkj/model/CmsContentModel.java | 3 +- .../com/hfkj/model/goods/JdGoodsModel.java | 12 +++ .../com/hfkj/model/order/OrderChildModel.java | 2 + .../CouponDiscountPackageService.java | 2 + .../service/goods/GoodPresentService.java | 9 ++ .../hfkj/service/goods/GoodsMsgService.java | 2 +- .../hfkj/service/goods/GoodsSpecsService.java | 2 +- .../goods/impl/GoodPresentServiceImpl.java | 32 ++++++- .../goods/impl/GoodsMsgServiceImpl.java | 2 +- .../goods/impl/GoodsSpecsServiceImpl.java | 4 +- .../goods/impl/GoodsTypeServiceImpl.java | 7 +- .../service/order/OrderCreateService.java | 1 + .../service/order/OrderPaySuccessService.java | 7 +- .../order/impl/BsOrderServiceImpl.java | 51 ++++++++++- 29 files changed, 521 insertions(+), 213 deletions(-) diff --git a/bweb/src/main/java/com/bweb/controller/TestController.java b/bweb/src/main/java/com/bweb/controller/TestController.java index 0dcd3e0..cdccc1a 100644 --- a/bweb/src/main/java/com/bweb/controller/TestController.java +++ b/bweb/src/main/java/com/bweb/controller/TestController.java @@ -1,4 +1,5 @@ package com.bweb.controller; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.hfkj.common.exception.ErrorCode; import com.hfkj.common.exception.ErrorHelp; @@ -17,6 +18,7 @@ import com.hfkj.service.card.BsUserCardService; import com.hfkj.service.coupon.channel.YouTuCouponService; import com.hfkj.service.goods.BsOrderGoodsService; import com.hfkj.service.goods.BsOrderStarbucksService; +import com.hfkj.service.goods.GoodsSpecsService; import com.hfkj.service.goods.GoodsUserAddressService; import com.hfkj.service.goods.impl.BsOrderStarbucksServiceImpl; import com.hfkj.service.hlt.HuiLianTongUnionCardService; @@ -56,7 +58,8 @@ public class TestController { @Resource private BsOrderGoodsService orderGoodsService; - + @Resource + private GoodsSpecsService goodsSpecsService; @Resource private JdService jdService; @@ -81,6 +84,8 @@ public class TestController { @Resource private BsOrderStarbucksServiceImpl bsOrderStarbucksService; + @Resource + private GoodsUserAddressService deliveryAddressService; @RequestMapping(value="/thirdPayResult",method = RequestMethod.GET) @@ -238,6 +243,29 @@ public class TestController { } } + + + @RequestMapping(value="/querySkuFreight",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "querySkuFreight") + public ResponseData querySkuFreight() { + try { + + List skuInfoList = new ArrayList<>(); + + com.jd.open.api.sdk.domain.vopdd.QueryOrderOpenProvider.request.querySkuFreight.SkuInfoOrderOpenReq skuInfo = new com.jd.open.api.sdk.domain.vopdd.QueryOrderOpenProvider.request.querySkuFreight.SkuInfoOrderOpenReq(); + + skuInfo.setSkuId(627345); + skuInfo.setSkuNum(1); + skuInfoList.add(skuInfo); + return ResponseMsgUtil.success( JdPostService.querySkuFreight(jdService.getToken() , skuInfoList , 24L ,2144L , 21037L , 58300L)); + + } catch (Exception e) { + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } + @RequestMapping(value="/skuList",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "skuList") @@ -562,4 +590,62 @@ public class TestController { return ResponseMsgUtil.exception(e); } } + + @RequestMapping(value="/querySkuFreight",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "查询运费") + public ResponseData querySkuFreight(@RequestBody JSONObject body) { + try { + + if (body == null || + body.getJSONArray("skuInfoList") == null + || body.getLong("addressId") == null + ) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + JSONArray array = body.getJSONArray("skuInfoList"); + GoodsUserAddress userAddress = goodsUserAddressService.queryDetail(body.getLong("addressId")); + if (userAddress.getProvinceId() == null) { + VopAddressConvertFourAreaByDetailStrResponse response = JdPostService.convertFourAreaByDetailStr(jdService.getToken() , userAddress.getRegionName() + userAddress.getAddress()); + + if (response != null && response.getOpenRpcResult().getSuccess()) { + userAddress.setProvinceId(response.getOpenRpcResult().getResult().getProvinceId()); + userAddress.setProvinceName(response.getOpenRpcResult().getResult().getProvinceName()); + userAddress.setCityId(response.getOpenRpcResult().getResult().getCityId()); + userAddress.setCityName(response.getOpenRpcResult().getResult().getCityName()); + userAddress.setCountyId(response.getOpenRpcResult().getResult().getCountyId()); + userAddress.setCountyName(response.getOpenRpcResult().getResult().getCountyName()); + userAddress.setTownId(response.getOpenRpcResult().getResult().getTownId()); + userAddress.setTownName(response.getOpenRpcResult().getResult().getTownName()); + userAddress.setUpdateTime(new Date()); + deliveryAddressService.update(userAddress); + } + } + List skuInfoList = new ArrayList<>(); + com.jd.open.api.sdk.domain.vopdd.QueryOrderOpenProvider.request.querySkuFreight.SkuInfoOrderOpenReq skuInfo = new com.jd.open.api.sdk.domain.vopdd.QueryOrderOpenProvider.request.querySkuFreight.SkuInfoOrderOpenReq(); + + for(Object object : array) { + JSONObject json = (JSONObject)object; + GoodsSpecs specs = goodsSpecsService.queryDetail(json.getLong("specsId")); + if (specs.getThirdId() != null) { + skuInfo.setSkuId(Long.parseLong(specs.getThirdId())); + skuInfo.setSkuNum(json.getInteger("num")); + skuInfoList.add(skuInfo); + } + } + + if (skuInfoList.isEmpty()) { + JSONObject object = new JSONObject(); + object.put("totalFreight" , 0); + return ResponseMsgUtil.success(object); + } + + return ResponseMsgUtil.success(JdPostService.querySkuFreight(jdService.getToken() , skuInfoList , userAddress.getProvinceId() ,userAddress.getCityId() , userAddress.getCountyId() , userAddress.getTownId()).getOpenRpcResult().getResult()); + + } catch (Exception e) { + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } } diff --git a/bweb/src/main/java/com/bweb/controller/discount/DiscountPackageController.java b/bweb/src/main/java/com/bweb/controller/discount/DiscountPackageController.java index 4b32034..6f7f710 100644 --- a/bweb/src/main/java/com/bweb/controller/discount/DiscountPackageController.java +++ b/bweb/src/main/java/com/bweb/controller/discount/DiscountPackageController.java @@ -1,5 +1,6 @@ package com.bweb.controller.discount; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; @@ -11,6 +12,7 @@ import com.hfkj.common.security.UserCenter; import com.hfkj.common.utils.OrderUtil; import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.entity.*; +import com.hfkj.haioil.HaiOilService; import com.hfkj.model.ResponseData; import com.hfkj.model.SecUserSessionObject; import com.hfkj.service.discount.CouponDiscountPackageService; @@ -25,9 +27,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; +import java.util.*; @Controller @RequestMapping(value="/discountPackage") @@ -73,6 +73,42 @@ public class DiscountPackageController { } + @RequestMapping(value = "/discountPackageList", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "获取优惠券包列表") + public ResponseData discountPackageList( + @RequestParam(name = "type", required = false) Integer type) { + try { + + Map map = new HashMap<>(); + + if (type == 1) { + return ResponseMsgUtil.success(couponDiscountPackageService.getList(map)); + } else { + List list = new ArrayList<>(); + JSONObject object = HaiOilService.queryPkList(map).getJSONObject("return_data"); + JSONArray array = object.getJSONArray("dataList"); + for (Object obj : array) { + + JSONObject jsonObject = (JSONObject)obj; + + CouponDiscountPackage couponDiscountPackage = new CouponDiscountPackage(); + couponDiscountPackage.setKey(jsonObject.getString("discountPkNo")); + couponDiscountPackage.setTitle(jsonObject.getString("discountPkName")); + list.add(couponDiscountPackage); + } + return ResponseMsgUtil.success(list); + } + + + + } catch (Exception e) { + log.error("HighOrderController --> getUserOrderList() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/getDiscountPackageRecordList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取优惠券包记录列表") diff --git a/bweb/src/main/java/com/bweb/controller/goods/GoodPresentController.java b/bweb/src/main/java/com/bweb/controller/goods/GoodPresentController.java index 2f7d31d..c762989 100644 --- a/bweb/src/main/java/com/bweb/controller/goods/GoodPresentController.java +++ b/bweb/src/main/java/com/bweb/controller/goods/GoodPresentController.java @@ -1,5 +1,6 @@ package com.bweb.controller.goods; +import com.alibaba.fastjson.JSONObject; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.hfkj.common.exception.ErrorCode; @@ -12,6 +13,7 @@ import com.hfkj.entity.CouponDiscountPackage; import com.hfkj.entity.GoodPresent; import com.hfkj.entity.GoodsMsg; import com.hfkj.entity.GoodsType; +import com.hfkj.haioil.HaiOilService; import com.hfkj.model.ResponseData; import com.hfkj.model.SecUserSessionObject; import com.hfkj.service.discount.CouponDiscountPackageService; @@ -67,16 +69,24 @@ public class GoodPresentController { || body.getSpecsId() == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } - - CouponDiscountPackage discountPackage = discountPackageService.findDiscountPackageByKey(body.getKey()); - if (discountPackage == null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券包不存在"); + CouponDiscountPackage discountPackage = new CouponDiscountPackage(); + if (body.getType() == 1) { + discountPackage = discountPackageService.findDiscountPackageByKey(body.getKey()); + if (discountPackage == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券包不存在"); + } + body.setName(discountPackage.getTitle()); + } else { + Map map = new HashMap<>(); + map.put("discountPkNo" , body.getKey()); + JSONObject jsonObject = HaiOilService.queryPkDetail(map); + body.setName(jsonObject.getJSONObject("return_data").getString("discountPkName")); } + body.setCreateTime(new Date()); body.setUpdateTime(new Date()); body.setStatus(1); - body.setName(discountPackage.getTitle()); goodPresentService.create(body); return ResponseMsgUtil.success("操作成功"); diff --git a/bweb/src/main/java/com/bweb/controller/goods/GoodsController.java b/bweb/src/main/java/com/bweb/controller/goods/GoodsController.java index 70fa838..a974545 100644 --- a/bweb/src/main/java/com/bweb/controller/goods/GoodsController.java +++ b/bweb/src/main/java/com/bweb/controller/goods/GoodsController.java @@ -349,7 +349,7 @@ public class GoodsController { @RequestMapping(value="/getGoodsSpecsList",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询商品规格列表") - public ResponseData getGoodsSpecsList(@RequestParam(value = "id" , required = false) Long id) { + public ResponseData getGoodsSpecsList(@RequestParam(value = "id" , required = true) Long id) { try { Map map = new HashMap<>(); @@ -359,6 +359,7 @@ public class GoodsController { List goodsModelSpecs = new ArrayList<>(); + for (GoodsSpecs goodsSpec : goodsSpecs) { GoodsModelSpecs goodsModelSpec = new GoodsModelSpecs(); BeanUtils.copyProperties(goodsSpec, goodsModelSpec); @@ -385,30 +386,11 @@ public class GoodsController { @RequestMapping(value="/getGoodsSpecsListAll",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询商品规格列表") - public ResponseData getGoodsSpecsListAll() { + public ResponseData getGoodsSpecsListAll(@RequestParam(value = "name" , required = false) String name) { try { Map map = new HashMap<>(); - map.put("status" , 1); - List goodsMsgList = goodsMsgService.getList(new HashMap<>()); - - List goodsModelSpecs = new ArrayList<>(); - - for (GoodsMsg goodsMsg : goodsMsgList) { - Map mapGoods = new HashMap<>(); - mapGoods.put("goodsId" , goodsMsg.getId()); - - List goodsSpecs = goodsSpecsService.getList(mapGoods); - for (GoodsSpecs goodsSpec : goodsSpecs) { - GoodsModelSpecs goodsModelSpec = new GoodsModelSpecs(); - BeanUtils.copyProperties(goodsSpec, goodsModelSpec); - goodsModelSpec.setGoodsName(goodsMsg.getTitle()); - goodsModelSpec.setSpecsId(goodsSpec.getId()); - goodsModelSpecs.add(goodsModelSpec); - } - - } - - return ResponseMsgUtil.success(goodsModelSpecs); + map.put("name" , name); + return ResponseMsgUtil.success(goodsSpecsService.getGoodsSpecsCrest(map)); } catch (Exception e) { log.error("error!",e); diff --git a/cweb/src/main/java/com/cweb/controller/cms/CmsContentController.java b/cweb/src/main/java/com/cweb/controller/cms/CmsContentController.java index 1fa6cee..291a501 100644 --- a/cweb/src/main/java/com/cweb/controller/cms/CmsContentController.java +++ b/cweb/src/main/java/com/cweb/controller/cms/CmsContentController.java @@ -7,6 +7,7 @@ import com.hfkj.entity.GoodsSpecs; import com.hfkj.model.CmsContentModel; import com.hfkj.model.ResponseData; import com.hfkj.model.goods.GoodsModel; +import com.hfkj.model.goods.JdGoodsModel; import com.hfkj.service.cms.CmsContentService; import com.hfkj.service.goods.GoodsMsgService; import com.hfkj.service.goods.GoodsSpecsService; @@ -64,54 +65,32 @@ public class CmsContentController { List cmsContents = new ArrayList<>(); for (CmsContent cmsContent : list) { - List goodsModels = new ArrayList<>(); + List goodsModels = new ArrayList<>(); if (cmsContent.getShowType() != null) { Map goodsMap = new HashMap<>(); goodsMap.put("status" , 1); goodsMap.put("showType" , 1); - List goodsMsgs = new ArrayList<>(); + List goodsMsgs = new ArrayList<>(); if (cmsContent.getShowType() == 1) { goodsMap.put("goodsType", cmsContent.getShowDataId()); - goodsMsgs = goodsMsgService.getListCrest(goodsMap).stream().limit(2).collect(Collectors.toList()); + goodsMap.put("limit" , 2); + goodsMsgs = goodsMsgService.getListCrest(goodsMap); } if (cmsContent.getShowType() == 2) { goodsMap.put("goodsType", cmsContent.getShowDataId()); - goodsMsgs = goodsMsgService.getListCrest(goodsMap).stream().limit(4).collect(Collectors.toList()); + goodsMap.put("limit" , 4); + goodsMsgs = goodsMsgService.getListCrest(goodsMap); } if (cmsContent.getShowType() == 3) { goodsMap.put("goodsType", cmsContent.getShowDataId()); - goodsMsgs = goodsMsgService.getListCrest(goodsMap).stream().limit(10).collect(Collectors.toList()); + goodsMap.put("limit" , 10); + goodsMsgs = goodsMsgService.getListCrest(goodsMap); } - for (GoodsMsg goodsMsg : goodsMsgs) { - - GoodsModel goodsModel = new GoodsModel(); - - Map specMap = new HashMap<>(); - specMap.put("goodsId", goodsMsg.getId()); - List goodsSpecs = goodsSpecsService.getList(specMap); - - if (!goodsSpecs.isEmpty()) { - BigDecimal minPrice = goodsSpecs.get(0).getSalePrice(); - BigDecimal minOriginalPrice = goodsSpecs.get(0).getOriginalPrice(); - - for (GoodsSpecs specs : goodsSpecs) { - if (specs.getSalePrice().compareTo(minPrice) < 0) { - minPrice = specs.getSalePrice(); - minOriginalPrice = specs.getOriginalPrice(); - } - } - BeanUtils.copyProperties(goodsMsg, goodsModel); - goodsModel.setOriginalPrice(minOriginalPrice); - goodsModel.setPrice(minPrice); - - goodsModels.add(goodsModel); - - } - } + goodsModels.addAll(goodsMsgs); } CmsContentModel cmsContentModel = new CmsContentModel(); diff --git a/cweb/src/main/java/com/cweb/controller/goods/DeliveryAddressController.java b/cweb/src/main/java/com/cweb/controller/goods/DeliveryAddressController.java index a1d9c93..9b5aea4 100644 --- a/cweb/src/main/java/com/cweb/controller/goods/DeliveryAddressController.java +++ b/cweb/src/main/java/com/cweb/controller/goods/DeliveryAddressController.java @@ -93,19 +93,19 @@ public class DeliveryAddressController { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } -// VopAddressConvertFourAreaByDetailStrResponse response = JdPostService.convertFourAreaByDetailStr(jdService.getToken() , deliveryAddress.getRegionName() + deliveryAddress.getAddress()); -// -// -// -// // 判断response是否为空,并且response的OpenRpcResult的success属性是否为true -// if (response != null && response.getOpenRpcResult().getSuccess()) { -// deliveryAddress.setProvinceId(response.getOpenRpcResult().getResult().getProvinceId()); -// deliveryAddress.setCityId(response.getOpenRpcResult().getResult().getCityId()); -// deliveryAddress.setCountyId(response.getOpenRpcResult().getResult().getCountyId()); -// deliveryAddress.setTownId(response.getOpenRpcResult().getResult().getTownId()); -// } else { -// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, response.getOpenRpcResult().getResultMessage()); -// } + VopAddressConvertFourAreaByDetailStrResponse response = JdPostService.convertFourAreaByDetailStr(jdService.getToken() , deliveryAddress.getRegionName() + deliveryAddress.getAddress()); + + + + // 判断response是否为空,并且response的OpenRpcResult的success属性是否为true + if (response != null && response.getOpenRpcResult().getSuccess()) { + deliveryAddress.setProvinceId(response.getOpenRpcResult().getResult().getProvinceId()); + deliveryAddress.setCityId(response.getOpenRpcResult().getResult().getCityId()); + deliveryAddress.setCountyId(response.getOpenRpcResult().getResult().getCountyId()); + deliveryAddress.setTownId(response.getOpenRpcResult().getResult().getTownId()); + } else { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, response.getOpenRpcResult().getResultMessage()); + } deliveryAddress.setUserId(userSession.getUser().getId()); @@ -154,20 +154,20 @@ public class DeliveryAddressController { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前收货地址异常!"); } -// VopAddressConvertFourAreaByDetailStrResponse response = JdPostService.convertFourAreaByDetailStr(jdService.getToken() , deliveryAddress.getRegionName() + deliveryAddress.getAddress()); -// -// if (response != null && response.getOpenRpcResult().getSuccess()) { -// deliveryAddress.setProvinceId(response.getOpenRpcResult().getResult().getProvinceId()); -// deliveryAddress.setProvinceName(response.getOpenRpcResult().getResult().getProvinceName()); -// deliveryAddress.setCityId(response.getOpenRpcResult().getResult().getCityId()); -// deliveryAddress.setCityName(response.getOpenRpcResult().getResult().getCityName()); -// deliveryAddress.setCountyId(response.getOpenRpcResult().getResult().getCountyId()); -// deliveryAddress.setCountyName(response.getOpenRpcResult().getResult().getCountyName()); -// deliveryAddress.setTownId(response.getOpenRpcResult().getResult().getTownId()); -// deliveryAddress.setTownName(response.getOpenRpcResult().getResult().getTownName()); -// } else { -// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, response.getOpenRpcResult().getResultMessage()); -// } + VopAddressConvertFourAreaByDetailStrResponse response = JdPostService.convertFourAreaByDetailStr(jdService.getToken() , deliveryAddress.getRegionName() + deliveryAddress.getAddress()); + + if (response != null && response.getOpenRpcResult().getSuccess()) { + deliveryAddress.setProvinceId(response.getOpenRpcResult().getResult().getProvinceId()); + deliveryAddress.setProvinceName(response.getOpenRpcResult().getResult().getProvinceName()); + deliveryAddress.setCityId(response.getOpenRpcResult().getResult().getCityId()); + deliveryAddress.setCityName(response.getOpenRpcResult().getResult().getCityName()); + deliveryAddress.setCountyId(response.getOpenRpcResult().getResult().getCountyId()); + deliveryAddress.setCountyName(response.getOpenRpcResult().getResult().getCountyName()); + deliveryAddress.setTownId(response.getOpenRpcResult().getResult().getTownId()); + deliveryAddress.setTownName(response.getOpenRpcResult().getResult().getTownName()); + } else { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, response.getOpenRpcResult().getResultMessage()); + } deliveryAddress.setUserId(userSession.getUser().getId()); deliveryAddress.setStatus(1); diff --git a/cweb/src/main/java/com/cweb/controller/goods/GoodsController.java b/cweb/src/main/java/com/cweb/controller/goods/GoodsController.java index c68991a..5b93551 100644 --- a/cweb/src/main/java/com/cweb/controller/goods/GoodsController.java +++ b/cweb/src/main/java/com/cweb/controller/goods/GoodsController.java @@ -17,6 +17,7 @@ import com.hfkj.model.SecUserSessionObject; import com.hfkj.model.goods.GoodsModel; import com.hfkj.model.goods.GoodsModelSpecs; import com.hfkj.model.goods.GoodsTypeModel; +import com.hfkj.model.goods.JdGoodsModel; import com.hfkj.service.discount.CouponDiscountService; import com.hfkj.service.goods.*; import com.hfkj.sysenum.SecUserObjectTypeEnum; @@ -66,11 +67,12 @@ public class GoodsController { @RequestMapping(value="/getListGoodsType",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询商品分类列表") - public ResponseData getListGoodsType() { + public ResponseData getListGoodsType(@RequestParam(value = "type" , required = false) Integer type) { try { Map map = new HashMap<>(); map.put("status" , 1); + map.put("type" , type); List list = goodsTypeService.getList(map); List goodsTypeModels = goodsTypeService.getGoodsTypeModelList(list); @@ -131,82 +133,35 @@ public class GoodsController { map.put("title", title); map.put("goodsType", goodsType); map.put("showType", showType); + map.put("price", price); map.put("goodsTypeParent", goodsTypeParent); map.put("goodsBrand", goodsBrand); map.put("saleNum", saleNum); - map.put("limit", limit); + if (limit == null && title == null && goodsType == null && goodsTypeParent == null && goodsBrand == null) { + map.put("limit", 500); + } else { + map.put("limit", limit); + } + map.put("time", time); map.put("status", 1); - List list = goodsMsgService.getListCrest(map); - List specsList = goodsSpecsService.getGoodsSpecsCrest(); - - List goodsModels = new ArrayList<>(); - - // 查询优惠券可以用规格 - - Map mapSpecs = new HashMap<>(); - mapSpecs.put("discountId", discountId); - - // 查询规格可用优惠券 - List couponDiscountGoodsRel = couponDiscountService.getListGoodsRel(mapSpecs); - - for (GoodsMsg goodsMsg : list) { - - GoodsModel goodsModel = new GoodsModel(); - - List goodsSpecs = specsList.stream().filter(s -> s.getGoodsId().equals(goodsMsg.getId())).collect(Collectors.toList()); - - if (!goodsSpecs.isEmpty()) { - BigDecimal minPrice = goodsSpecs.get(0).getSalePrice(); - BigDecimal minOriginalPrice = goodsSpecs.get(0).getOriginalPrice(); - + if (discountId != null) { + // 查询优惠券可以用规格 - for (GoodsSpecs specs : goodsSpecs) { - if (specs.getSalePrice().compareTo(minPrice) < 0) { - minPrice = specs.getSalePrice(); - minOriginalPrice = specs.getOriginalPrice(); - } + Map mapSpecs = new HashMap<>(); + mapSpecs.put("discountId", discountId); - if (discountId != null) { - CouponDiscountGoodsRel discountGoodsRel = couponDiscountGoodsRel.stream().filter(s -> s.getSpecsId().equals(specs.getId())).findFirst().orElse(null); - if (discountGoodsRel == null) { - specs.setExt1("0"); - } else { - specs.setExt1("1"); - } - - - } - - } - - if (discountId != null) { - // todo 删除没有绑定优惠券的 - goodsSpecs = goodsSpecs.stream().filter(s-> !s.getExt1().equals("0")).collect(Collectors.toList()); - } - - if (goodsSpecs.isEmpty()) { - continue; - } - - BeanUtils.copyProperties(goodsMsg, goodsModel); - goodsModel.setOriginalPrice(minOriginalPrice); - goodsModel.setPrice(minPrice); - goodsModels.add(goodsModel); - } + // 查询规格可用优惠券 + List couponDiscountGoodsRel = couponDiscountService.getListGoodsRel(mapSpecs); + List sp = couponDiscountGoodsRel.stream().map(CouponDiscountGoodsRel::getSpecsId).collect(Collectors.toList()); + map.put("specsId", sp); } - if (price != null) { - if (price == 1) { - goodsModels = goodsModels.stream().sorted(Comparator.comparing(GoodsModel::getPrice)).collect(Collectors.toList()); - } - if (price == 2) { - goodsModels = goodsModels.stream().sorted(Comparator.comparing(GoodsModel::getPrice).reversed()).collect(Collectors.toList()); - } - } + List list = goodsMsgService.getListCrest(map); + - return ResponseMsgUtil.success(PageUtil.initPageInfoObj(pageNum, goodsModels.size(), pageSize, new PageInfo<>(goodsModels))); + return ResponseMsgUtil.success(PageUtil.initPageInfoObj(pageNum, list.size(), pageSize, new PageInfo<>(list))); } catch (Exception e) { log.error("GoodsDetailController --> getListUser() error!", e); diff --git a/order/src/main/java/com/order/controller/OrderController.java b/order/src/main/java/com/order/controller/OrderController.java index 6c8c126..197aeca 100644 --- a/order/src/main/java/com/order/controller/OrderController.java +++ b/order/src/main/java/com/order/controller/OrderController.java @@ -1,5 +1,6 @@ package com.order.controller; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; @@ -11,22 +12,23 @@ import com.hfkj.common.utils.PageUtil; import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.common.utils.SignatureUtil; import com.hfkj.config.CommonSysConst; -import com.hfkj.entity.BsOrder; -import com.hfkj.entity.BsOrderChild; -import com.hfkj.entity.BsOrderGoods; -import com.hfkj.entity.GoodsSpecs; +import com.hfkj.entity.*; import com.hfkj.haioil.HaiOilService; +import com.hfkj.jd.JdPostService; +import com.hfkj.jd.JdService; import com.hfkj.model.ResponseData; import com.hfkj.model.UserSessionObject; import com.hfkj.model.order.OrderChildModel; import com.hfkj.model.order.OrderModel; import com.hfkj.service.goods.BsOrderGoodsService; import com.hfkj.service.goods.GoodsSpecsService; +import com.hfkj.service.goods.GoodsUserAddressService; import com.hfkj.service.order.BsOrderService; import com.hfkj.service.order.impl.BsOrderChildServiceImpl; import com.hfkj.service.pay.HuiPayService; import com.hfkj.sysenum.UserStatusEnum; import com.hfkj.sysenum.order.*; +import com.jd.open.api.sdk.response.vopdz.VopAddressConvertFourAreaByDetailStrResponse; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; @@ -62,7 +64,12 @@ public class OrderController { private GoodsSpecsService goodsSpecsService; @Resource private BsOrderGoodsService orderGoodsService; - + @Resource + private JdService jdService; + @Resource + private GoodsUserAddressService goodsUserAddressService; + @Resource + private GoodsUserAddressService deliveryAddressService; @RequestMapping(value="/create",method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "创建订单") @@ -340,4 +347,65 @@ public class OrderController { } } + @RequestMapping(value="/querySkuFreight",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "查询运费") + public ResponseData querySkuFreight(@RequestBody JSONObject body) { + try { + + if (body == null || + body.getJSONArray("skuInfoList") == null + || body.getLong("addressId") == null + ) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + JSONArray array = body.getJSONArray("skuInfoList"); + GoodsUserAddress userAddress = goodsUserAddressService.queryDetail(body.getLong("addressId")); + + if (userAddress.getProvinceId() == null) { + VopAddressConvertFourAreaByDetailStrResponse response = JdPostService.convertFourAreaByDetailStr(jdService.getToken() , userAddress.getRegionName() + userAddress.getAddress()); + + if (response != null && response.getOpenRpcResult().getSuccess()) { + userAddress.setProvinceId(response.getOpenRpcResult().getResult().getProvinceId()); + userAddress.setProvinceName(response.getOpenRpcResult().getResult().getProvinceName()); + userAddress.setCityId(response.getOpenRpcResult().getResult().getCityId()); + userAddress.setCityName(response.getOpenRpcResult().getResult().getCityName()); + userAddress.setCountyId(response.getOpenRpcResult().getResult().getCountyId()); + userAddress.setCountyName(response.getOpenRpcResult().getResult().getCountyName()); + userAddress.setTownId(response.getOpenRpcResult().getResult().getTownId()); + userAddress.setTownName(response.getOpenRpcResult().getResult().getTownName()); + userAddress.setUpdateTime(new Date()); + deliveryAddressService.update(userAddress); + } else { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, response.getOpenRpcResult().getResultMessage()); + } + } + + List skuInfoList = new ArrayList<>(); + com.jd.open.api.sdk.domain.vopdd.QueryOrderOpenProvider.request.querySkuFreight.SkuInfoOrderOpenReq skuInfo = new com.jd.open.api.sdk.domain.vopdd.QueryOrderOpenProvider.request.querySkuFreight.SkuInfoOrderOpenReq(); + + for(Object object : array) { + JSONObject json = (JSONObject)object; + GoodsSpecs specs = goodsSpecsService.queryDetail(json.getLong("specsId")); + if (specs.getThirdId() != null) { + skuInfo.setSkuId(Long.parseLong(specs.getThirdId())); + skuInfo.setSkuNum(json.getInteger("num")); + skuInfoList.add(skuInfo); + } + } + + if (skuInfoList.isEmpty()) { + JSONObject object = new JSONObject(); + object.put("totalFreight" , 0); + return ResponseMsgUtil.success(object); + } + + return ResponseMsgUtil.success(JdPostService.querySkuFreight(jdService.getToken() , skuInfoList , userAddress.getProvinceId() ,userAddress.getCityId() , userAddress.getCountyId() , userAddress.getTownId()).getOpenRpcResult().getResult()); + + } catch (Exception e) { + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } } diff --git a/order/src/main/java/com/order/controller/notify/MeiTuanController.java b/order/src/main/java/com/order/controller/notify/MeiTuanController.java index 8262b55..5c4a9b1 100644 --- a/order/src/main/java/com/order/controller/notify/MeiTuanController.java +++ b/order/src/main/java/com/order/controller/notify/MeiTuanController.java @@ -255,7 +255,7 @@ public class MeiTuanController { } - @RequestMapping(value = "/orderPush", method = RequestMethod.POST) + @RequestMapping(value = "/order", method = RequestMethod.POST) @ApiOperation(value = "订单状态变更回调") @ResponseBody public Object orderPush( diff --git a/schedule/src/main/java/com/hfkj/schedule/JdGoodsSchedule.java b/schedule/src/main/java/com/hfkj/schedule/JdGoodsSchedule.java index 3a41221..25e744f 100644 --- a/schedule/src/main/java/com/hfkj/schedule/JdGoodsSchedule.java +++ b/schedule/src/main/java/com/hfkj/schedule/JdGoodsSchedule.java @@ -38,16 +38,16 @@ public class JdGoodsSchedule { @Resource private JdService jdService; -// //每10分钟执行一次 -// @Scheduled(cron = "0 0/10 * * * ?") -// public void etcCarMsg() { -// try { -// -// jdService.deleteMsg(); -// -// } catch (Exception e) { -// log.error("HighUserController --> findByUserId() error!", e); -// } -// } + //每10分钟执行一次 + @Scheduled(cron = "0 0/10 * * * ?") + public void etcCarMsg() { + try { + + jdService.deleteMsg(); + + } catch (Exception e) { + log.error("HighUserController --> findByUserId() error!", e); + } + } } diff --git a/service/src/main/java/com/hfkj/dao/GoodsMsgMapperExt.java b/service/src/main/java/com/hfkj/dao/GoodsMsgMapperExt.java index a48f72a..6113411 100644 --- a/service/src/main/java/com/hfkj/dao/GoodsMsgMapperExt.java +++ b/service/src/main/java/com/hfkj/dao/GoodsMsgMapperExt.java @@ -38,26 +38,55 @@ public interface GoodsMsgMapperExt { "") List getJdGoodsList(@Param("param") Map param); +// @Select("") +// List getGoodsListCrest(@Param("param") Map param); + @Select("") - List getGoodsListCrest(@Param("param") Map param); + List getGoodsListCrest(@Param("param") Map param); } \ No newline at end of file diff --git a/service/src/main/java/com/hfkj/dao/GoodsSpecsMapperExt.java b/service/src/main/java/com/hfkj/dao/GoodsSpecsMapperExt.java index 79e85f4..eb4d5d4 100644 --- a/service/src/main/java/com/hfkj/dao/GoodsSpecsMapperExt.java +++ b/service/src/main/java/com/hfkj/dao/GoodsSpecsMapperExt.java @@ -1,10 +1,8 @@ package com.hfkj.dao; -import com.hfkj.entity.GoodsMsg; import com.hfkj.entity.GoodsSpecs; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; - import java.util.List; import java.util.Map; @@ -18,11 +16,12 @@ public interface GoodsSpecsMapperExt { @Select("") - List getGoodsSpecsCrest(); + List getGoodsSpecsCrest(@Param("param") Map param); } \ No newline at end of file diff --git a/service/src/main/java/com/hfkj/haioil/HaiOilService.java b/service/src/main/java/com/hfkj/haioil/HaiOilService.java index b103a27..2128cfa 100644 --- a/service/src/main/java/com/hfkj/haioil/HaiOilService.java +++ b/service/src/main/java/com/hfkj/haioil/HaiOilService.java @@ -39,6 +39,45 @@ public class HaiOilService { } + /** + * @MethodName queryListByPk + * @Description: 查询优惠券包列表 + * @param map + * @return: com.alibaba.fastjson.JSONObject + * @Author: Sum1Dream + * @Date: 2024/9/9 下午3:00 + */ + public static JSONObject queryPkList(Map map) throws Exception { + + JSONObject object = request("/openapi/discount/queryPkList" , map); + + if (Objects.equals(object.getString("return_code"), "000000")) { + return object; + } else { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请求失败!"); + } + + } + + /** + * @MethodName queryPkDetail + * @Description: 查询优惠券包详情 + * @param map + * @return: com.alibaba.fastjson.JSONObject + * @Author: Sum1Dream + * @Date: 2024/9/9 下午3:00 + */ + public static JSONObject queryPkDetail(Map map) throws Exception { + + JSONObject object = request("/openapi/discount/queryPkDetail" , map); + + if (Objects.equals(object.getString("return_code"), "000000")) { + return object; + } else { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请求失败!"); + } + + } /** * @MethodName queryListByPhone diff --git a/service/src/main/java/com/hfkj/jd/Impl/JdServiceImpl.java b/service/src/main/java/com/hfkj/jd/Impl/JdServiceImpl.java index 2d6b557..e0963da 100644 --- a/service/src/main/java/com/hfkj/jd/Impl/JdServiceImpl.java +++ b/service/src/main/java/com/hfkj/jd/Impl/JdServiceImpl.java @@ -95,6 +95,7 @@ public class JdServiceImpl implements JdService { if (token == null) { // 请求回调 会在回调存入参数 JdPostService.getAccessToken(); + getToken(); } return token.toString(); } diff --git a/service/src/main/java/com/hfkj/jd/JdPostService.java b/service/src/main/java/com/hfkj/jd/JdPostService.java index 2a67763..5556b6d 100644 --- a/service/src/main/java/com/hfkj/jd/JdPostService.java +++ b/service/src/main/java/com/hfkj/jd/JdPostService.java @@ -8,6 +8,8 @@ import com.hfkj.entity.GoodsUserAddress; import com.jd.open.api.sdk.DefaultJdClient; import com.jd.open.api.sdk.JdClient; import com.jd.open.api.sdk.domain.vopdd.OperaOrderOpenProvider.request.submitOrder.*; +import com.jd.open.api.sdk.domain.vopdd.QueryOrderOpenProvider.request.querySkuFreight.AreaBaseInfoOpenReq; +import com.jd.open.api.sdk.domain.vopdd.QueryOrderOpenProvider.request.querySkuFreight.FreightQueryOpenReq; import com.jd.open.api.sdk.domain.vopkc.SkuInfoGoodsProvider.request.getNewStockById.AreaBaseInfoGoodsReq; import com.jd.open.api.sdk.domain.vopkc.SkuInfoGoodsProvider.request.getNewStockById.GetStockByIdGoodsReq; import com.jd.open.api.sdk.domain.vopkc.SkuInfoGoodsProvider.request.getNewStockById.SkuNumBaseGoodsReq; @@ -21,10 +23,7 @@ import com.jd.open.api.sdk.request.vopsh.VopAfsCreateAfsApplyRequest; import com.jd.open.api.sdk.request.vopsp.*; import com.jd.open.api.sdk.request.vopxx.VopMessageDeleteClientMsgByIdListRequest; import com.jd.open.api.sdk.request.vopxx.VopMessageQueryTransByVopNormalRequest; -import com.jd.open.api.sdk.response.vopdd.VopOrderConfirmOrderResponse; -import com.jd.open.api.sdk.response.vopdd.VopOrderQueryDeliveryInfoResponse; -import com.jd.open.api.sdk.response.vopdd.VopOrderQueryOrderDetailResponse; -import com.jd.open.api.sdk.response.vopdd.VopOrderSubmitOrderResponse; +import com.jd.open.api.sdk.response.vopdd.*; import com.jd.open.api.sdk.response.vopdz.VopAddressConvertFourAreaByDetailStrResponse; import com.jd.open.api.sdk.response.vopdz.VopAddressQueryJdAreaIdListResponse; import com.jd.open.api.sdk.response.vopdz.VopAddressVerifyAreaFourIdOpenReqResponse; @@ -192,6 +191,23 @@ public class JdPostService { return client.execute(request); } + // 查询商品运费 + public static VopOrderQuerySkuFreightResponse querySkuFreight(String token , List skuInfoList , Long provinceId , Long cityId , Long countyId , Long townId) throws Exception { + JdClient client=new DefaultJdClient(SERVER_URL,token,CommonSysConst.getSysConfig().getJDAppKey(),CommonSysConst.getSysConfig().getJDAppSecret()); + VopOrderQuerySkuFreightRequest request=new VopOrderQuerySkuFreightRequest(); + FreightQueryOpenReq freightQueryOpenReq=new FreightQueryOpenReq(); + freightQueryOpenReq.setPaymentType(4); + freightQueryOpenReq.setSkuInfoList(skuInfoList); + AreaBaseInfoOpenReq areaBaseInfoOpenReq = new AreaBaseInfoOpenReq(); + areaBaseInfoOpenReq.setProvinceId(provinceId); + areaBaseInfoOpenReq.setCityId(cityId); + areaBaseInfoOpenReq.setCountyId(countyId); + areaBaseInfoOpenReq.setTownId(townId); + freightQueryOpenReq.setAreaInfo(areaBaseInfoOpenReq); + request.setFreightQueryOpenReq(freightQueryOpenReq); + return client.execute(request); + } + // 提交预占订单服务 public static VopOrderSubmitOrderResponse submitOrder(String token , GoodsUserAddress address , String orderNo , Integer skuNum , Long skuId) throws Exception { // 创建京东客户端 diff --git a/service/src/main/java/com/hfkj/model/CmsContentModel.java b/service/src/main/java/com/hfkj/model/CmsContentModel.java index 92e4639..84388ca 100644 --- a/service/src/main/java/com/hfkj/model/CmsContentModel.java +++ b/service/src/main/java/com/hfkj/model/CmsContentModel.java @@ -2,6 +2,7 @@ package com.hfkj.model; import com.hfkj.entity.CmsContent; import com.hfkj.model.goods.GoodsModel; +import com.hfkj.model.goods.JdGoodsModel; import lombok.Data; import java.util.List; @@ -9,5 +10,5 @@ import java.util.List; @Data public class CmsContentModel extends CmsContent { - List goodsMsgList; + List goodsMsgList; } diff --git a/service/src/main/java/com/hfkj/model/goods/JdGoodsModel.java b/service/src/main/java/com/hfkj/model/goods/JdGoodsModel.java index f386744..b90f7cf 100644 --- a/service/src/main/java/com/hfkj/model/goods/JdGoodsModel.java +++ b/service/src/main/java/com/hfkj/model/goods/JdGoodsModel.java @@ -15,6 +15,10 @@ import java.math.BigDecimal; @Data public class JdGoodsModel { + @ColumnWidth(50) + @ExcelProperty("编码") + public String id; + @ColumnWidth(50) @ExcelProperty("一级分类") public String goodsTypeParentName; @@ -39,6 +43,10 @@ public class JdGoodsModel { @ExcelProperty("售卖价格") public BigDecimal salePrice; + @ColumnWidth(15) + @ExcelProperty("售卖价格") + public BigDecimal price; + @ColumnWidth(20) @ExcelProperty("京东价") public BigDecimal thirdPrice; @@ -51,6 +59,10 @@ public class JdGoodsModel { @ExcelProperty({"sku编码"}) public String thirdId; + @ColumnWidth(20) + @ExcelProperty({"规格编码"}) + public String specsId; + @ColumnWidth(20) @ExcelProperty({"销量"}) public String saleNum; diff --git a/service/src/main/java/com/hfkj/model/order/OrderChildModel.java b/service/src/main/java/com/hfkj/model/order/OrderChildModel.java index 0288590..bcf7450 100644 --- a/service/src/main/java/com/hfkj/model/order/OrderChildModel.java +++ b/service/src/main/java/com/hfkj/model/order/OrderChildModel.java @@ -18,4 +18,6 @@ public class OrderChildModel extends BsOrderChild { */ private Object business; + private Long addressId; + } diff --git a/service/src/main/java/com/hfkj/service/discount/CouponDiscountPackageService.java b/service/src/main/java/com/hfkj/service/discount/CouponDiscountPackageService.java index 71bbe97..e015fe0 100644 --- a/service/src/main/java/com/hfkj/service/discount/CouponDiscountPackageService.java +++ b/service/src/main/java/com/hfkj/service/discount/CouponDiscountPackageService.java @@ -1,5 +1,6 @@ package com.hfkj.service.discount; +import com.alibaba.fastjson.JSONObject; import com.hfkj.entity.CouponDiscount; import com.hfkj.entity.CouponDiscountPackage; import com.hfkj.entity.CouponDiscountPackageDetails; @@ -70,6 +71,7 @@ public interface CouponDiscountPackageService { */ List getList(Map map); + /** * @Author Sum1Dream * @Name getListRecordByMap diff --git a/service/src/main/java/com/hfkj/service/goods/GoodPresentService.java b/service/src/main/java/com/hfkj/service/goods/GoodPresentService.java index 5b3fb4f..462b16d 100644 --- a/service/src/main/java/com/hfkj/service/goods/GoodPresentService.java +++ b/service/src/main/java/com/hfkj/service/goods/GoodPresentService.java @@ -56,4 +56,13 @@ public interface GoodPresentService { * @Date: 2024/12/18 下午3:42 */ void delete(Long id , Boolean fullDelete); + + /** + * @MethodName PresentDiscountPackage + * @Description: + * @param specsId + * @Author: Sum1Dream + * @Date: 2024/12/30 下午3:47 + */ + void presentDiscountPackage(Long specsId, String phone) throws Exception; } diff --git a/service/src/main/java/com/hfkj/service/goods/GoodsMsgService.java b/service/src/main/java/com/hfkj/service/goods/GoodsMsgService.java index 4ac19b7..a2d53e2 100644 --- a/service/src/main/java/com/hfkj/service/goods/GoodsMsgService.java +++ b/service/src/main/java/com/hfkj/service/goods/GoodsMsgService.java @@ -87,7 +87,7 @@ public interface GoodsMsgService { * @Author: Sum1Dream * @Date: 2024/11/26 上午10:49 */ - List getListCrest(Map map); + List getListCrest(Map map); List getJdGoodsList(Map param); diff --git a/service/src/main/java/com/hfkj/service/goods/GoodsSpecsService.java b/service/src/main/java/com/hfkj/service/goods/GoodsSpecsService.java index a21692a..194413a 100644 --- a/service/src/main/java/com/hfkj/service/goods/GoodsSpecsService.java +++ b/service/src/main/java/com/hfkj/service/goods/GoodsSpecsService.java @@ -87,7 +87,7 @@ public interface GoodsSpecsService { List getList(Map map); - List getGoodsSpecsCrest(); + List getGoodsSpecsCrest(Map map); /** * @Author Sum1Dream diff --git a/service/src/main/java/com/hfkj/service/goods/impl/GoodPresentServiceImpl.java b/service/src/main/java/com/hfkj/service/goods/impl/GoodPresentServiceImpl.java index a67bec5..309e7d5 100644 --- a/service/src/main/java/com/hfkj/service/goods/impl/GoodPresentServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/goods/impl/GoodPresentServiceImpl.java @@ -1,19 +1,19 @@ package com.hfkj.service.goods.impl; import com.hfkj.dao.GoodPresentMapper; +import com.hfkj.entity.CouponDiscountPackage; import com.hfkj.entity.GoodPresent; import com.hfkj.entity.GoodPresentExample; import com.hfkj.entity.GoodsBrand; +import com.hfkj.haioil.HaiOilService; +import com.hfkj.service.discount.CouponDiscountPackageService; import com.hfkj.service.goods.GoodPresentService; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; -import java.util.Collections; -import java.util.Date; -import java.util.List; -import java.util.Map; +import java.util.*; @Service("goodPresentService") public class GoodPresentServiceImpl implements GoodPresentService { @@ -21,6 +21,9 @@ public class GoodPresentServiceImpl implements GoodPresentService { @Resource private GoodPresentMapper goodPresentMapper; + @Resource + private CouponDiscountPackageService couponDiscountPackageService; + @Override public void create(GoodPresent goodPresent) { goodPresentMapper.insert(goodPresent); @@ -44,6 +47,7 @@ public class GoodPresentServiceImpl implements GoodPresentService { if (MapUtils.getLong(map, "specsId") != null) { criteria.andSpecsIdEqualTo(MapUtils.getLong(map, "specsId")); } + criteria.andStatusNotEqualTo(0); return goodPresentMapper.selectByExample(example); } @@ -59,4 +63,24 @@ public class GoodPresentServiceImpl implements GoodPresentService { update(goodPresent); } } + + + @Override + public void presentDiscountPackage(Long specsId , String phone) throws Exception { + Map map = new HashMap<>(); + map.put("specsId",specsId); + List list = getList(map); + + for (GoodPresent goodPresent : list) { + if (goodPresent.getType() == 1) { + CouponDiscountPackage discountPackage = couponDiscountPackageService.findDiscountPackageByKey(goodPresent.getKey()); + couponDiscountPackageService.giveDiscountPackage(discountPackage.getId().intValue() , phone); + } else { + map.put("discountPkNo" , goodPresent.getKey()); + map.put("number" , 1); + map.put("phone" , phone); + HaiOilService.pushPk(map); + } + } + } } diff --git a/service/src/main/java/com/hfkj/service/goods/impl/GoodsMsgServiceImpl.java b/service/src/main/java/com/hfkj/service/goods/impl/GoodsMsgServiceImpl.java index c7a16f2..e3f5f05 100644 --- a/service/src/main/java/com/hfkj/service/goods/impl/GoodsMsgServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/goods/impl/GoodsMsgServiceImpl.java @@ -145,7 +145,7 @@ public class GoodsMsgServiceImpl implements GoodsMsgService { } @Override - public List getListCrest(Map map) { + public List getListCrest(Map map) { return goodsMsgMapper.getGoodsListCrest(map); } diff --git a/service/src/main/java/com/hfkj/service/goods/impl/GoodsSpecsServiceImpl.java b/service/src/main/java/com/hfkj/service/goods/impl/GoodsSpecsServiceImpl.java index 2b421d4..e152c2a 100644 --- a/service/src/main/java/com/hfkj/service/goods/impl/GoodsSpecsServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/goods/impl/GoodsSpecsServiceImpl.java @@ -112,8 +112,8 @@ public class GoodsSpecsServiceImpl implements GoodsSpecsService { @Override - public List getGoodsSpecsCrest() { - return goodsSpecsMapper.getGoodsSpecsCrest(); + public List getGoodsSpecsCrest(Map map) { + return goodsSpecsMapper.getGoodsSpecsCrest(map); } @Override diff --git a/service/src/main/java/com/hfkj/service/goods/impl/GoodsTypeServiceImpl.java b/service/src/main/java/com/hfkj/service/goods/impl/GoodsTypeServiceImpl.java index 95acb4e..cfc618a 100644 --- a/service/src/main/java/com/hfkj/service/goods/impl/GoodsTypeServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/goods/impl/GoodsTypeServiceImpl.java @@ -92,7 +92,7 @@ public class GoodsTypeServiceImpl implements GoodsTypeService { public List getList(Map map) { GoodsTypeExample example = new GoodsTypeExample(); - GoodsTypeExample.Criteria criteria = example.createCriteria().andStatusNotEqualTo(0); + GoodsTypeExample.Criteria criteria = example.createCriteria(); if (MapUtils.getLong(map, "parentId") != null) { criteria.andParentIdEqualTo(MapUtils.getLong(map, "parentId")); @@ -103,6 +103,11 @@ public class GoodsTypeServiceImpl implements GoodsTypeService { if (MapUtils.getInteger(map, "businessType") != null) { criteria.andBusinessTypeEqualTo(MapUtils.getInteger(map, "businessType")); } + if (MapUtils.getInteger(map, "type") != null) { + if (MapUtils.getInteger(map, "type") == 2) { + criteria.andOpIdIsNull(); + } + } if (MapUtils.getInteger(map, "status") != null) { criteria.andStatusEqualTo(MapUtils.getInteger(map, "status")); } else { diff --git a/service/src/main/java/com/hfkj/service/order/OrderCreateService.java b/service/src/main/java/com/hfkj/service/order/OrderCreateService.java index be1bbf0..c702c66 100644 --- a/service/src/main/java/com/hfkj/service/order/OrderCreateService.java +++ b/service/src/main/java/com/hfkj/service/order/OrderCreateService.java @@ -322,6 +322,7 @@ public class OrderCreateService { } orderChild.setBusiness(jsonObject); + orderChild.setAddressId(address.getId()); return orderChild; } diff --git a/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java b/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java index e0f4fcc..a789c83 100644 --- a/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java +++ b/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java @@ -72,6 +72,8 @@ public class OrderPaySuccessService { private BsOrderMemberService bsOrderMemberService; @Resource private JdService jdService; + @Resource + private GoodPresentService goodPresentService; /** * 订单业务处理 * @param order @@ -297,8 +299,9 @@ public class OrderPaySuccessService { if (goodsOrder.getThirdOrderNo() != null) { jdService.confirmOrder(goodsOrder); } - - + if (childOrder.getProductSpecId() != null) { + goodPresentService.presentDiscountPackage(childOrder.getProductSpecId() , order.getUserPhone()); + } goodsMsgService.editSaleNum(goodsOrder.getGoodsId() , goodsOrder.getGoodsCount() , 1); goodsOrder.setTotalPrice(childOrder.getProductTotalPrice()); diff --git a/service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java b/service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java index 48c1ebf..672a0b1 100644 --- a/service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java @@ -11,6 +11,7 @@ import com.hfkj.common.utils.RandomUtils; import com.hfkj.common.utils.RedisUtil; import com.hfkj.dao.BsOrderMapper; import com.hfkj.entity.*; +import com.hfkj.jd.JdPostService; import com.hfkj.jd.JdService; import com.hfkj.model.order.OrderChildModel; import com.hfkj.model.order.OrderModel; @@ -20,6 +21,8 @@ import com.hfkj.service.BsProductConfigService; import com.hfkj.service.discount.CouponDiscountService; import com.hfkj.service.discount.CouponDiscountUserRelService; import com.hfkj.service.goods.BsOrderCinemaService; +import com.hfkj.service.goods.GoodsSpecsService; +import com.hfkj.service.goods.GoodsUserAddressService; import com.hfkj.service.order.*; import com.hfkj.service.user.UserIntegralService; import com.hfkj.sysenum.UserIntegralRecordOpUserTypeEnum; @@ -28,6 +31,9 @@ import com.hfkj.sysenum.order.OrderChildProductTypeEnum; import com.hfkj.sysenum.order.OrderChildStatusEnum; import com.hfkj.sysenum.order.OrderPayChannelEnum; import com.hfkj.sysenum.order.OrderStatusEnum; +import com.jd.open.api.sdk.domain.vopdd.QueryOrderOpenProvider.request.querySkuFreight.SkuInfoOrderOpenReq; +import com.jd.open.api.sdk.domain.vopdd.QueryOrderOpenProvider.response.querySkuFreight.FreightQueryOpenResp; +import com.jd.open.api.sdk.response.vopdd.VopOrderQuerySkuFreightResponse; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.apache.rocketmq.spring.core.RocketMQTemplate; @@ -91,7 +97,10 @@ public class BsOrderServiceImpl implements BsOrderService { private BsProductConfigService productConfigService; @Resource private JdService jdService; - + @Resource + private GoodsSpecsService goodsSpecsService; + @Resource + private GoodsUserAddressService goodsUserAddressService; @Override public BsOrder editData(BsOrder order) { @@ -129,11 +138,17 @@ public class BsOrderServiceImpl implements BsOrderService { order.setOrderNo(DateUtil.date2String(new Date(), "yyMMddHHmmss") + RandomUtils.number(6, false)); editData(order); + Long addressId = null; // 订单总金额 BigDecimal totalPrice = new BigDecimal("0"); // 商品总金额 BigDecimal productTotalPrice = new BigDecimal("0"); + // 创建京东产品物流 + List skuInfoList = new ArrayList<>(); + SkuInfoOrderOpenReq skuInfo = new SkuInfoOrderOpenReq(); + + /************** 处理业务 ***************/ for (OrderChildModel child : order.getOrderChildList()) { child.setOrderNo(order.getOrderNo()); @@ -142,6 +157,14 @@ public class BsOrderServiceImpl implements BsOrderService { // 提交订单前实物商品处理 if (child.getProductType().equals(OrderChildProductTypeEnum.type1.getCode())) { child = orderCreateService.goods(order, child); + addressId = child.getAddressId(); + // 查询规格 + GoodsSpecs specs = goodsSpecsService.queryDetail(child.getProductSpecId()); + if (specs.getThirdId() != null) { + skuInfo.setSkuId(Long.parseLong(specs.getThirdId())); + skuInfo.setSkuNum(child.getProductCount()); + skuInfoList.add(skuInfo); + } // todo 1.0阶段暂时需要返回收货地址使用 order.setBusiness(child.getBusiness()); } else if (child.getProductType().equals(OrderChildProductTypeEnum.type2.getCode())) { @@ -223,6 +246,17 @@ public class BsOrderServiceImpl implements BsOrderService { order.setOrderStatus(order.getPayRealPrice().compareTo(new BigDecimal("0")) == 0?OrderStatusEnum.status2.getCode():OrderStatusEnum.status1.getCode()); BigDecimal totalChildDiscountPrice = new BigDecimal("0"); Long totalIntegralDiscountPrice = 0L; + + + // 计算运费 + if (!skuInfoList.isEmpty()) { + FreightQueryOpenResp resp = queryFreight(skuInfoList , addressId); + if (resp != null ) { + order.setFreightPrice(resp.getTotalFreight()); + order.setPayRealPrice(order.getPayRealPrice().add(resp.getTotalFreight())); + } + } + // 订单入库前处理 for (int i = 0; i < order.getOrderChildList().size();i++) { OrderChildModel childOrder = order.getOrderChildList().get(i); @@ -684,4 +718,19 @@ public class BsOrderServiceImpl implements BsOrderService { } } + + private FreightQueryOpenResp queryFreight(List skuInfoList , Long addressId) throws Exception { + GoodsUserAddress userAddress = goodsUserAddressService.queryDetail(addressId); + if (userAddress.getProvinceId() != null) { + VopOrderQuerySkuFreightResponse freightResponse = JdPostService.querySkuFreight(jdService.getToken() , skuInfoList , userAddress.getProvinceId() ,userAddress.getCityId() , userAddress.getCountyId() , userAddress.getTownId()); + + if (freightResponse != null && !freightResponse.getOpenRpcResult().getSuccess()) { + return null; + } + return freightResponse.getOpenRpcResult().getResult(); + } + return null; + + } + }