You've already forked FrameTour-BE
feat(pricing): 集成定价服务并优化价格查询逻辑- 在 OrderBiz 中添加 IPriceCalculationService 依赖,用于计算价格
All checks were successful
ZhenTu-BE/pipeline/head This commit looks good
All checks were successful
ZhenTu-BE/pipeline/head This commit looks good
- 重构 queryPrice 方法,使用定价服务计算价格而不是直接从数据库读取 - 移除 PriceObj 中未使用的 scenicAllPrice 字段 - 删除 ScenicEntity 和 ScenicAddOrUpdateReq 中的冗余价格字段 -优化 ProductConfigServiceImpl 中的 getTierConfig 方法,增加参数校验
This commit is contained in:
@@ -24,6 +24,11 @@ import com.ycwl.basic.model.pc.task.entity.TaskEntity;
|
||||
import com.ycwl.basic.model.pc.template.resp.TemplateRespVO;
|
||||
import com.ycwl.basic.model.pc.video.entity.VideoEntity;
|
||||
import com.ycwl.basic.model.pc.video.resp.VideoRespVO;
|
||||
import com.ycwl.basic.pricing.dto.PriceCalculationRequest;
|
||||
import com.ycwl.basic.pricing.dto.PriceCalculationResult;
|
||||
import com.ycwl.basic.pricing.dto.ProductItem;
|
||||
import com.ycwl.basic.pricing.enums.ProductType;
|
||||
import com.ycwl.basic.pricing.service.IPriceCalculationService;
|
||||
import com.ycwl.basic.profitsharing.biz.ProfitSharingBiz;
|
||||
import com.ycwl.basic.repository.FaceRepository;
|
||||
import com.ycwl.basic.repository.OrderRepository;
|
||||
@@ -40,6 +45,7 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -79,6 +85,8 @@ public class OrderBiz {
|
||||
@Autowired
|
||||
@Lazy
|
||||
private PrinterService printerService;
|
||||
@Autowired
|
||||
private IPriceCalculationService iPriceCalculationService;
|
||||
|
||||
public PriceObj queryPrice(Long scenicId, int goodsType, Long goodsId) {
|
||||
PriceObj priceObj = new PriceObj();
|
||||
@@ -86,7 +94,6 @@ public class OrderBiz {
|
||||
priceObj.setGoodsId(goodsId);
|
||||
ScenicEntity scenic = scenicRepository.getScenic(scenicId);
|
||||
ScenicConfigEntity scenicConfig = scenicRepository.getScenicConfig(scenicId);
|
||||
priceObj.setScenicAllPrice(scenic.getPrice());
|
||||
if (scenicConfig != null) {
|
||||
if (Boolean.TRUE.equals(scenicConfig.getAllFree())) {
|
||||
// 景区全免
|
||||
@@ -120,13 +127,20 @@ public class OrderBiz {
|
||||
priceObj.setScenicId(video.getScenicId());
|
||||
break;
|
||||
case 1: // source
|
||||
priceObj.setPrice(scenic.getSourceVideoPrice());
|
||||
priceObj.setSlashPrice(scenic.getSourceVideoPrice());
|
||||
priceObj.setFaceId(goodsId);
|
||||
break;
|
||||
case 2: // source
|
||||
priceObj.setPrice(scenic.getSourceImagePrice());
|
||||
priceObj.setSlashPrice(scenic.getSourceImagePrice());
|
||||
FaceEntity face = faceRepository.getFace(goodsId);
|
||||
PriceCalculationRequest calculationRequest = new PriceCalculationRequest();
|
||||
ProductItem productItem = new ProductItem();
|
||||
productItem.setProductType(goodsType == 1 ? ProductType.RECORDING_SET : ProductType.PHOTO_SET);
|
||||
productItem.setProductId(scenic.getId().toString());
|
||||
productItem.setPurchaseCount(1);
|
||||
productItem.setScenicId(scenic.getId().toString());
|
||||
calculationRequest.setProducts(Collections.singletonList(productItem));
|
||||
calculationRequest.setUserId(face.getMemberId());
|
||||
calculationRequest.setFaceId(face.getId());
|
||||
PriceCalculationResult priceCalculationResult = iPriceCalculationService.calculatePrice(calculationRequest);
|
||||
priceObj.setPrice(priceCalculationResult.getFinalAmount());
|
||||
priceObj.setSlashPrice(priceCalculationResult.getOriginalAmount());
|
||||
priceObj.setFaceId(goodsId);
|
||||
break;
|
||||
}
|
||||
|
@@ -12,6 +12,5 @@ public class PriceObj {
|
||||
private Long goodsId;
|
||||
private Long faceId;
|
||||
private BigDecimal price = BigDecimal.ZERO;
|
||||
private BigDecimal scenicAllPrice;
|
||||
private BigDecimal slashPrice;
|
||||
}
|
||||
|
@@ -61,7 +61,4 @@ public class ScenicEntity {
|
||||
* 景区源素材价格,元
|
||||
*/
|
||||
private String kfCodeUrl;
|
||||
private BigDecimal price;
|
||||
private BigDecimal sourceVideoPrice;
|
||||
private BigDecimal sourceImagePrice;
|
||||
}
|
||||
|
@@ -77,10 +77,6 @@ public class ScenicAddOrUpdateReq {
|
||||
private Date createTime;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date updateTime;
|
||||
// 景区源素材价格,元
|
||||
private BigDecimal price;
|
||||
private BigDecimal sourceVideoPrice;
|
||||
private BigDecimal sourceImagePrice;
|
||||
|
||||
// 账号
|
||||
private String account;
|
||||
|
@@ -43,6 +43,9 @@ public class ProductConfigServiceImpl implements IProductConfigService {
|
||||
@Override
|
||||
// @Cacheable(value = "tier-config", key = "#productType + '_' + #productId + '_' + #quantity")
|
||||
public PriceTierConfig getTierConfig(String productType, String productId, Integer quantity) {
|
||||
if (quantity == null || quantity <= 0) {
|
||||
return null;
|
||||
}
|
||||
PriceTierConfig config = tierConfigMapper.selectByProductTypeAndQuantity(productType, productId, quantity);
|
||||
// 不使用default配置,没查到就算了
|
||||
// // 如果没有找到特定商品的阶梯配置,尝试使用default配置
|
||||
@@ -57,9 +60,10 @@ public class ProductConfigServiceImpl implements IProductConfigService {
|
||||
// }
|
||||
//
|
||||
if (config == null) {
|
||||
log.warn("阶梯定价配置未找到: productType={}, productId={}, quantity={}",
|
||||
productType, productId, quantity);
|
||||
return null;
|
||||
}
|
||||
log.warn("阶梯定价: productType={}, productId={}, quantity={},config={}",
|
||||
productType, productId, quantity, config);
|
||||
return config;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user