Fix Bug #503: AI修复
This commit is contained in:
@@ -58,11 +58,13 @@ public class DispenseServiceImpl {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Map<String, Object> returnDrug(Long dispenseId, Integer quantity) {
|
||||
// 1. 写入退药明细(负数表示退药)
|
||||
dispenseMapper.insertDetail(dispenseId, -quantity);
|
||||
int returnQty = -Math.abs(quantity);
|
||||
dispenseMapper.insertDetail(dispenseId, returnQty);
|
||||
|
||||
// 2. 同步更新汇总单统计
|
||||
dispenseMapper.updateSummaryAfterDetail(dispenseId, -quantity);
|
||||
// 2. 同步更新汇总单统计(在同事务内完成,确保时机一致)
|
||||
dispenseMapper.updateSummaryAfterDetail(dispenseId, returnQty);
|
||||
|
||||
// 3. 返回统一结构
|
||||
return Map.of("code", 0, "msg", "退药成功");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user