mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 01:59:20 +08:00
feat(ecom-dmb): 成本同步弹窗新增实时订单数预览,确认前显示受影响订单数量
This commit is contained in:
+12
@@ -87,4 +87,16 @@ public interface OrderService extends IService<OrderPO> {
|
||||
int syncCostsToOrders(Long specId, java.math.BigDecimal productCost,
|
||||
java.math.BigDecimal shippingCost, java.math.BigDecimal otherCost,
|
||||
java.time.LocalDateTime startTime, java.time.LocalDateTime endTime);
|
||||
|
||||
/**
|
||||
* 统计在指定时间范围内、且商品规格在列表中的订单数量(与成本同步 UPDATE 条件一致,用于同步前预览)
|
||||
*
|
||||
* @param companyId 公司ID
|
||||
* @param specIds 规格ID列表
|
||||
* @param startTime 订单时间起(含)
|
||||
* @param endTime 订单时间止(含)
|
||||
* @return 订单条数
|
||||
*/
|
||||
long countOrdersForCostSync(Long companyId, java.util.List<Long> specIds,
|
||||
java.time.LocalDateTime startTime, java.time.LocalDateTime endTime);
|
||||
}
|
||||
|
||||
+14
@@ -463,4 +463,18 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OrderPO> implemen
|
||||
return baseMapper.updateCostFields(productCost, shippingCost, otherCost, specId, startTime, endTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countOrdersForCostSync(Long companyId, List<Long> specIds,
|
||||
java.time.LocalDateTime startTime, java.time.LocalDateTime endTime) {
|
||||
if (specIds == null || specIds.isEmpty()) {
|
||||
return 0L;
|
||||
}
|
||||
Long cnt = baseMapper.selectCount(new LambdaQueryWrapper<OrderPO>()
|
||||
.eq(OrderPO::getCompanyId, companyId)
|
||||
.in(OrderPO::getProductSpecId, specIds)
|
||||
.ge(OrderPO::getOrderTime, startTime)
|
||||
.le(OrderPO::getOrderTime, endTime));
|
||||
return cnt == null ? 0L : cnt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+22
@@ -136,6 +136,28 @@ public class ProductSpecController {
|
||||
return ApiResponse.success("成本同步成功,共更新" + updatedCount + "条订单", updatedCount);
|
||||
}
|
||||
|
||||
@Operation(summary = "统计成本同步将影响的订单数量", description = "根据已选规格与订单时间范围,统计当前公司将更新的订单条数,条件与批量同步一致")
|
||||
@PostMapping("/count-orders-for-cost-sync")
|
||||
@RequirePermission(value = "ecom:product:read", description = "统计成本同步订单数", allowSuper = true)
|
||||
public ApiResponse<Long> countOrdersForCostSync(@Valid @RequestBody BatchSyncCostDTO batchSyncCostDTO) {
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
List<ProductSpecPO> specs = productSpecService.getByIds(batchSyncCostDTO.getSpecIds());
|
||||
if (specs.isEmpty()) {
|
||||
return ApiResponse.success("统计成功", 0L);
|
||||
}
|
||||
for (ProductSpecPO spec : specs) {
|
||||
if (!spec.getCompanyId().equals(companyId)) {
|
||||
throw new BusinessException("规格不存在,规格ID: " + spec.getId());
|
||||
}
|
||||
}
|
||||
long count = orderService.countOrdersForCostSync(
|
||||
companyId,
|
||||
batchSyncCostDTO.getSpecIds(),
|
||||
batchSyncCostDTO.getStartTime(),
|
||||
batchSyncCostDTO.getEndTime());
|
||||
return ApiResponse.success("统计成功", count);
|
||||
}
|
||||
|
||||
@Operation(summary = "批量同步规格成本到历史订单", description = "批量将多个规格的成本同步到符合时间范围的订单")
|
||||
@PostMapping("/batch-sync-costs-to-orders")
|
||||
@RequirePermission(value = "ecom:product:update", description = "批量同步成本到订单", allowSuper = true)
|
||||
|
||||
Reference in New Issue
Block a user