【功能优化】商城:调整满减送的数据返回

This commit is contained in:
YunaiV 2024-09-21 14:30:12 +08:00
parent 4fc10eff77
commit 00f89350e6
2 changed files with 40 additions and 17 deletions

View File

@ -6,6 +6,7 @@ import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
@Schema(description = "用户 App - 商品结算信息 Response VO")
@Data
@ -20,18 +21,6 @@ public class AppTradeProductSettlementRespVO {
@Schema(description = "满减送活动信息", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private RewardActivity rewardActivity;
@Schema(description = "满减送活动信息")
@Data
public static class RewardActivity {
@Schema(description = "满减活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Long id;
@Schema(description = "优惠规则描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "满 0.5 元减 0.3")
private List<String> ruleDescriptions;
}
@Schema(description = "SKU 价格信息")
@Data
public static class Sku implements Serializable {
@ -53,4 +42,40 @@ public class AppTradeProductSettlementRespVO {
}
@Schema(description = "满减送活动信息")
@Data
public static class RewardActivity {
@Schema(description = "满减活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Long id;
@Schema(description = "条件类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Integer conditionType;
@Schema(description = "优惠规则的数组", requiredMode = Schema.RequiredMode.REQUIRED)
private List<RewardActivityRule> rules;
}
@Schema(description = "优惠规则")
@Data
public static class RewardActivityRule {
@Schema(description = "优惠门槛", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") // 1. N 单位; 2. N
private Integer limit;
@Schema(description = "优惠价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
private Integer discountPrice;
@Schema(description = "是否包邮", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
private Boolean freeDelivery;
@Schema(description = "赠送的积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
private Integer point;
@Schema(description = "赠送的优惠劵编号的数组")
private Map<Long, Integer> giveCouponTemplateCounts;
}
}

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.trade.service.price;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO;
import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi;
import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO;
@ -145,11 +146,8 @@ public class TradePriceServiceImpl implements TradePriceService {
spuVO.setSkus(skuVOList);
// 2.2 满减送活动
RewardActivityMatchRespDTO rewardActivity = CollUtil.findOne(rewardActivityMap,
activity -> CollUtil.contains(activity.getProductScopeValues(), spuId));
if (rewardActivity != null) {
spuVO.setRewardActivity(new AppTradeProductSettlementRespVO.RewardActivity().setId(rewardActivity.getId())
.setRuleDescriptions(convertList(rewardActivity.getRules(), RewardActivityMatchRespDTO.Rule::getDescription)));
}
activity -> CollUtil.contains(activity.getSpuIds(), spuId));
spuVO.setRewardActivity(BeanUtils.toBean(rewardActivity, AppTradeProductSettlementRespVO.RewardActivity.class));
return spuVO;
});
}