优化入库单保存代码
This commit is contained in:
parent
8e0341d23f
commit
586e649017
|
|
@ -72,7 +72,11 @@ public class ReceiptOrderController extends BaseController {
|
||||||
@Log(title = "入库单", businessType = BusinessType.INSERT)
|
@Log(title = "入库单", businessType = BusinessType.INSERT)
|
||||||
@PostMapping("add-or-update")
|
@PostMapping("add-or-update")
|
||||||
public ResponseEntity<Integer> addOrUpdate(@RequestBody ReceiptOrderForm receiptOrder) {
|
public ResponseEntity<Integer> addOrUpdate(@RequestBody ReceiptOrderForm receiptOrder) {
|
||||||
return ResponseEntity.ok(service.addOrUpdate(receiptOrder));
|
if(receiptOrder.getId() == null ){
|
||||||
|
return ResponseEntity.ok(service.add(receiptOrder));
|
||||||
|
}else {
|
||||||
|
return ResponseEntity.ok(service.update(receiptOrder));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("修改入库单")
|
@ApiOperation("修改入库单")
|
||||||
|
|
|
||||||
|
|
@ -144,26 +144,36 @@ public class ReceiptOrderService {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增或更新入库单以及入库明细
|
* 新增入库单
|
||||||
*
|
*
|
||||||
* @param receiptOrder 入库单
|
* @param receiptOrder 入库单
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Transactional
|
@Transactional
|
||||||
public int addOrUpdate(ReceiptOrderForm receiptOrder) {
|
public int add(ReceiptOrderForm receiptOrder) {
|
||||||
int res;
|
int res;
|
||||||
// 1. 新增
|
// 1. 新增
|
||||||
if (receiptOrder.getId() == null) {
|
receiptOrder.setDelFlag(0);
|
||||||
receiptOrder.setDelFlag(0);
|
receiptOrder.setCreateTime(LocalDateTime.now());
|
||||||
receiptOrder.setCreateTime(LocalDateTime.now());
|
res = receiptOrderMapper.insert(receiptOrder);
|
||||||
res = receiptOrderMapper.insert(receiptOrder);
|
saveDetails(receiptOrder.getId(), receiptOrder.getDetails());
|
||||||
saveDetails(receiptOrder.getId(), receiptOrder.getDetails());
|
if(receiptOrder.getSupplierId()!=null && receiptOrder.getPayableAmount()!=null){
|
||||||
if(receiptOrder.getSupplierId()!=null && receiptOrder.getPayableAmount()!=null){
|
//保存订单金额到供应商流水表
|
||||||
//保存订单金额到供应商流水表
|
saveOrUpdatePayAmount(receiptOrder);
|
||||||
saveOrUpdatePayAmount(receiptOrder);
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
return res;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新入库单
|
||||||
|
*
|
||||||
|
* @param receiptOrder 入库单
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Transactional
|
||||||
|
public int update(ReceiptOrderForm receiptOrder){
|
||||||
|
int res;
|
||||||
// 2. 编辑
|
// 2. 编辑
|
||||||
QueryWrapper<ReceiptOrderDetail> qw = new QueryWrapper<>();
|
QueryWrapper<ReceiptOrderDetail> qw = new QueryWrapper<>();
|
||||||
qw.eq("receipt_order_id", receiptOrder.getId());
|
qw.eq("receipt_order_id", receiptOrder.getId());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue