Merge remote-tracking branch 'yudao/feature/mall_product' into feature/mall_product
commit
fcaa92d406
@ -0,0 +1,27 @@
|
|||||||
|
package cn.iocoder.yudao.module.promotion.api.coupon.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 优惠劵使用 Request DTO
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class CouponValidReqDTO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 优惠劵编号
|
||||||
|
*/
|
||||||
|
@NotNull(message = "优惠劵编号不能为空")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户编号
|
||||||
|
*/
|
||||||
|
@NotNull(message = "用户编号不能为空")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
package cn.iocoder.yudao.module.promotion.api.discount;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.promotion.api.discount.dto.DiscountProductRespDTO;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 限时折扣 API 接口
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
public interface DiscountActivityApi {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得商品匹配的的限时折扣信息
|
||||||
|
*
|
||||||
|
* @param skuIds 商品 SKU 编号数组
|
||||||
|
* @return 限时折扣信息
|
||||||
|
*/
|
||||||
|
List<DiscountProductRespDTO> getMatchDiscountProductList(Collection<Long> skuIds);
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,4 +0,0 @@
|
|||||||
/**
|
|
||||||
* 占位
|
|
||||||
*/
|
|
||||||
package cn.iocoder.yudao.module.promotion.api;
|
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
package cn.iocoder.yudao.module.promotion.api.discount;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.promotion.api.discount.dto.DiscountProductRespDTO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.convert.discount.DiscountActivityConvert;
|
||||||
|
import cn.iocoder.yudao.module.promotion.service.discount.DiscountActivityService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 限时折扣 API 实现类
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class DiscountActivityApiImpl implements DiscountActivityApi {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private DiscountActivityService discountActivityService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DiscountProductRespDTO> getMatchDiscountProductList(Collection<Long> skuIds) {
|
||||||
|
return DiscountActivityConvert.INSTANCE.convertList02(discountActivityService.getMatchDiscountProductList(skuIds));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.promotion.api.discount;
|
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
package cn.iocoder.yudao.module.promotion.api.reward;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.promotion.api.reward.dto.RewardActivityMatchRespDTO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.service.reward.RewardActivityService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 满减送活动 API 实现类
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class RewardActivityApiImpl implements RewardActivityApi {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RewardActivityService rewardActivityService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<RewardActivityMatchRespDTO> getMatchRewardActivityList(Collection<Long> spuIds) {
|
||||||
|
return rewardActivityService.getMatchRewardActivityList(spuIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,31 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo;
|
|
||||||
|
|
||||||
import com.alibaba.excel.annotation.ExcelProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 快递运费模板 Excel VO
|
|
||||||
*
|
|
||||||
* @author jason
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class DeliveryExpressTemplateExcelVO {
|
|
||||||
|
|
||||||
@ExcelProperty("编号,自增")
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
@ExcelProperty("模板名称")
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
@ExcelProperty("配送计费方式 1:按件 2:按重量 3:按体积")
|
|
||||||
private Integer chargeMode;
|
|
||||||
|
|
||||||
@ExcelProperty("排序")
|
|
||||||
private Integer sort;
|
|
||||||
|
|
||||||
@ExcelProperty("创建时间")
|
|
||||||
private LocalDateTime createTime;
|
|
||||||
|
|
||||||
}
|
|
||||||
4
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/DeliveryExpressCreateReqVO.java → yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressCreateReqVO.java
4
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/DeliveryExpressCreateReqVO.java → yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressCreateReqVO.java
@ -1,9 +1,7 @@
|
|||||||
package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo;
|
package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express;
|
||||||
|
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
import java.util.*;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import javax.validation.constraints.*;
|
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 快递公司创建 Request VO")
|
@Schema(description = "管理后台 - 快递公司创建 Request VO")
|
||||||
@Data
|
@Data
|
||||||
4
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/DeliveryExpressExportReqVO.java → yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressExportReqVO.java
4
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/DeliveryExpressExportReqVO.java → yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressExportReqVO.java
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo;
|
package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
10
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/DeliveryExpressUpdateReqVO.java → yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressUpdateReqVO.java
10
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/DeliveryExpressUpdateReqVO.java → yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressUpdateReqVO.java
@ -1,9 +1,11 @@
|
|||||||
package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo;
|
package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.*;
|
import lombok.Data;
|
||||||
import java.util.*;
|
import lombok.EqualsAndHashCode;
|
||||||
import javax.validation.constraints.*;
|
import lombok.ToString;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 快递公司更新 Request VO")
|
@Schema(description = "管理后台 - 快递公司更新 Request VO")
|
||||||
@Data
|
@Data
|
||||||
2
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/DeliveryExpressTemplateBaseVO.java → yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateBaseVO.java
2
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/DeliveryExpressTemplateBaseVO.java → yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateBaseVO.java
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo;
|
package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
11
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/DeliveryExpressTemplateCreateReqVO.java → yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateCreateReqVO.java
11
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/DeliveryExpressTemplateCreateReqVO.java → yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateCreateReqVO.java
10
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/DeliveryExpressTemplatePageReqVO.java → yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplatePageReqVO.java
10
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/DeliveryExpressTemplatePageReqVO.java → yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplatePageReqVO.java
@ -1,10 +1,12 @@
|
|||||||
package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo;
|
package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate;
|
||||||
|
|
||||||
import lombok.*;
|
|
||||||
import java.util.*;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.ToString;
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||||
2
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/DeliveryExpressTemplateRespVO.java → yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateRespVO.java
2
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/DeliveryExpressTemplateRespVO.java → yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateRespVO.java
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo;
|
package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
3
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/DeliveryExpressTemplateSimpleRespVO.java → yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateSimpleRespVO.java
3
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/DeliveryExpressTemplateSimpleRespVO.java → yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateSimpleRespVO.java
14
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/DeliveryExpressTemplateUpdateReqVO.java → yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateUpdateReqVO.java
14
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/DeliveryExpressTemplateUpdateReqVO.java → yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateUpdateReqVO.java
12
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/ExpressTemplateChargeBaseVO.java → yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/ExpressTemplateChargeBaseVO.java
12
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/ExpressTemplateChargeBaseVO.java → yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/ExpressTemplateChargeBaseVO.java
10
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/ExpressTemplateChargeUpdateVO.java → yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/ExpressTemplateChargeUpdateVO.java
10
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/ExpressTemplateChargeUpdateVO.java → yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/ExpressTemplateChargeUpdateVO.java
13
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/ExpressTemplateFreeBaseVO.java → yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/ExpressTemplateFreeBaseVO.java
13
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/ExpressTemplateFreeBaseVO.java → yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/ExpressTemplateFreeBaseVO.java
6
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/ExpressTemplateFreeUpdateVO.java → yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/ExpressTemplateFreeUpdateVO.java
6
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/ExpressTemplateFreeUpdateVO.java → yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/ExpressTemplateFreeUpdateVO.java
@ -0,0 +1,21 @@
|
|||||||
|
package cn.iocoder.yudao.module.trade.service.price;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO;
|
||||||
|
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 价格计算 Service 接口
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
public interface TradePriceService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 价格计算
|
||||||
|
*
|
||||||
|
* @param calculateReqDTO 计算信息
|
||||||
|
* @return 计算结果
|
||||||
|
*/
|
||||||
|
TradePriceCalculateRespBO calculatePrice(TradePriceCalculateReqBO calculateReqDTO);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,86 @@
|
|||||||
|
package cn.iocoder.yudao.module.trade.service.price.bo;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import javax.validation.constraints.Min;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 价格计算 Request BO
|
||||||
|
*
|
||||||
|
* @author yudao源码
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class TradePriceCalculateReqBO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单类型
|
||||||
|
*
|
||||||
|
* 枚举 {@link TradeOrderTypeEnum}
|
||||||
|
*/
|
||||||
|
private Integer orderType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户编号
|
||||||
|
*
|
||||||
|
* 对应 MemberUserDO 的 id 编号
|
||||||
|
*/
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 优惠劵编号
|
||||||
|
*
|
||||||
|
* 对应 CouponDO 的 id 编号
|
||||||
|
*/
|
||||||
|
private Long couponId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 收货地址编号
|
||||||
|
*
|
||||||
|
* 对应 MemberAddressDO 的 id 编号
|
||||||
|
*/
|
||||||
|
private Long addressId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品 SKU 数组
|
||||||
|
*/
|
||||||
|
@NotNull(message = "商品数组不能为空")
|
||||||
|
private List<Item> items;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品 SKU
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Valid
|
||||||
|
public static class Item {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SKU 编号
|
||||||
|
*/
|
||||||
|
@NotNull(message = "商品 SKU 编号不能为空")
|
||||||
|
private Long skuId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SKU 数量
|
||||||
|
*/
|
||||||
|
@NotNull(message = "商品 SKU 数量不能为空")
|
||||||
|
@Min(value = 0L, message = "商品 SKU 数量必须大于等于 0")
|
||||||
|
private Integer count;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 购物车项的编号
|
||||||
|
*/
|
||||||
|
private Long cartId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否选中
|
||||||
|
*/
|
||||||
|
@NotNull(message = "是否选中不能为空")
|
||||||
|
private Boolean selected;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,80 @@
|
|||||||
|
package cn.iocoder.yudao.module.trade.service.price.calculator;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.iocoder.yudao.module.promotion.api.discount.DiscountActivityApi;
|
||||||
|
import cn.iocoder.yudao.module.promotion.api.discount.dto.DiscountProductRespDTO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum;
|
||||||
|
import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum;
|
||||||
|
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO;
|
||||||
|
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO;
|
||||||
|
import org.springframework.core.annotation.Order;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||||
|
import static cn.iocoder.yudao.module.trade.service.price.calculator.TradePriceCalculatorHelper.formatPrice;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 限时折扣的 {@link TradePriceCalculator} 实现类
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@Order(TradePriceCalculator.ORDER_DISCOUNT_ACTIVITY)
|
||||||
|
public class TradeDiscountActivityPriceCalculator implements TradePriceCalculator {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private DiscountActivityApi discountActivityApi;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) {
|
||||||
|
// 获得 SKU 对应的限时折扣活动
|
||||||
|
List<DiscountProductRespDTO> discountProducts = discountActivityApi.getMatchDiscountProductList(
|
||||||
|
convertSet(result.getItems(), TradePriceCalculateRespBO.OrderItem::getSkuId));
|
||||||
|
if (CollUtil.isEmpty(discountProducts)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Map<Long, DiscountProductRespDTO> discountProductMap = convertMap(discountProducts, DiscountProductRespDTO::getSkuId);
|
||||||
|
|
||||||
|
// 处理每个 SKU 的限时折扣
|
||||||
|
result.getItems().forEach(orderItem -> {
|
||||||
|
// 1. 获取该 SKU 的优惠信息
|
||||||
|
DiscountProductRespDTO discountProduct = discountProductMap.get(orderItem.getSkuId());
|
||||||
|
if (discountProduct == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 2. 计算优惠金额
|
||||||
|
Integer newPayPrice = calculatePayPrice(discountProduct, orderItem);
|
||||||
|
Integer newDiscountPrice = orderItem.getPayPrice() - newPayPrice;
|
||||||
|
|
||||||
|
// 3.1 记录优惠明细
|
||||||
|
TradePriceCalculatorHelper.addPromotion(result, orderItem,
|
||||||
|
discountProduct.getActivityId(), discountProduct.getActivityName(), PromotionTypeEnum.DISCOUNT_ACTIVITY.getType(),
|
||||||
|
StrUtil.format("限时折扣:省 {} 元", formatPrice(newDiscountPrice)),
|
||||||
|
newDiscountPrice);
|
||||||
|
// 3.2 更新 SKU 优惠金额
|
||||||
|
orderItem.setDiscountPrice(orderItem.getDiscountPrice() + newDiscountPrice);
|
||||||
|
TradePriceCalculatorHelper.recountPayPrice(orderItem);
|
||||||
|
});
|
||||||
|
TradePriceCalculatorHelper.recountAllPrice(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Integer calculatePayPrice(DiscountProductRespDTO discountProduct,
|
||||||
|
TradePriceCalculateRespBO.OrderItem orderItem) {
|
||||||
|
Integer price = orderItem.getPayPrice();
|
||||||
|
if (PromotionDiscountTypeEnum.PRICE.getType().equals(discountProduct.getDiscountType())) { // 减价
|
||||||
|
price -= discountProduct.getDiscountPrice() * orderItem.getCount();
|
||||||
|
} else if (PromotionDiscountTypeEnum.PERCENT.getType().equals(discountProduct.getDiscountType())) { // 打折
|
||||||
|
price = price * discountProduct.getDiscountPercent() / 100;
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException(String.format("优惠活动的商品(%s) 的优惠类型不正确", discountProduct));
|
||||||
|
}
|
||||||
|
return price;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,19 @@
|
|||||||
|
package cn.iocoder.yudao.module.trade.service.price.calculator;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO;
|
||||||
|
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 价格计算的计算器接口
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
public interface TradePriceCalculator {
|
||||||
|
|
||||||
|
int ORDER_DISCOUNT_ACTIVITY = 10;
|
||||||
|
int ORDER_REWARD_ACTIVITY = 20;
|
||||||
|
int ORDER_COUPON = 30;
|
||||||
|
|
||||||
|
void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result);
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue