From 08b78b5f2705470de9bad53ec77b96425854f1ee Mon Sep 17 00:00:00 2001 From: yuanye <418471657@qq.com> Date: Fri, 20 Dec 2024 11:43:24 +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 --- .../main/java/com/bweb/config/AuthConfig.java | 2 +- .../bweb/controller/file/FileController.java | 2 +- .../goods/GoodPresentController.java | 130 ++++++++++++++++++ .../discount/DiscountController.java | 1 + .../controller/goods/GoodsController.java | 34 ++++- .../com/hfkj/dao/GoodsSpecsMapperExt.java | 1 + .../java/com/hfkj/jd/Impl/JdServiceImpl.java | 5 +- .../discount/CouponDiscountUserRelModel.java | 5 + .../service/goods/GoodPresentService.java | 55 ++++++++ .../goods/impl/GoodPresentServiceImpl.java | 62 +++++++++ .../BsOrderAfterSalesApplyServiceImpl.java | 2 - 11 files changed, 290 insertions(+), 9 deletions(-) create mode 100644 bweb/src/main/java/com/bweb/controller/goods/GoodPresentController.java create mode 100644 service/src/main/java/com/hfkj/service/goods/impl/GoodPresentServiceImpl.java diff --git a/bweb/src/main/java/com/bweb/config/AuthConfig.java b/bweb/src/main/java/com/bweb/config/AuthConfig.java index 52b84aa..ae32148 100644 --- a/bweb/src/main/java/com/bweb/config/AuthConfig.java +++ b/bweb/src/main/java/com/bweb/config/AuthConfig.java @@ -1,4 +1,4 @@ -package com.cweb.config; +package com.bweb.config; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.module.SimpleModule; diff --git a/bweb/src/main/java/com/bweb/controller/file/FileController.java b/bweb/src/main/java/com/bweb/controller/file/FileController.java index ef5c13b..bbcc559 100644 --- a/bweb/src/main/java/com/bweb/controller/file/FileController.java +++ b/bweb/src/main/java/com/bweb/controller/file/FileController.java @@ -46,7 +46,7 @@ public class FileController { @RequestMapping(value="/getFileRecordsList",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询列表") - public ResponseData getFileRecordsList( HttpServletRequest request) { + public ResponseData getFileRecordsList(HttpServletRequest request) { try { SessionObject sessionObject = userCenter.getSessionObject(request); diff --git a/bweb/src/main/java/com/bweb/controller/goods/GoodPresentController.java b/bweb/src/main/java/com/bweb/controller/goods/GoodPresentController.java new file mode 100644 index 0000000..58cc84b --- /dev/null +++ b/bweb/src/main/java/com/bweb/controller/goods/GoodPresentController.java @@ -0,0 +1,130 @@ +package com.bweb.controller.goods; + +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.hfkj.common.exception.ErrorCode; +import com.hfkj.common.exception.ErrorHelp; +import com.hfkj.common.exception.SysCode; +import com.hfkj.common.security.SessionObject; +import com.hfkj.common.security.UserCenter; +import com.hfkj.common.utils.ResponseMsgUtil; +import com.hfkj.entity.CouponDiscountPackage; +import com.hfkj.entity.GoodPresent; +import com.hfkj.entity.GoodsMsg; +import com.hfkj.entity.GoodsType; +import com.hfkj.model.ResponseData; +import com.hfkj.model.SecUserSessionObject; +import com.hfkj.service.discount.CouponDiscountPackageService; +import com.hfkj.service.goods.GoodPresentService; +import com.hfkj.sysenum.SecUserObjectTypeEnum; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +@Controller +@RequestMapping(value="/goodPresent") +@Api(value="商品赠送") +public class GoodPresentController { + + private static final Logger log = LoggerFactory.getLogger(GoodPresentController.class); + + @Resource + private GoodPresentService goodPresentService; + + @Resource + private CouponDiscountPackageService discountPackageService; + + @Resource + private UserCenter userCenter; + + @RequestMapping(value="/createGoodPresent",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "创建商品赠送") + public ResponseData createGoodPresent(@RequestBody GoodPresent body, HttpServletRequest request) { + + try { + + SessionObject sessionObject = userCenter.getSessionObject(request); + SecUserSessionObject userModel = (SecUserSessionObject) sessionObject.getObject(); + + if (!userModel.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type1.getCode())) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.ROLE_NOT_PERMISSIONS, ""); + } + + if (body == null + || body.getKey() == null + || body.getType() == null + || 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, "优惠券包不存在"); + } + + body.setCreateTime(new Date()); + body.setUpdateTime(new Date()); + body.setStatus(1); + body.setName(discountPackage.getTitle()); + goodPresentService.create(body); + + return ResponseMsgUtil.success("操作成功"); + + } catch (Exception e) { + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + + } + + @RequestMapping(value="/getListBrand",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询列表") + public ResponseData getListBrand(@RequestParam(value = "specsId" , required = false) Long specsId) { + try { + + Map map = new HashMap<>(); + map.put("specsId", specsId); + return ResponseMsgUtil.success(goodPresentService.getList(map)); + + } catch (Exception e) { + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value="/delete",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "删除") + public ResponseData delete(@RequestParam(value = "id" , required = false) Long id, HttpServletRequest request) { + try { + + SessionObject sessionObject = userCenter.getSessionObject(request); + SecUserSessionObject userModel = (SecUserSessionObject) sessionObject.getObject(); + + if (!userModel.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type1.getCode())) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.ROLE_NOT_PERMISSIONS, ""); + } + + goodPresentService.delete(id , false); + + return ResponseMsgUtil.success("删除成功"); + + } catch (Exception e) { + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } + +} diff --git a/cweb/src/main/java/com/cweb/controller/discount/DiscountController.java b/cweb/src/main/java/com/cweb/controller/discount/DiscountController.java index af030a3..4d284f2 100644 --- a/cweb/src/main/java/com/cweb/controller/discount/DiscountController.java +++ b/cweb/src/main/java/com/cweb/controller/discount/DiscountController.java @@ -106,6 +106,7 @@ public class DiscountController { rel.setUserId(userSession.getUser().getId()); rel.setDiscountName(jsonObject.getString("discountName")); rel.setDiscountType(jsonObject.getInteger("discountType")); + rel.setDiscountNo(jsonObject.getString("discountNo")); rel.setDiscountCondition(jsonObject.getBigDecimal("discountCondition")); if (jsonObject.getInteger("discountType") == 3) { rel.setDiscountPercentage(jsonObject.getBigDecimal("discountPrice")); 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 630ba37..2210acc 100644 --- a/cweb/src/main/java/com/cweb/controller/goods/GoodsController.java +++ b/cweb/src/main/java/com/cweb/controller/goods/GoodsController.java @@ -10,16 +10,14 @@ import com.hfkj.common.security.SessionObject; import com.hfkj.common.security.UserCenter; import com.hfkj.common.utils.PageUtil; import com.hfkj.common.utils.ResponseMsgUtil; -import com.hfkj.entity.GoodsMsg; -import com.hfkj.entity.GoodsSpecs; -import com.hfkj.entity.GoodsType; -import com.hfkj.entity.GoodsVpd; +import com.hfkj.entity.*; import com.hfkj.jd.JdService; import com.hfkj.model.ResponseData; 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.service.discount.CouponDiscountService; import com.hfkj.service.goods.*; import com.hfkj.sysenum.SecUserObjectTypeEnum; import io.swagger.annotations.Api; @@ -61,6 +59,8 @@ public class GoodsController { @Resource private JdService jdService; + @Resource + private CouponDiscountService couponDiscountService; @RequestMapping(value="/getListGoodsType",method = RequestMethod.GET) @@ -114,6 +114,7 @@ public class GoodsController { @RequestParam(value = "goodsTypeParent", required = false) Long goodsTypeParent, @RequestParam(value = "goodsType", required = false) Long goodsType, @RequestParam(value = "showType", required = false) Integer showType, + @RequestParam(value = "discountId", required = false) Integer discountId, @RequestParam(value = "goodsBrand", required = false) Long goodsBrand, @RequestParam(value = "price", required = false) Integer price, @RequestParam(value = "saleNum", required = false) Integer saleNum, @@ -142,6 +143,14 @@ public class GoodsController { 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(); @@ -152,12 +161,29 @@ public class GoodsController { 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(); } + + if (discountId != null) { + CouponDiscountGoodsRel discountGoodsRel = couponDiscountGoodsRel.stream().filter(s -> s.getSpecsId().equals(specs.getId())).findFirst().orElse(null); + if (discountGoodsRel == null) { + specs.setExt1("0"); + } + } + + } + + // 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); diff --git a/service/src/main/java/com/hfkj/dao/GoodsSpecsMapperExt.java b/service/src/main/java/com/hfkj/dao/GoodsSpecsMapperExt.java index b7a09c9..79e85f4 100644 --- a/service/src/main/java/com/hfkj/dao/GoodsSpecsMapperExt.java +++ b/service/src/main/java/com/hfkj/dao/GoodsSpecsMapperExt.java @@ -17,6 +17,7 @@ public interface GoodsSpecsMapperExt { @Select("