Ver Fonte

feat(store): 更新生命优惠券实体字段填充策略并优化服务逻辑

- 为 LifeCoupon 和 LifeDiscountCoupon 实体中的多个字段添加 TableField 注解,
  设置 fill 属性为 FieldFill.UPDATE,以支持自动填充更新操作
- 在 LifeCouponPlatformController 中优化获取优惠券详情时的字段处理逻辑,
  对 singleQty、singleCanUse 和 purchaseLimitCode 字段做空值或默认值转换
- 在 LifeCouponPlatformServiceImpl 中新增对 singleQty 的初始化校验逻辑,
  若该字段为空则设置为 0
- 在 LifeDiscountCouponPlatformServiceImpl 中增加对 minimumSpendingAmount
  是否为零的判断,并在为零时设为 null,避免前端显示无效数值
- 所有修改均围绕提升数据一致性与接口返回规范性展开,增强系统健壮性和可维护性
zjy há 2 semanas atrás
pai
commit
3e28603fe9

+ 4 - 1
alien-entity/src/main/java/shop/alien/entity/store/LifeCoupon.java

@@ -56,17 +56,20 @@ public class LifeCoupon {
     private Integer expirationDate;
     private Integer expirationDate;
 
 
     @ApiModelProperty(value = "开始日期")
     @ApiModelProperty(value = "开始日期")
-    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8" )
+    @TableField(value = "start_date", fill = FieldFill.UPDATE)
     private Date startDate;
     private Date startDate;
 
 
     @ApiModelProperty(value = "结束日期")
     @ApiModelProperty(value = "结束日期")
     @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
     @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    @TableField(value = "end_date", fill = FieldFill.UPDATE)
     private Date endDate;
     private Date endDate;
 
 
     @ApiModelProperty(value = "不可用时间")
     @ApiModelProperty(value = "不可用时间")
     private String unusedDate;
     private String unusedDate;
 
 
     @ApiModelProperty(value = "优惠券数量")
     @ApiModelProperty(value = "优惠券数量")
+    @TableField(value = "single_qty", fill = FieldFill.UPDATE)
     private Integer singleQty;
     private Integer singleQty;
 
 
     @ApiModelProperty(value = "限制购买数")
     @ApiModelProperty(value = "限制购买数")

+ 3 - 3
alien-entity/src/main/java/shop/alien/entity/store/LifeDiscountCoupon.java

@@ -42,7 +42,7 @@ public class LifeDiscountCoupon extends Model<LifeDiscountCoupon> {
     private String name;
     private String name;
 
 
     @ApiModelProperty(value = "面值")
     @ApiModelProperty(value = "面值")
-    @TableField("nominal_value")
+    @TableField(value = "nominal_value", fill = FieldFill.UPDATE)
     private BigDecimal nominalValue;
     private BigDecimal nominalValue;
 
 
     @ApiModelProperty(value = "有效期(天)")
     @ApiModelProperty(value = "有效期(天)")
@@ -58,7 +58,7 @@ public class LifeDiscountCoupon extends Model<LifeDiscountCoupon> {
     private LocalDate endDate;
     private LocalDate endDate;
 
 
     @ApiModelProperty(value = "库存(优惠券数量)")
     @ApiModelProperty(value = "库存(优惠券数量)")
-    @TableField("single_qty")
+    @TableField(value = "single_qty", fill = FieldFill.UPDATE)
     private Integer singleQty;
     private Integer singleQty;
 
 
     @ApiModelProperty(value = "补充说明")
     @ApiModelProperty(value = "补充说明")
@@ -74,7 +74,7 @@ public class LifeDiscountCoupon extends Model<LifeDiscountCoupon> {
     private Integer restrictedQuantity;
     private Integer restrictedQuantity;
 
 
     @ApiModelProperty(value = "最低消费")
     @ApiModelProperty(value = "最低消费")
-    @TableField("minimum_spending_amount")
+    @TableField(value = "minimum_spending_amount", fill = FieldFill.UPDATE)
     private BigDecimal minimumSpendingAmount;
     private BigDecimal minimumSpendingAmount;
 
 
     @ApiModelProperty(value = "类型   1-优惠券  2-红包 3-平台优惠券")
     @ApiModelProperty(value = "类型   1-优惠券  2-红包 3-平台优惠券")

+ 14 - 1
alien-store-platform/src/main/java/shop/alien/storeplatform/controller/LifeCouponPlatformController.java

@@ -128,7 +128,20 @@ public class LifeCouponPlatformController {
         log.info("LifeCouponController.getCouponDetail?id={}", id);
         log.info("LifeCouponController.getCouponDetail?id={}", id);
         LambdaQueryWrapper<LifeCoupon> objectLambdaQueryWrapper = new LambdaQueryWrapper<>();
         LambdaQueryWrapper<LifeCoupon> objectLambdaQueryWrapper = new LambdaQueryWrapper<>();
         objectLambdaQueryWrapper.eq(LifeCoupon::getId, id);
         objectLambdaQueryWrapper.eq(LifeCoupon::getId, id);
-        return R.data(lifeCouponService.getOne(objectLambdaQueryWrapper));
+        LifeCoupon coupon = lifeCouponService.getOne(objectLambdaQueryWrapper);
+        if (coupon.getSingleQty() == null || coupon.getSingleQty() == 0) {
+            coupon.setSingleQty(null);
+        }
+
+        if ("0".equals(coupon.getSingleCanUse())) {
+            coupon.setSingleCanUse(null);
+        }
+
+        if ("0".equals(coupon.getPurchaseLimitCode())) {
+            coupon.setPurchaseLimitCode(null);
+        }
+
+        return R.data(coupon);
     }
     }
 
 
 
 

+ 4 - 0
alien-store-platform/src/main/java/shop/alien/storeplatform/service/impl/LifeCouponPlatformServiceImpl.java

@@ -91,6 +91,10 @@ public class LifeCouponPlatformServiceImpl extends ServiceImpl<LifeCouponMapper,
             lifeCoupon.setSingleCanUse("0");
             lifeCoupon.setSingleCanUse("0");
         }
         }
 
 
+        if (lifeCoupon.getSingleQty() == null || "".equals(lifeCoupon.getSingleQty())) {
+            lifeCoupon.setSingleQty(0);
+        }
+
         lifeCoupon.setStatus(1);
         lifeCoupon.setStatus(1);
         if (StringUtils.isEmpty(lifeCoupon.getId())) {
         if (StringUtils.isEmpty(lifeCoupon.getId())) {
             lifeCoupon.setType(1);
             lifeCoupon.setType(1);

+ 3 - 0
alien-store-platform/src/main/java/shop/alien/storeplatform/service/impl/LifeDiscountCouponPlatformServiceImpl.java

@@ -381,6 +381,9 @@ public class LifeDiscountCouponPlatformServiceImpl extends ServiceImpl<LifeDisco
         lifeDiscountCouponVo.setAvailableTimeQuantum(availableTimeQuantumList);
         lifeDiscountCouponVo.setAvailableTimeQuantum(availableTimeQuantumList);
         lifeDiscountCouponVo.setCustomizeUnavailableTimeQuantum(customizeUnavailableTimeQuantumList);
         lifeDiscountCouponVo.setCustomizeUnavailableTimeQuantum(customizeUnavailableTimeQuantumList);
         lifeDiscountCouponVo.setCreatedTime(lifeDiscountCoupon.getCreatedTime());
         lifeDiscountCouponVo.setCreatedTime(lifeDiscountCoupon.getCreatedTime());
+        if (lifeDiscountCouponVo.getMinimumSpendingAmount() != null && lifeDiscountCouponVo.getMinimumSpendingAmount().compareTo(BigDecimal.ZERO) == 0) {
+            lifeDiscountCouponVo.setMinimumSpendingAmount(null);
+        }
         return lifeDiscountCouponVo;
         return lifeDiscountCouponVo;
     }
     }