给单据增加订金字段和接口逻辑

This commit is contained in:
季圣华
2022-05-29 18:18:00 +08:00
parent 9f2be3b81b
commit 3939106bee
13 changed files with 179 additions and 52 deletions

View File

@@ -135,6 +135,7 @@ public class DepotHeadService {
if(dh.getDeposit() == null) {
dh.setDeposit(BigDecimal.ZERO);
}
dh.setFinishDeposit(depotHeadMapperEx.getFinishDepositByNumber(dh.getNumber()));
if(StringUtil.isNotEmpty(dh.getSalesMan())) {
dh.setSalesManStr(personService.getPersonByMapAndIds(personMap,dh.getSalesMan()));
}
@@ -745,6 +746,16 @@ public class DepotHeadService {
}
depotHead.setAccountMoneyList(accountMoneyList);
}
//校验累计扣除订金是否超出订单中的金额
if(depotHead.getDeposit()!=null && StringUtil.isNotEmpty(depotHead.getLinkNumber())) {
BigDecimal finishDeposit = depotHeadMapperEx.getFinishDepositByNumberExceptCurrent(depotHead.getLinkNumber(), depotHead.getNumber());
//订单中的订金金额
BigDecimal preDeposit = getDepotHead(depotHead.getLinkNumber()).getChangeAmount().abs();
if(depotHead.getDeposit().add(finishDeposit).compareTo(preDeposit)>0) {
throw new BusinessRunTimeException(ExceptionConstants.DEPOT_HEAD_DEPOSIT_OVER_PRE_CODE,
String.format(ExceptionConstants.DEPOT_HEAD_DEPOSIT_OVER_PRE_MSG));
}
}
try{
depotHeadMapper.insertSelective(depotHead);
}catch(Exception e){
@@ -818,6 +829,16 @@ public class DepotHeadService {
}
depotHead.setAccountMoneyList(accountMoneyList);
}
//校验累计扣除订金是否超出订单中的金额
if(depotHead.getDeposit()!=null && StringUtil.isNotEmpty(depotHead.getLinkNumber())) {
BigDecimal finishDeposit = depotHeadMapperEx.getFinishDepositByNumberExceptCurrent(depotHead.getLinkNumber(), depotHead.getNumber());
//订单中的订金金额
BigDecimal preDeposit = getDepotHead(depotHead.getLinkNumber()).getChangeAmount().abs();
if(depotHead.getDeposit().add(finishDeposit).compareTo(preDeposit)>0) {
throw new BusinessRunTimeException(ExceptionConstants.DEPOT_HEAD_DEPOSIT_OVER_PRE_CODE,
String.format(ExceptionConstants.DEPOT_HEAD_DEPOSIT_OVER_PRE_MSG));
}
}
try{
depotHeadMapper.updateByPrimaryKeySelective(depotHead);
}catch(Exception e){

View File

@@ -414,8 +414,6 @@ public class DepotItemService {
}
}
if (StringUtil.isExist(rowObj.get("batchNumber"))) {
//校验录入的批号是否重复
checkBatchNumberIsExist(depotHead.getType(), depotHead.getSubType(), materialExtend.getId(), rowObj.getString("batchNumber"), barCode);
depotItem.setBatchNumber(rowObj.getString("batchNumber"));
} else {
//批号不能为空
@@ -573,27 +571,6 @@ public class DepotItemService {
String.format(ExceptionConstants.DEPOT_HEAD_ROW_FAILED_MSG));
}
}
/**
* 校验录入的批号是否重复
* @param type
* @param subType
* @param meId
* @param batchNumber
* @param barCode
*/
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public void checkBatchNumberIsExist(String type, String subType, Long meId, String batchNumber, String barCode) {
if ((BusinessConstants.SUB_TYPE_PURCHASE.equals(subType) ||
BusinessConstants.SUB_TYPE_OTHER.equals(subType) ||
BusinessConstants.SUB_TYPE_SALES_RETURN.equals(subType)) &&
BusinessConstants.DEPOTHEAD_TYPE_IN.equals(type)) {
Long bnCount = depotItemMapperEx.getCountByMaterialAndBatchNumber(meId, batchNumber);
if (bnCount > 0) {
throw new BusinessRunTimeException(ExceptionConstants.DEPOT_HEAD_BATCH_NUMBERE_EXISTS_CODE,
String.format(ExceptionConstants.DEPOT_HEAD_BATCH_NUMBERE_EXISTS_MSG, barCode));
}
}
}
/**
* 判断单据的状态
* 通过数组对比:原单据的商品和商品数量(汇总) 与 分批操作后单据的商品和商品数量(汇总)

View File

@@ -424,8 +424,10 @@ public class SerialNumberService {
serialNumber.setInBillNo(inBillNo);
serialNumberMapper.insertSelective(serialNumber);
} else {
throw new BusinessRunTimeException(ExceptionConstants.SERIAL_NUMBERE_ALREADY_EXISTS_CODE,
String.format(ExceptionConstants.SERIAL_NUMBERE_ALREADY_EXISTS_MSG, sn));
if(!inBillNo.equals(list.get(0).getInBillNo())) {
throw new BusinessRunTimeException(ExceptionConstants.SERIAL_NUMBERE_ALREADY_EXISTS_CODE,
String.format(ExceptionConstants.SERIAL_NUMBERE_ALREADY_EXISTS_MSG, sn));
}
}
}
}