【代码评审】商城:满减送订单

This commit is contained in:
YunaiV 2024-09-02 21:53:41 +08:00
parent f3dd628aba
commit e5453028f1
2 changed files with 4 additions and 16 deletions

View File

@ -1,16 +0,0 @@
package cn.iocoder.yudao.module.promotion.convert.reward;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
/**
* 满减送活动 Convert
*
* @author 芋道源码
*/
@Mapper
public interface RewardActivityConvert {
RewardActivityConvert INSTANCE = Mappers.getMapper(RewardActivityConvert.class);
}

View File

@ -110,6 +110,10 @@ public class TradeRewardActivityPriceCalculator implements TradePriceCalculator
if (CollUtil.isNotEmpty(rule.getGiveCouponTemplateCounts())) {
for (Map.Entry<Long, Integer> entry : rule.getGiveCouponTemplateCounts().entrySet()) {
Map<Long, Integer> giveCouponTemplateCounts = result.getGiveCouponTemplateCounts();
// TODO @puhui999是不是有一种可能性这个 key 没有别的 key 有哈
// TODO 这里还有一种简化的写法就是下面大概两行就可以啦
// result.getGiveCouponTemplateCounts().put(entry.getKey(),
// result.getGiveCouponTemplateCounts().getOrDefault(entry.getKey(), 0) + entry.getValue());
if (giveCouponTemplateCounts.get(entry.getKey()) == null) { // 情况一还没有赠送的优惠券
result.setGiveCouponTemplateCounts(rule.getGiveCouponTemplateCounts());
} else { // 情况二别的满减活动送过同类优惠券则直接增加数量