refactor(biz): 重构Vlog 视频价格计算逻辑
All checks were successful
ZhenTu-BE/pipeline/head This commit looks good

- 移除 OrderBiz 中的固定价格设置,改为调用价格计算服务
- 删除 PriceBiz 中未使用的 IOnePricePurchaseService 注入
- 优化 AppOrderV2Controller 中的产品数量设置逻辑
- 新增 VideoTaskRepository 中的 getTaskDeviceCount 方法,用于获取任务设备数量
- 调整 GoodsServiceImpl 和 OrderServiceImpl 中的相关代码,使用新的设备数量获取方法
This commit is contained in:
2025-09-08 10:11:19 +08:00
parent d9a2da49bb
commit 29637bc5e5
6 changed files with 48 additions and 66 deletions

View File

@@ -290,28 +290,8 @@ public class GoodsServiceImpl implements GoodsService {
if (task == null) {
return ApiResponse.fail("该vlog不存在或已失效");
}
Map<String, Object> paramJson = JacksonUtil.parseObject(task.getTaskParams(), Map.class);
AtomicInteger deviceCount = new AtomicInteger();
goodsDetailVO.setShotTime(taskTaskService.getTaskShotDate(task.getId()));
if (paramJson == null) {
deviceCount.set(1);
} else {
List<String> templatePlaceholder = templateRepository.getTemplatePlaceholder(task.getTemplateId());
paramJson.entrySet().stream()
.filter(entry -> StringUtils.isNumeric(entry.getKey()))
.forEach(entry -> {
List<Object> jsonArray = JacksonUtil.parseArray(JacksonUtil.toJSONString(entry.getValue()), Object.class);
if (jsonArray != null && !jsonArray.isEmpty()) {
for (Object ignored : jsonArray) {
if (templatePlaceholder.contains(entry.getKey())) {
deviceCount.getAndIncrement();
templatePlaceholder.remove(entry.getKey());
}
}
}
});
}
goodsDetailVO.setLensNum(deviceCount.get());
goodsDetailVO.setLensNum(videoTaskRepository.getTaskDeviceCount(task.getId()));
CouponRecordQueryResp couponRecord = couponBiz.queryUserCouponRecord(task.getScenicId(), userId, task.getFaceId(), task.getTemplateId().toString());
if (couponRecord != null) {
if (couponRecord.isUsable()) {

View File

@@ -298,19 +298,8 @@ public class OrderServiceImpl implements OrderService {
goods.setUrl(videoMapperById.getVideoUrl());
goods.setGoodsType(0);
goods.setTemplateCoverUrl(template.getCoverUrl());
long deviceCount;
if (task.getTaskParams() == null) {
deviceCount = 1;
} else {
Map<String, Object> paramJson = JacksonUtil.parseObject(task.getTaskParams(), Map.class);
List<String> templatePlaceholder = templateRepository.getTemplatePlaceholder(task.getTemplateId());
deviceCount = paramJson.keySet().stream()
.filter(StringUtils::isNumeric)
.filter(templatePlaceholder::contains)
.count();
}
goods.setCreateTime(videoTaskRepository.getTaskShotDate(task.getId()));
goods.setParts(Math.toIntExact(deviceCount));
goods.setParts(videoTaskRepository.getTaskDeviceCount(task.getId()));
goodsList.add(goods);
item.setShootingTime(videoTaskRepository.getTaskShotDate(videoMapperById.getTaskId()));
item.setVideoUrl(videoMapperById.getVideoUrl());