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

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

@@ -376,9 +376,12 @@ public class ExceptionConstants {
//单据录入-商品的批号不能为空
public static final int DEPOT_HEAD_BATCH_NUMBERE_EMPTY_CODE = 8000015;
public static final String DEPOT_HEAD_BATCH_NUMBERE_EMPTY_MSG = "抱歉,商品条码:%s的批号不能为空";
//单据录入-商品的批号重复
public static final int DEPOT_HEAD_BATCH_NUMBERE_EXISTS_CODE = 8000016;
public static final String DEPOT_HEAD_BATCH_NUMBERE_EXISTS_MSG = "抱歉,商品条码:%s的批号已存在";
//单据录入-会员预付款余额不足
public static final int DEPOT_HEAD_MEMBER_PAY_LACK_CODE = 8000016;
public static final String DEPOT_HEAD_MEMBER_PAY_LACK_MSG = "抱歉,会员预付款余额不足";
//单据录入-累计订金超出原订单中的订金
public static final int DEPOT_HEAD_DEPOSIT_OVER_PRE_CODE = 8000017;
public static final String DEPOT_HEAD_DEPOSIT_OVER_PRE_MSG = "抱歉,累计订金超出原订单中的订金";
/**
* 单据明细信息
* type = 90

View File

@@ -118,6 +118,8 @@ public class AccountController {
JSONArray dataArray = new JSONArray();
if (null != dataList) {
for (AccountVo4InOutList aEx : dataList) {
String type = aEx.getType().replace("其它", "");
aEx.setType(type);
String timeStr = aEx.getOperTime().toString();
BigDecimal balance = accountService.getAccountSum(accountId, timeStr, "date").add(accountService.getAccountSumByHead(accountId, timeStr, "date"))
.add(accountService.getAccountSumByDetail(accountId, timeStr, "date")).add(accountService.getManyAccountSum(accountId, timeStr, "date")).add(initialAmount);

View File

@@ -52,6 +52,8 @@ public class DepotHead {
private BigDecimal otherMoney;
private BigDecimal deposit;
private String status;
private String purchaseStatus;
@@ -254,6 +256,14 @@ public class DepotHead {
this.otherMoney = otherMoney;
}
public BigDecimal getDeposit() {
return deposit;
}
public void setDeposit(BigDecimal deposit) {
this.deposit = deposit;
}
public String getStatus() {
return status;
}

View File

@@ -1656,6 +1656,66 @@ public class DepotHeadExample {
return (Criteria) this;
}
public Criteria andDepositIsNull() {
addCriterion("deposit is null");
return (Criteria) this;
}
public Criteria andDepositIsNotNull() {
addCriterion("deposit is not null");
return (Criteria) this;
}
public Criteria andDepositEqualTo(BigDecimal value) {
addCriterion("deposit =", value, "deposit");
return (Criteria) this;
}
public Criteria andDepositNotEqualTo(BigDecimal value) {
addCriterion("deposit <>", value, "deposit");
return (Criteria) this;
}
public Criteria andDepositGreaterThan(BigDecimal value) {
addCriterion("deposit >", value, "deposit");
return (Criteria) this;
}
public Criteria andDepositGreaterThanOrEqualTo(BigDecimal value) {
addCriterion("deposit >=", value, "deposit");
return (Criteria) this;
}
public Criteria andDepositLessThan(BigDecimal value) {
addCriterion("deposit <", value, "deposit");
return (Criteria) this;
}
public Criteria andDepositLessThanOrEqualTo(BigDecimal value) {
addCriterion("deposit <=", value, "deposit");
return (Criteria) this;
}
public Criteria andDepositIn(List<BigDecimal> values) {
addCriterion("deposit in", values, "deposit");
return (Criteria) this;
}
public Criteria andDepositNotIn(List<BigDecimal> values) {
addCriterion("deposit not in", values, "deposit");
return (Criteria) this;
}
public Criteria andDepositBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("deposit between", value1, value2, "deposit");
return (Criteria) this;
}
public Criteria andDepositNotBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("deposit not between", value1, value2, "deposit");
return (Criteria) this;
}
public Criteria andStatusIsNull() {
addCriterion("status is null");
return (Criteria) this;

View File

@@ -181,4 +181,11 @@ public interface DepotHeadMapperEx {
@Param("endTime") String endTime,
@Param("materialParam") String materialParam,
@Param("depotArray") String[] depotArray);
BigDecimal getFinishDepositByNumber(
@Param("number") String number);
BigDecimal getFinishDepositByNumberExceptCurrent(
@Param("linkNumber") String linkNumber,
@Param("number") String number);
}

View File

@@ -35,6 +35,8 @@ public class DepotHeadVo4List extends DepotHead{
private String address;
private BigDecimal finishDeposit;
public String getProjectName() {
return projectName;
}
@@ -146,4 +148,12 @@ public class DepotHeadVo4List extends DepotHead{
public void setAddress(String address) {
this.address = address;
}
public BigDecimal getFinishDeposit() {
return finishDeposit;
}
public void setFinishDeposit(BigDecimal finishDeposit) {
this.finishDeposit = finishDeposit;
}
}

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));
}
}
}
}

View File

@@ -26,6 +26,7 @@
<result column="discount_money" jdbcType="DECIMAL" property="discountMoney" />
<result column="discount_last_money" jdbcType="DECIMAL" property="discountLastMoney" />
<result column="other_money" jdbcType="DECIMAL" property="otherMoney" />
<result column="deposit" jdbcType="DECIMAL" property="deposit" />
<result column="status" jdbcType="VARCHAR" property="status" />
<result column="purchase_status" jdbcType="VARCHAR" property="purchaseStatus" />
<result column="link_number" jdbcType="VARCHAR" property="linkNumber" />
@@ -94,8 +95,8 @@
id, type, sub_type, default_number, number, create_time, oper_time, organ_id, creator,
account_id, change_amount, back_amount, total_price, pay_type, bill_type, remark,
file_name, sales_man, account_id_list, account_money_list, discount, discount_money,
discount_last_money, other_money, status, purchase_status, link_number, tenant_id,
delete_flag
discount_last_money, other_money, deposit, status, purchase_status, link_number,
tenant_id, delete_flag
</sql>
<select id="selectByExample" parameterType="com.jsh.erp.datasource.entities.DepotHeadExample" resultMap="BaseResultMap">
select
@@ -136,8 +137,9 @@
remark, file_name, sales_man,
account_id_list, account_money_list, discount,
discount_money, discount_last_money, other_money,
status, purchase_status, link_number,
tenant_id, delete_flag)
deposit, status, purchase_status,
link_number, tenant_id, delete_flag
)
values (#{id,jdbcType=BIGINT}, #{type,jdbcType=VARCHAR}, #{subType,jdbcType=VARCHAR},
#{defaultNumber,jdbcType=VARCHAR}, #{number,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
#{operTime,jdbcType=TIMESTAMP}, #{organId,jdbcType=BIGINT}, #{creator,jdbcType=BIGINT},
@@ -146,8 +148,9 @@
#{remark,jdbcType=VARCHAR}, #{fileName,jdbcType=VARCHAR}, #{salesMan,jdbcType=VARCHAR},
#{accountIdList,jdbcType=VARCHAR}, #{accountMoneyList,jdbcType=VARCHAR}, #{discount,jdbcType=DECIMAL},
#{discountMoney,jdbcType=DECIMAL}, #{discountLastMoney,jdbcType=DECIMAL}, #{otherMoney,jdbcType=DECIMAL},
#{status,jdbcType=VARCHAR}, #{purchaseStatus,jdbcType=VARCHAR}, #{linkNumber,jdbcType=VARCHAR},
#{tenantId,jdbcType=BIGINT}, #{deleteFlag,jdbcType=VARCHAR})
#{deposit,jdbcType=DECIMAL}, #{status,jdbcType=VARCHAR}, #{purchaseStatus,jdbcType=VARCHAR},
#{linkNumber,jdbcType=VARCHAR}, #{tenantId,jdbcType=BIGINT}, #{deleteFlag,jdbcType=VARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="com.jsh.erp.datasource.entities.DepotHead">
insert into jsh_depot_head
@@ -224,6 +227,9 @@
<if test="otherMoney != null">
other_money,
</if>
<if test="deposit != null">
deposit,
</if>
<if test="status != null">
status,
</if>
@@ -313,6 +319,9 @@
<if test="otherMoney != null">
#{otherMoney,jdbcType=DECIMAL},
</if>
<if test="deposit != null">
#{deposit,jdbcType=DECIMAL},
</if>
<if test="status != null">
#{status,jdbcType=VARCHAR},
</if>
@@ -411,6 +420,9 @@
<if test="record.otherMoney != null">
other_money = #{record.otherMoney,jdbcType=DECIMAL},
</if>
<if test="record.deposit != null">
deposit = #{record.deposit,jdbcType=DECIMAL},
</if>
<if test="record.status != null">
status = #{record.status,jdbcType=VARCHAR},
</if>
@@ -457,6 +469,7 @@
discount_money = #{record.discountMoney,jdbcType=DECIMAL},
discount_last_money = #{record.discountLastMoney,jdbcType=DECIMAL},
other_money = #{record.otherMoney,jdbcType=DECIMAL},
deposit = #{record.deposit,jdbcType=DECIMAL},
status = #{record.status,jdbcType=VARCHAR},
purchase_status = #{record.purchaseStatus,jdbcType=VARCHAR},
link_number = #{record.linkNumber,jdbcType=VARCHAR},
@@ -538,6 +551,9 @@
<if test="otherMoney != null">
other_money = #{otherMoney,jdbcType=DECIMAL},
</if>
<if test="deposit != null">
deposit = #{deposit,jdbcType=DECIMAL},
</if>
<if test="status != null">
status = #{status,jdbcType=VARCHAR},
</if>
@@ -581,6 +597,7 @@
discount_money = #{discountMoney,jdbcType=DECIMAL},
discount_last_money = #{discountLastMoney,jdbcType=DECIMAL},
other_money = #{otherMoney,jdbcType=DECIMAL},
deposit = #{deposit,jdbcType=DECIMAL},
status = #{status,jdbcType=VARCHAR},
purchase_status = #{purchaseStatus,jdbcType=VARCHAR},
link_number = #{linkNumber,jdbcType=VARCHAR},

View File

@@ -680,8 +680,23 @@
)
</if>
and (abs(dh.change_amount)+(select ifnull(sum(abs(ai.each_amount)),0) from jsh_account_item ai where ai.bill_id=dh.id and ifnull(ai.delete_flag,'0') !='1'))
&lt; (dh.discount_last_money + dh.other_money)
&lt; (dh.discount_last_money + dh.other_money - ifnull(dh.deposit,0))
and ifnull(dh.delete_flag,'0') !='1'
order by dh.id desc
</select>
<select id="getFinishDepositByNumber" resultType="java.math.BigDecimal">
select ifnull(sum(dh.deposit),0)
from jsh_depot_head dh
where dh.link_number=#{number}
and ifnull(dh.delete_flag,'0') !='1'
</select>
<select id="getFinishDepositByNumberExceptCurrent" resultType="java.math.BigDecimal">
select ifnull(sum(dh.deposit),0)
from jsh_depot_head dh
where dh.link_number=#{linkNumber}
and dh.number!=#{number}
and ifnull(dh.delete_flag,'0') !='1'
</select>
</mapper>