Commit 433e84b3 by 杨浩

fix: pickUp 接口更新客户订单金额方式改为直接设置 orderAmount

- CustomerOrderApi 新增 updateOrderAmount 方法
- ErpSaleOrderServiceImpl.updatePickUp 调用 updateOrderAmount 而非 updateActualAmount

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
parent 879700fb
...@@ -433,13 +433,8 @@ public class ErpSaleOrderServiceImpl implements ErpSaleOrderService { ...@@ -433,13 +433,8 @@ public class ErpSaleOrderServiceImpl implements ErpSaleOrderService {
int newOrderAmount = allCustomerOrderItems.stream() int newOrderAmount = allCustomerOrderItems.stream()
.mapToInt(item -> item.getOrderItemTotal() != null ? item.getOrderItemTotal() : 0) .mapToInt(item -> item.getOrderItemTotal() != null ? item.getOrderItemTotal() : 0)
.sum(); .sum();
// 通过差值方式更新 orderAmount:先查出旧值,计算差值 // 直接设置 orderAmount
CustomerOrderDTO customerOrder = customerOrderApi.queryById(saleOrder.getCustomerOrderId()); customerOrderApi.updateOrderAmount(saleOrder.getCustomerOrderId(), newOrderAmount);
int oldOrderAmount = customerOrder.getOrderAmount() != null ? customerOrder.getOrderAmount() : 0;
int diffAmount = newOrderAmount - oldOrderAmount;
if (diffAmount != 0) {
customerOrderApi.updateActualAmount(saleOrder.getCustomerOrderId(), diffAmount);
}
// 8. 更新 ErpPurchaseOrderItemDO // 8. 更新 ErpPurchaseOrderItemDO
ErpPurchaseOrderItemDO purchaseOrderItem = purchaseOrderItemMapper.selectByCustomerOrderItemId(saleItemOrder.getCustomerOrderItemId()); ErpPurchaseOrderItemDO purchaseOrderItem = purchaseOrderItemMapper.selectByCustomerOrderItemId(saleItemOrder.getCustomerOrderItemId());
......
...@@ -32,5 +32,7 @@ public interface CustomerOrderApi { ...@@ -32,5 +32,7 @@ public interface CustomerOrderApi {
void updateActualAmount(Long id, int addAmount); void updateActualAmount(Long id, int addAmount);
void updateOrderAmount(Long id, int orderAmount);
void updatePurchaseAnnex(Long customerOrderId, Long supplierId, Long productId, String annex); void updatePurchaseAnnex(Long customerOrderId, Long supplierId, Long productId, String annex);
} }
...@@ -936,6 +936,19 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO ...@@ -936,6 +936,19 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO
} }
@Override @Override
public void updateOrderAmount(Long id, int orderAmount) {
String lock = String.format(ORDER_LOCK, id);
RedisUtils.tryLockRds(lock);
try {
customerOrderMapper.update(Wrappers.<CustomerOrderDO>lambdaUpdate()
.set(CustomerOrderDO::getOrderAmount, orderAmount)
.eq(CustomerOrderDO::getId, id));
} finally {
RedisUtils.unLockRds(lock);
}
}
@Override
public void updatePurchaseAnnex(Long customerOrderId, Long supplierId, Long productId, String annex) { public void updatePurchaseAnnex(Long customerOrderId, Long supplierId, Long productId, String annex) {
customerOrderItemMapper.update(Wrappers.<CustomerOrderItemDO>lambdaUpdate() customerOrderItemMapper.update(Wrappers.<CustomerOrderItemDO>lambdaUpdate()
.set(CustomerOrderItemDO::getPurchaseAnnex, annex) .set(CustomerOrderItemDO::getPurchaseAnnex, annex)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment