Compare commits

...

2 Commits

Author SHA1 Message Date
6fb3cb93a9 feat(pricing): 增加商品参数校验和默认值设置
All checks were successful
ZhenTu-BE/pipeline/head This commit looks good
- 为每个产品增加产品类型和产品 ID 的非空校验
- 为购买数量和数量设置默认值为 1,如果未提供
2025-09-08 14:03:15 +08:00
c1ca4e8631 feat(template): 添加模板缩放裁剪功能
- 在 TemplateEntity 中添加 zoomCut 字段,用于控制模板的缩放裁剪
- 更新 TemplateMapper.xml,增加 zoom_cut 列的插入和更新逻辑
2025-09-08 10:54:21 +08:00
3 changed files with 19 additions and 3 deletions

View File

@@ -76,6 +76,7 @@ public class TemplateEntity {
private Integer sort;
private Integer cropEnable;
private Integer zoomCut;
private String onlyIf;
private String resolution;
private List<TemplateEntity> children;

View File

@@ -35,7 +35,21 @@ public class PriceCalculationServiceImpl implements IPriceCalculationService {
if (request.getProducts() == null || request.getProducts().isEmpty()) {
throw new PriceCalculationException("商品列表不能为空");
}
request.getProducts().forEach(product -> {
if (product.getProductType() == null) {
throw new PriceCalculationException("商品类型不能为空");
}
if (product.getProductId() == null) {
throw new PriceCalculationException("商品ID不能为空");
}
if (product.getPurchaseCount() == null) {
product.setPurchaseCount(1);
}
if (product.getQuantity() == null) {
product.setQuantity(1);
}
});
// 计算商品价格和原价
PriceDetails priceDetails = calculateProductsPriceWithOriginal(request.getProducts());
BigDecimal totalAmount = priceDetails.getTotalAmount();

View File

@@ -2,8 +2,8 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ycwl.basic.mapper.TemplateMapper">
<insert id="add">
insert into template(id, scenic_id, `name`, pid, is_placeholder, source_url, effects, luts, overlays, audios, cover_url, frame_rate, speed, price, slash_price, sort, crop_enable, only_if, resolution, create_time)
values (#{id}, #{scenicId}, #{name}, #{pid}, #{isPlaceholder}, #{sourceUrl}, #{effects}, #{luts}, #{overlays}, #{audios}, #{coverUrl}, #{frameRate}, #{speed}, #{price}, #{slashPrice}, #{sort}, #{cropEnable}, #{onlyIf}, #{resolution}, now())
insert into template(id, scenic_id, `name`, pid, is_placeholder, source_url, effects, luts, overlays, audios, cover_url, frame_rate, speed, price, slash_price, sort, crop_enable, zoom_cut, only_if, resolution, create_time)
values (#{id}, #{scenicId}, #{name}, #{pid}, #{isPlaceholder}, #{sourceUrl}, #{effects}, #{luts}, #{overlays}, #{audios}, #{coverUrl}, #{frameRate}, #{speed}, #{price}, #{slashPrice}, #{sort}, #{cropEnable}, #{zoomCut}, #{onlyIf}, #{resolution}, now())
</insert>
<insert id="addConfig">
insert into template_config(id, template_id, create_time)
@@ -29,6 +29,7 @@
<if test="speed!= null">speed = #{speed}, </if>
<if test="sort!= null">sort = #{sort}, </if>
<if test="cropEnable!= null">crop_enable = #{cropEnable}, </if>
<if test="zoomCut!= null">zoom_cut = #{zoomCut}, </if>
<if test="onlyIf!= null">only_if = #{onlyIf}, </if>
<if test="resolution!= null">resolution = #{resolution}, </if>
</set>