mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-26 01:01:52 +08:00
product:订单表,增加 vip 优惠字段
This commit is contained in:
parent
53e789dfdc
commit
b4587fd79e
@ -23,12 +23,6 @@
|
|||||||
<artifactId>yudao-module-product-api</artifactId>
|
<artifactId>yudao-module-product-api</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${revision}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- TODO 芋艿:看看~~~ -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.iocoder.boot</groupId>
|
|
||||||
<artifactId>yudao-module-trade-api</artifactId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.iocoder.boot</groupId>
|
<groupId>cn.iocoder.boot</groupId>
|
||||||
<artifactId>yudao-module-member-api</artifactId>
|
<artifactId>yudao-module-member-api</artifactId>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package cn.iocoder.yudao.module.product.api.property;
|
package cn.iocoder.yudao.module.product.api.property;
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO;
|
import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO;
|
||||||
import cn.iocoder.yudao.module.product.convert.propertyvalue.ProductPropertyValueConvert;
|
import cn.iocoder.yudao.module.product.convert.property.ProductPropertyValueConvert;
|
||||||
import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService;
|
import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
package cn.iocoder.yudao.module.product.controller.admin.property;
|
package cn.iocoder.yudao.module.product.controller.admin.property;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
|
||||||
import cn.hutool.crypto.symmetric.AES;
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueCreateReqVO;
|
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueCreateReqVO;
|
||||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO;
|
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO;
|
||||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueRespVO;
|
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueRespVO;
|
||||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueUpdateReqVO;
|
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueUpdateReqVO;
|
||||||
import cn.iocoder.yudao.module.product.convert.propertyvalue.ProductPropertyValueConvert;
|
import cn.iocoder.yudao.module.product.convert.property.ProductPropertyValueConvert;
|
||||||
import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService;
|
import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
@ -20,9 +18,6 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
@Tag(name = "管理后台 - 商品属性值")
|
@Tag(name = "管理后台 - 商品属性值")
|
||||||
|
@ -1,10 +1,15 @@
|
|||||||
package cn.iocoder.yudao.module.product.controller.app.spu;
|
package cn.iocoder.yudao.module.product.controller.app.spu;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.module.member.api.level.MemberLevelApi;
|
||||||
|
import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO;
|
||||||
|
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
|
||||||
|
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
||||||
import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuDetailRespVO;
|
import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuDetailRespVO;
|
||||||
import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageRespVO;
|
|
||||||
import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO;
|
import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageRespVO;
|
||||||
import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert;
|
import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert;
|
||||||
import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
|
import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
|
||||||
import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO;
|
import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO;
|
||||||
@ -23,10 +28,12 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||||
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SPU_NOT_ENABLE;
|
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SPU_NOT_ENABLE;
|
||||||
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SPU_NOT_EXISTS;
|
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SPU_NOT_EXISTS;
|
||||||
|
|
||||||
@ -41,6 +48,11 @@ public class AppProductSpuController {
|
|||||||
@Resource
|
@Resource
|
||||||
private ProductSkuService productSkuService;
|
private ProductSkuService productSkuService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private MemberLevelApi memberLevelApi;
|
||||||
|
@Resource
|
||||||
|
private MemberUserApi memberUserApi;
|
||||||
|
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
@Operation(summary = "获得商品 SPU 列表")
|
@Operation(summary = "获得商品 SPU 列表")
|
||||||
@Parameters({
|
@Parameters({
|
||||||
@ -51,14 +63,32 @@ public class AppProductSpuController {
|
|||||||
@RequestParam("recommendType") String recommendType,
|
@RequestParam("recommendType") String recommendType,
|
||||||
@RequestParam(value = "count", defaultValue = "10") Integer count) {
|
@RequestParam(value = "count", defaultValue = "10") Integer count) {
|
||||||
List<ProductSpuDO> list = productSpuService.getSpuList(recommendType, count);
|
List<ProductSpuDO> list = productSpuService.getSpuList(recommendType, count);
|
||||||
return success(ProductSpuConvert.INSTANCE.convertListForGetSpuList(list));
|
if (CollUtil.isEmpty(list)) {
|
||||||
|
return success(Collections.emptyList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 拼接返回
|
||||||
|
List<AppProductSpuPageRespVO> voList = ProductSpuConvert.INSTANCE.convertListForGetSpuList(list);
|
||||||
|
// 处理 vip 价格
|
||||||
|
MemberLevelRespDTO memberLevel = getMemberLevel();
|
||||||
|
voList.forEach(vo -> vo.setVipPrice(calculateVipPrice(vo.getPrice(), memberLevel)));
|
||||||
|
return success(voList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@Operation(summary = "获得商品 SPU 分页")
|
@Operation(summary = "获得商品 SPU 分页")
|
||||||
public CommonResult<PageResult<AppProductSpuPageRespVO>> getSpuPage(@Valid AppProductSpuPageReqVO pageVO) {
|
public CommonResult<PageResult<AppProductSpuPageRespVO>> getSpuPage(@Valid AppProductSpuPageReqVO pageVO) {
|
||||||
PageResult<ProductSpuDO> pageResult = productSpuService.getSpuPage(pageVO);
|
PageResult<ProductSpuDO> pageResult = productSpuService.getSpuPage(pageVO);
|
||||||
return success(ProductSpuConvert.INSTANCE.convertPageForGetSpuPage(pageResult));
|
if (CollUtil.isEmpty(pageResult.getList())) {
|
||||||
|
return success(PageResult.empty(pageResult.getTotal()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 拼接返回
|
||||||
|
PageResult<AppProductSpuPageRespVO> voPageResult = ProductSpuConvert.INSTANCE.convertPageForGetSpuPage(pageResult);
|
||||||
|
// 处理 vip 价格
|
||||||
|
MemberLevelRespDTO memberLevel = getMemberLevel();
|
||||||
|
voPageResult.getList().forEach(vo -> vo.setVipPrice(calculateVipPrice(vo.getPrice(), memberLevel)));
|
||||||
|
return success(voPageResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/get-detail")
|
@GetMapping("/get-detail")
|
||||||
@ -74,10 +104,40 @@ public class AppProductSpuController {
|
|||||||
throw exception(SPU_NOT_ENABLE);
|
throw exception(SPU_NOT_ENABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查询商品 SKU
|
// 拼接返回
|
||||||
List<ProductSkuDO> skus = productSkuService.getSkuListBySpuId(spu.getId());
|
List<ProductSkuDO> skus = productSkuService.getSkuListBySpuId(spu.getId());
|
||||||
// 拼接
|
AppProductSpuDetailRespVO detailVO = ProductSpuConvert.INSTANCE.convertForGetSpuDetail(spu, skus);
|
||||||
return success(ProductSpuConvert.INSTANCE.convertForGetSpuDetail(spu, skus));
|
// 处理 vip 价格
|
||||||
|
MemberLevelRespDTO memberLevel = getMemberLevel();
|
||||||
|
detailVO.setVipPrice(calculateVipPrice(detailVO.getPrice(), memberLevel));
|
||||||
|
return success(detailVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
private MemberLevelRespDTO getMemberLevel() {
|
||||||
|
Long userId = getLoginUserId();
|
||||||
|
if (userId == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
MemberUserRespDTO user = memberUserApi.getUser(userId);
|
||||||
|
if (user.getLevelId() == null || user.getLevelId() <= 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return memberLevelApi.getMemberLevel(user.getLevelId());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算会员 VIP 优惠价格
|
||||||
|
*
|
||||||
|
* @param price 原价
|
||||||
|
* @param memberLevel 会员等级
|
||||||
|
* @return 优惠价格
|
||||||
|
*/
|
||||||
|
public Integer calculateVipPrice(Integer price, MemberLevelRespDTO memberLevel) {
|
||||||
|
if (memberLevel == null || memberLevel.getDiscountPercent() == null) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
Integer newPrice = price * memberLevel.getDiscountPercent() / 100;
|
||||||
|
return price - newPrice;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.yudao.module.product.convert.propertyvalue;
|
package cn.iocoder.yudao.module.product.convert.property;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
@ -79,8 +79,6 @@ public interface ProductSpuConvert {
|
|||||||
ProductSpuDO spu = list.get(i);
|
ProductSpuDO spu = list.get(i);
|
||||||
AppProductSpuPageRespVO spuVO = voList.get(i);
|
AppProductSpuPageRespVO spuVO = voList.get(i);
|
||||||
spuVO.setUnitName(DictFrameworkUtils.getDictDataLabel(DictTypeConstants.PRODUCT_UNIT, spu.getUnit()));
|
spuVO.setUnitName(DictFrameworkUtils.getDictDataLabel(DictTypeConstants.PRODUCT_UNIT, spu.getUnit()));
|
||||||
// 计算 vip 价格 TODO 芋艿:临时的逻辑,等 vip 支持后
|
|
||||||
spuVO.setVipPrice((int) (spuVO.getPrice() * 0.9));
|
|
||||||
}
|
}
|
||||||
return voList;
|
return voList;
|
||||||
}
|
}
|
||||||
@ -95,11 +93,6 @@ public interface ProductSpuConvert {
|
|||||||
.setUnitName(DictFrameworkUtils.getDictDataLabel(DictTypeConstants.PRODUCT_UNIT, spu.getUnit()));
|
.setUnitName(DictFrameworkUtils.getDictDataLabel(DictTypeConstants.PRODUCT_UNIT, spu.getUnit()));
|
||||||
// 处理 SKU
|
// 处理 SKU
|
||||||
spuVO.setSkus(convertListForGetSpuDetail(skus));
|
spuVO.setSkus(convertListForGetSpuDetail(skus));
|
||||||
// 计算 vip 价格 TODO 芋艿:临时的逻辑,等 vip 支持后
|
|
||||||
if (true) {
|
|
||||||
spuVO.setVipPrice((int) (spuVO.getPrice() * 0.9));
|
|
||||||
spuVO.getSkus().forEach(sku -> sku.setVipPrice((int) (sku.getPrice() * 0.9)));
|
|
||||||
}
|
|
||||||
return spuVO;
|
return spuVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* trade 模块,主要实现交易相关功能
|
* product 模块,主要实现交易相关功能
|
||||||
* 例如:订单、退款、购物车等功能。
|
* 例如:订单、退款、购物车等功能。
|
||||||
*
|
*
|
||||||
* 1. Controller URL:以 /product/ 开头,避免和其它 Module 冲突
|
* 1. Controller URL:以 /product/ 开头,避免和其它 Module 冲突
|
||||||
|
@ -5,7 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|||||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueCreateReqVO;
|
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueCreateReqVO;
|
||||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO;
|
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO;
|
||||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueUpdateReqVO;
|
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueUpdateReqVO;
|
||||||
import cn.iocoder.yudao.module.product.convert.propertyvalue.ProductPropertyValueConvert;
|
import cn.iocoder.yudao.module.product.convert.property.ProductPropertyValueConvert;
|
||||||
import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO;
|
import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO;
|
||||||
import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO;
|
import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO;
|
||||||
import cn.iocoder.yudao.module.product.dal.mysql.property.ProductPropertyValueMapper;
|
import cn.iocoder.yudao.module.product.dal.mysql.property.ProductPropertyValueMapper;
|
||||||
|
@ -53,9 +53,7 @@ public interface ErrorCodeConstants {
|
|||||||
|
|
||||||
// ========== Price 相关 1011003000 ============
|
// ========== Price 相关 1011003000 ============
|
||||||
ErrorCode PRICE_CALCULATE_PAY_PRICE_ILLEGAL = new ErrorCode(1011003000, "支付价格计算异常,原因:价格小于等于 0");
|
ErrorCode PRICE_CALCULATE_PAY_PRICE_ILLEGAL = new ErrorCode(1011003000, "支付价格计算异常,原因:价格小于等于 0");
|
||||||
ErrorCode PRICE_CALCULATE_DELIVERY_PRICE_USER_ADDRESS_IS_EMPTY = new ErrorCode(1011003001, "计算快递运费异常,收件人地址编号为空");
|
|
||||||
ErrorCode PRICE_CALCULATE_DELIVERY_PRICE_TEMPLATE_NOT_FOUND = new ErrorCode(1011003002, "计算快递运费异常,找不到对应的运费模板");
|
ErrorCode PRICE_CALCULATE_DELIVERY_PRICE_TEMPLATE_NOT_FOUND = new ErrorCode(1011003002, "计算快递运费异常,找不到对应的运费模板");
|
||||||
ErrorCode PRICE_CALCULATE_DELIVERY_PRICE_PICK_UP_STORE_IS_EMPTY = new ErrorCode(1011003003, "计算快递运费异常,自提点为空");
|
|
||||||
ErrorCode PRICE_CALCULATE_COUPON_NOT_MATCH_NORMAL_ORDER = new ErrorCode(1011003004, "参与秒杀、拼团、砍价的营销商品,无法使用优惠劵");
|
ErrorCode PRICE_CALCULATE_COUPON_NOT_MATCH_NORMAL_ORDER = new ErrorCode(1011003004, "参与秒杀、拼团、砍价的营销商品,无法使用优惠劵");
|
||||||
|
|
||||||
// ========== 物流 Express 模块 1011004000 ==========
|
// ========== 物流 Express 模块 1011004000 ==========
|
||||||
|
@ -82,6 +82,9 @@ public class AppTradeOrderSettlementRespVO {
|
|||||||
@Schema(description = "积分抵扣的金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "50")
|
@Schema(description = "积分抵扣的金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "50")
|
||||||
private Integer pointPrice;
|
private Integer pointPrice;
|
||||||
|
|
||||||
|
@Schema(description = "VIP 减免金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "30")
|
||||||
|
private Integer vipPrice;
|
||||||
|
|
||||||
@Schema(description = "实际支付金额(总),单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "450")
|
@Schema(description = "实际支付金额(总),单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "450")
|
||||||
private Integer payPrice;
|
private Integer payPrice;
|
||||||
|
|
||||||
|
@ -64,7 +64,8 @@ public class TradeDeliveryPriceCalculator implements TradePriceCalculator {
|
|||||||
|
|
||||||
private void calculateByPickUp(TradePriceCalculateReqBO param) {
|
private void calculateByPickUp(TradePriceCalculateReqBO param) {
|
||||||
if (param.getPickUpStoreId() == null) {
|
if (param.getPickUpStoreId() == null) {
|
||||||
throw exception(PRICE_CALCULATE_DELIVERY_PRICE_PICK_UP_STORE_IS_EMPTY);
|
// 价格计算时,如果为空就不算~最终下单,会校验该字段不允许空
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
DeliveryPickUpStoreDO pickUpStore = deliveryPickUpStoreService.getDeliveryPickUpStore(param.getPickUpStoreId());
|
DeliveryPickUpStoreDO pickUpStore = deliveryPickUpStoreService.getDeliveryPickUpStore(param.getPickUpStoreId());
|
||||||
if (pickUpStore == null || CommonStatusEnum.DISABLE.getStatus().equals(pickUpStore.getStatus())) {
|
if (pickUpStore == null || CommonStatusEnum.DISABLE.getStatus().equals(pickUpStore.getStatus())) {
|
||||||
@ -77,7 +78,8 @@ public class TradeDeliveryPriceCalculator implements TradePriceCalculator {
|
|||||||
private void calculateExpress(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) {
|
private void calculateExpress(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) {
|
||||||
// 0. 得到收件地址区域
|
// 0. 得到收件地址区域
|
||||||
if (param.getAddressId() == null) {
|
if (param.getAddressId() == null) {
|
||||||
throw exception(PRICE_CALCULATE_DELIVERY_PRICE_USER_ADDRESS_IS_EMPTY);
|
// 价格计算时,如果为空就不算~最终下单,会校验该字段不允许空
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
AddressRespDTO address = addressApi.getAddress(param.getAddressId(), param.getUserId());
|
AddressRespDTO address = addressApi.getAddress(param.getAddressId(), param.getUserId());
|
||||||
Assert.notNull(address, "收件人({})的地址,不能为空", param.getUserId());
|
Assert.notNull(address, "收件人({})的地址,不能为空", param.getUserId());
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
package cn.iocoder.yudao.module.trade.service.price.calculator;
|
package cn.iocoder.yudao.module.trade.service.price.calculator;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.iocoder.yudao.module.promotion.api.discount.DiscountActivityApi;
|
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.api.discount.dto.DiscountProductRespDTO;
|
||||||
import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum;
|
import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum;
|
||||||
import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum;
|
import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum;
|
||||||
|
import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum;
|
||||||
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO;
|
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO;
|
||||||
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO;
|
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO;
|
||||||
import org.springframework.core.annotation.Order;
|
import org.springframework.core.annotation.Order;
|
||||||
@ -33,6 +35,10 @@ public class TradeDiscountActivityPriceCalculator implements TradePriceCalculato
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) {
|
public void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) {
|
||||||
|
// 0. 只有【普通】订单,才计算该优惠
|
||||||
|
if (ObjectUtil.notEqual(result.getType(), TradeOrderTypeEnum.NORMAL.getType())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// 获得 SKU 对应的限时折扣活动
|
// 获得 SKU 对应的限时折扣活动
|
||||||
List<DiscountProductRespDTO> discountProducts = discountActivityApi.getMatchDiscountProductList(
|
List<DiscountProductRespDTO> discountProducts = discountActivityApi.getMatchDiscountProductList(
|
||||||
convertSet(result.getItems(), TradePriceCalculateRespBO.OrderItem::getSkuId));
|
convertSet(result.getItems(), TradePriceCalculateRespBO.OrderItem::getSkuId));
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package cn.iocoder.yudao.module.trade.service.price.calculator;
|
package cn.iocoder.yudao.module.trade.service.price.calculator;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.iocoder.yudao.module.member.api.level.MemberLevelApi;
|
import cn.iocoder.yudao.module.member.api.level.MemberLevelApi;
|
||||||
import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO;
|
import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO;
|
||||||
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
|
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
|
||||||
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
||||||
import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum;
|
import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum;
|
||||||
|
import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum;
|
||||||
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO;
|
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO;
|
||||||
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO;
|
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO;
|
||||||
import org.springframework.core.annotation.Order;
|
import org.springframework.core.annotation.Order;
|
||||||
@ -30,6 +32,10 @@ public class TradeMemberLevelPriceCalculator implements TradePriceCalculator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) {
|
public void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) {
|
||||||
|
// 0. 只有【普通】订单,才计算该优惠
|
||||||
|
if (ObjectUtil.notEqual(result.getType(), TradeOrderTypeEnum.NORMAL.getType())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// 1. 获得用户的会员等级
|
// 1. 获得用户的会员等级
|
||||||
MemberUserRespDTO user = memberUserApi.getUser(param.getUserId());
|
MemberUserRespDTO user = memberUserApi.getUser(param.getUserId());
|
||||||
if (user.getLevelId() == null || user.getLevelId() <= 0) {
|
if (user.getLevelId() == null || user.getLevelId() <= 0) {
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
package cn.iocoder.yudao.module.trade.service.price.calculator;
|
package cn.iocoder.yudao.module.trade.service.price.calculator;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.iocoder.yudao.module.promotion.api.reward.RewardActivityApi;
|
import cn.iocoder.yudao.module.promotion.api.reward.RewardActivityApi;
|
||||||
import cn.iocoder.yudao.module.promotion.api.reward.dto.RewardActivityMatchRespDTO;
|
import cn.iocoder.yudao.module.promotion.api.reward.dto.RewardActivityMatchRespDTO;
|
||||||
import cn.iocoder.yudao.module.promotion.enums.common.PromotionConditionTypeEnum;
|
import cn.iocoder.yudao.module.promotion.enums.common.PromotionConditionTypeEnum;
|
||||||
import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum;
|
import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum;
|
||||||
|
import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum;
|
||||||
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO;
|
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO;
|
||||||
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO;
|
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO;
|
||||||
import org.springframework.core.annotation.Order;
|
import org.springframework.core.annotation.Order;
|
||||||
@ -32,6 +34,10 @@ public class TradeRewardActivityPriceCalculator implements TradePriceCalculator
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) {
|
public void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) {
|
||||||
|
// 0. 只有【普通】订单,才计算该优惠
|
||||||
|
if (ObjectUtil.notEqual(result.getType(), TradeOrderTypeEnum.NORMAL.getType())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// 获得 SKU 对应的满减送活动
|
// 获得 SKU 对应的满减送活动
|
||||||
List<RewardActivityMatchRespDTO> rewardActivities = rewardActivityApi.getMatchRewardActivityList(
|
List<RewardActivityMatchRespDTO> rewardActivities = rewardActivityApi.getMatchRewardActivityList(
|
||||||
convertSet(result.getItems(), TradePriceCalculateRespBO.OrderItem::getSpuId));
|
convertSet(result.getItems(), TradePriceCalculateRespBO.OrderItem::getSpuId));
|
||||||
|
@ -5,6 +5,7 @@ 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.api.discount.dto.DiscountProductRespDTO;
|
||||||
import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum;
|
import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum;
|
||||||
import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum;
|
import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum;
|
||||||
|
import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum;
|
||||||
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO;
|
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO;
|
||||||
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO;
|
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@ -42,6 +43,7 @@ public class TradeDiscountActivityPriceCalculatorTest extends BaseMockitoUnitTes
|
|||||||
new TradePriceCalculateReqBO.Item().setSkuId(20L).setCount(3).setSelected(false) // 匹配活动,但未选中
|
new TradePriceCalculateReqBO.Item().setSkuId(20L).setCount(3).setSelected(false) // 匹配活动,但未选中
|
||||||
));
|
));
|
||||||
TradePriceCalculateRespBO result = new TradePriceCalculateRespBO()
|
TradePriceCalculateRespBO result = new TradePriceCalculateRespBO()
|
||||||
|
.setType(TradeOrderTypeEnum.NORMAL.getType())
|
||||||
.setPrice(new TradePriceCalculateRespBO.Price())
|
.setPrice(new TradePriceCalculateRespBO.Price())
|
||||||
.setPromotions(new ArrayList<>())
|
.setPromotions(new ArrayList<>())
|
||||||
.setItems(asList(
|
.setItems(asList(
|
||||||
|
@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO;
|
|||||||
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
|
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
|
||||||
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
||||||
import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum;
|
import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum;
|
||||||
|
import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum;
|
||||||
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO;
|
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO;
|
||||||
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO;
|
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@ -44,6 +45,7 @@ public class TradeMemberLevelPriceCalculatorTest extends BaseMockitoUnitTest {
|
|||||||
new TradePriceCalculateReqBO.Item().setSkuId(20L).setCount(3).setSelected(false) // 匹配活动,但未选中
|
new TradePriceCalculateReqBO.Item().setSkuId(20L).setCount(3).setSelected(false) // 匹配活动,但未选中
|
||||||
));
|
));
|
||||||
TradePriceCalculateRespBO result = new TradePriceCalculateRespBO()
|
TradePriceCalculateRespBO result = new TradePriceCalculateRespBO()
|
||||||
|
.setType(TradeOrderTypeEnum.NORMAL.getType())
|
||||||
.setPrice(new TradePriceCalculateRespBO.Price())
|
.setPrice(new TradePriceCalculateRespBO.Price())
|
||||||
.setPromotions(new ArrayList<>())
|
.setPromotions(new ArrayList<>())
|
||||||
.setItems(asList(
|
.setItems(asList(
|
||||||
|
@ -5,6 +5,7 @@ import cn.iocoder.yudao.module.promotion.api.reward.RewardActivityApi;
|
|||||||
import cn.iocoder.yudao.module.promotion.api.reward.dto.RewardActivityMatchRespDTO;
|
import cn.iocoder.yudao.module.promotion.api.reward.dto.RewardActivityMatchRespDTO;
|
||||||
import cn.iocoder.yudao.module.promotion.enums.common.PromotionConditionTypeEnum;
|
import cn.iocoder.yudao.module.promotion.enums.common.PromotionConditionTypeEnum;
|
||||||
import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum;
|
import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum;
|
||||||
|
import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum;
|
||||||
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO;
|
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO;
|
||||||
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO;
|
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@ -44,6 +45,7 @@ public class TradeRewardActivityPriceCalculatorTest extends BaseMockitoUnitTest
|
|||||||
new TradePriceCalculateReqBO.Item().setSkuId(30L).setCount(4).setSelected(true) // 匹配活动 2
|
new TradePriceCalculateReqBO.Item().setSkuId(30L).setCount(4).setSelected(true) // 匹配活动 2
|
||||||
));
|
));
|
||||||
TradePriceCalculateRespBO result = new TradePriceCalculateRespBO()
|
TradePriceCalculateRespBO result = new TradePriceCalculateRespBO()
|
||||||
|
.setType(TradeOrderTypeEnum.NORMAL.getType())
|
||||||
.setPrice(new TradePriceCalculateRespBO.Price())
|
.setPrice(new TradePriceCalculateRespBO.Price())
|
||||||
.setPromotions(new ArrayList<>())
|
.setPromotions(new ArrayList<>())
|
||||||
.setItems(asList(
|
.setItems(asList(
|
||||||
@ -157,6 +159,7 @@ public class TradeRewardActivityPriceCalculatorTest extends BaseMockitoUnitTest
|
|||||||
new TradePriceCalculateReqBO.Item().setSkuId(30L).setCount(4).setSelected(true)
|
new TradePriceCalculateReqBO.Item().setSkuId(30L).setCount(4).setSelected(true)
|
||||||
));
|
));
|
||||||
TradePriceCalculateRespBO result = new TradePriceCalculateRespBO()
|
TradePriceCalculateRespBO result = new TradePriceCalculateRespBO()
|
||||||
|
.setType(TradeOrderTypeEnum.NORMAL.getType())
|
||||||
.setPrice(new TradePriceCalculateRespBO.Price())
|
.setPrice(new TradePriceCalculateRespBO.Price())
|
||||||
.setPromotions(new ArrayList<>())
|
.setPromotions(new ArrayList<>())
|
||||||
.setItems(asList(
|
.setItems(asList(
|
||||||
|
Loading…
Reference in New Issue
Block a user