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<>();