From aae6dbb9464c3daca335c56b7c3ecc0233d4fd29 Mon Sep 17 00:00:00 2001 From: sdhkjh <2450473462@qq.com> Date: Sun, 20 Oct 2024 11:33:21 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=95=86=E5=9F=8E=E4=BC=98=E6=83=A0?= =?UTF-8?q?=E5=88=B8=E4=BF=AE=E6=94=B9=E9=83=A8=E5=88=86=E6=88=90=E5=91=98?= =?UTF-8?q?=E5=8F=98=E9=87=8F=E7=9B=B8=E5=85=B3=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/skyeye/coupon/entity/Coupon.java | 4 +-- .../skyeye/coupon/entity/CouponMaterial.java | 4 +-- .../service/impl/CouponServiceImpl.java | 25 ++++++++++++++----- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/skyeye-shop/shop-store/src/main/java/com/skyeye/coupon/entity/Coupon.java b/skyeye-shop/shop-store/src/main/java/com/skyeye/coupon/entity/Coupon.java index 03c22265..f96aa4e2 100644 --- a/skyeye-shop/shop-store/src/main/java/com/skyeye/coupon/entity/Coupon.java +++ b/skyeye-shop/shop-store/src/main/java/com/skyeye/coupon/entity/Coupon.java @@ -80,7 +80,7 @@ public class Coupon extends BaseGeneralInfo { private String discountLimitPrice; @TableField(value = "take_count") - @ApiModelProperty(value = "商品范围", required = "required") + @ApiModelProperty(value = "已经领取优惠券的数量", required = "required") private Integer takeCount; @TableField(value = "use_count") @@ -88,6 +88,6 @@ public class Coupon extends BaseGeneralInfo { private Integer useCount; @TableField(exist = false) - @ApiModelProperty(value = "优惠券适用对象列表", required = "required,json") + @ApiModelProperty(value = "优惠券适用对象列表", required = "json") private List couponMaterialList; } \ No newline at end of file diff --git a/skyeye-shop/shop-store/src/main/java/com/skyeye/coupon/entity/CouponMaterial.java b/skyeye-shop/shop-store/src/main/java/com/skyeye/coupon/entity/CouponMaterial.java index 77e66e8f..ed125d1c 100644 --- a/skyeye-shop/shop-store/src/main/java/com/skyeye/coupon/entity/CouponMaterial.java +++ b/skyeye-shop/shop-store/src/main/java/com/skyeye/coupon/entity/CouponMaterial.java @@ -15,11 +15,11 @@ import lombok.Data; public class CouponMaterial extends CommonInfo { @TableId("id") - @ApiModelProperty("主键id。为空时新增,不为空时编辑") + @Property("主键id。为空时新增,不为空时编辑") private String id; @TableField(value = "material_id") - @ApiModelProperty(value = "商品id", required = "required") + @ApiModelProperty(value = "商品id") private String materialId; @TableField(value = "coupon_id") diff --git a/skyeye-shop/shop-store/src/main/java/com/skyeye/coupon/service/impl/CouponServiceImpl.java b/skyeye-shop/shop-store/src/main/java/com/skyeye/coupon/service/impl/CouponServiceImpl.java index a0489d47..557f2df2 100644 --- a/skyeye-shop/shop-store/src/main/java/com/skyeye/coupon/service/impl/CouponServiceImpl.java +++ b/skyeye-shop/shop-store/src/main/java/com/skyeye/coupon/service/impl/CouponServiceImpl.java @@ -1,6 +1,6 @@ package com.skyeye.coupon.service.impl; -import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -20,6 +20,7 @@ import com.skyeye.coupon.entity.Coupon; import com.skyeye.coupon.entity.CouponMaterial; import com.skyeye.coupon.enums.CouponValidityType; import com.skyeye.coupon.enums.PromotionDiscountType; +import com.skyeye.coupon.enums.PromotionMaterialScope; import com.skyeye.coupon.service.CouponMaterialService; import com.skyeye.coupon.service.CouponService; import com.skyeye.exception.CustomException; @@ -40,9 +41,15 @@ public class CouponServiceImpl extends SkyeyeBusinessServiceImpl couponMaterial.setCouponId(coupon.getId())); + coupon.getCouponMaterialList().forEach(couponMaterial -> { + if ((StrUtil.isEmpty(couponMaterial.getMaterialId()))) { + throw new CustomException("适用对象的商品id(materialId)不能为空"); + } + couponMaterial.setCouponId(coupon.getId()); + }); // 批量新增 couponMaterialService.createEntity(coupon.getCouponMaterialList(), userId); } @@ -108,7 +120,7 @@ public class CouponServiceImpl extends SkyeyeBusinessServiceImpl list = list(queryWrapper); List parentIdList = list.stream().map(Coupon::getId).collect(Collectors.toList()); - Map> couponMapMaterialList =couponMaterialService.queryListByCouponId(parentIdList); + Map> couponMapMaterialList = couponMaterialService.queryListByCouponId(parentIdList); for (Coupon coupon : list) { coupon.setCouponMaterialList(couponMapMaterialList.get(coupon.getId())); } @@ -124,13 +136,14 @@ public class CouponServiceImpl extends SkyeyeBusinessServiceImpl list = list(queryWrapper); outputObject.setBean(list); outputObject.settotal(list.size()); } + @Override public void updateTakeCount(String couponId, Integer takeCount) { UpdateWrapper updateWrapper = new UpdateWrapper<>();