|
|
@@ -241,10 +241,35 @@ public class WxFinanceServiceImpl implements WxFinanceService { |
|
|
payway4.setCreateTime(new Date()); |
|
|
payway4.setCreateTime(new Date()); |
|
|
payway4.setUpdateTime(new Date()); |
|
|
payway4.setUpdateTime(new Date()); |
|
|
wxBillPayWayMapper.insert(payway4); |
|
|
wxBillPayWayMapper.insert(payway4); |
|
|
|
|
|
|
|
|
|
|
|
WxBillPayWay payway5 = new WxBillPayWay(); |
|
|
|
|
|
payway5.updateTenantInfo(tenantInfo); |
|
|
|
|
|
payway5.setId(Constant.bill_pay_way_deposit_setoff); |
|
|
|
|
|
payway5.setName("押金抵扣"); |
|
|
|
|
|
payway5.setIsDel(EnumYesOrNo.NO.getCode()); |
|
|
|
|
|
payway5.setIsSystem(EnumYesOrNo.YES.getCode()); |
|
|
|
|
|
payway5.setCreateTime(new Date()); |
|
|
|
|
|
payway5.setUpdateTime(new Date()); |
|
|
|
|
|
wxBillPayWayMapper.insert(payway5); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public FinanceBillSetoffSum getBillSetoffSum(WxShop record) { |
|
|
|
|
|
|
|
|
public BigDecimal getBillDepositSum(WxShop record) { |
|
|
|
|
|
//取账单里面的 |
|
|
|
|
|
//查询预存账单 |
|
|
|
|
|
WxAllBill abq = new WxAllBill(); |
|
|
|
|
|
abq.updateTenantInfo(record); |
|
|
|
|
|
abq.setShopId(record.getId()); |
|
|
|
|
|
abq.setDepositHasMoney(EnumYesOrNo.YES.getCode()); |
|
|
|
|
|
BigDecimal total = wxAllBillService.getBillDepositSum(abq); |
|
|
|
|
|
if (null == total) { |
|
|
|
|
|
total = new BigDecimal(0); |
|
|
|
|
|
} |
|
|
|
|
|
return total; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public BigDecimal getBillSetoffSum(WxShop record) { |
|
|
//取账单里面的 |
|
|
//取账单里面的 |
|
|
//查询预存账单 |
|
|
//查询预存账单 |
|
|
WxAllBill abq = new WxAllBill(); |
|
|
WxAllBill abq = new WxAllBill(); |
|
|
@@ -252,10 +277,34 @@ public class WxFinanceServiceImpl implements WxFinanceService { |
|
|
abq.setBillType(EnumBillAllType.ADVANCE.getCode()); |
|
|
abq.setBillType(EnumBillAllType.ADVANCE.getCode()); |
|
|
abq.setShopId(record.getId()); |
|
|
abq.setShopId(record.getId()); |
|
|
abq.setAdvanceHasMoney(EnumYesOrNo.YES.getCode()); |
|
|
abq.setAdvanceHasMoney(EnumYesOrNo.YES.getCode()); |
|
|
List<WxAllBill> advanceList = wxBillAllHelper.getMerchantAdvanceGroupSumList(abq); |
|
|
|
|
|
BigDecimal total = new BigDecimal(0); |
|
|
|
|
|
FinanceBillSetoffSum retMap = new FinanceBillSetoffSum(); |
|
|
|
|
|
List<FinanceAdvanceBillVo> bvolist = new ArrayList<FinanceAdvanceBillVo>(); |
|
|
|
|
|
|
|
|
BigDecimal total = wxAllBillService.getBillSetoffSum(abq); |
|
|
|
|
|
if (null == total) { |
|
|
|
|
|
total = new BigDecimal(0); |
|
|
|
|
|
} |
|
|
|
|
|
return total; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public List<FinanceAdvanceBillVo> getMerchantAdvanceDepositList(WxShop record) { |
|
|
|
|
|
//取账单里面的 |
|
|
|
|
|
List<FinanceAdvanceBillVo> bvolist = new ArrayList<FinanceAdvanceBillVo>(); |
|
|
|
|
|
//查询所有押金 |
|
|
|
|
|
BigDecimal deposit = getBillDepositSum(record); |
|
|
|
|
|
if (null != deposit && deposit.compareTo(new BigDecimal(0)) > 0 ) { |
|
|
|
|
|
FinanceAdvanceBillVo v0 = new FinanceAdvanceBillVo(); |
|
|
|
|
|
v0.setFeesId(Constant.bill_all_deposit_id); |
|
|
|
|
|
v0.setFeesName("押金总计"); |
|
|
|
|
|
v0.setRemain(deposit.toPlainString()); |
|
|
|
|
|
bvolist.add(v0); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//查询预存账单 |
|
|
|
|
|
WxAllBill abq = new WxAllBill(); |
|
|
|
|
|
abq.updateTenantInfo(record); |
|
|
|
|
|
abq.setBillType(EnumBillAllType.ADVANCE.getCode()); |
|
|
|
|
|
abq.setShopId(record.getId()); |
|
|
|
|
|
abq.setAdvanceHasMoney(EnumYesOrNo.YES.getCode()); |
|
|
|
|
|
List<WxAllBill> advanceList = wxAllBillService.getMerchantAdvanceGroupSumList(abq); |
|
|
if (null != advanceList && advanceList.size() > 0 ) { |
|
|
if (null != advanceList && advanceList.size() > 0 ) { |
|
|
WxEnergyFees fat = new WxEnergyFees(); |
|
|
WxEnergyFees fat = new WxEnergyFees(); |
|
|
fat.updateTenantInfo(record); |
|
|
fat.updateTenantInfo(record); |
|
|
@@ -271,13 +320,10 @@ public class WxFinanceServiceImpl implements WxFinanceService { |
|
|
vo.setFeesName(wfat.getName()); |
|
|
vo.setFeesName(wfat.getName()); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
total = total.add(new BigDecimal(at.getRemain())); |
|
|
|
|
|
bvolist.add(vo); |
|
|
bvolist.add(vo); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
retMap.setTotal(total); |
|
|
|
|
|
retMap.setAdvanceList(bvolist); |
|
|
|
|
|
return retMap; |
|
|
|
|
|
|
|
|
return bvolist; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//根据预充值收款单来冲抵账单 |
|
|
//根据预充值收款单来冲抵账单 |
|
|
@@ -347,17 +393,10 @@ public class WxFinanceServiceImpl implements WxFinanceService { |
|
|
if (null == dto.getBills() || dto.getBills().size() <= 0 || null == dto.getFeesId()) { |
|
|
if (null == dto.getBills() || dto.getBills().size() <= 0 || null == dto.getFeesId()) { |
|
|
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"请选择账单和抵扣科目"); |
|
|
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"请选择账单和抵扣科目"); |
|
|
} |
|
|
} |
|
|
//查询预收科目可冲抵的科目 |
|
|
|
|
|
WxEnergyFeesSetoff fsq = new WxEnergyFeesSetoff(); |
|
|
|
|
|
fsq.updateTenantInfo(dto); |
|
|
|
|
|
fsq.setAdvanceFeesId(dto.getFeesId()); |
|
|
|
|
|
List<Long> setOffFeesIds = wxEnergyService.getAdvanceSetoffFeesids(fsq); |
|
|
|
|
|
if (null == setOffFeesIds || setOffFeesIds.size() <= 0 ) { |
|
|
|
|
|
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"该科目未设置可冲抵科目"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//查询出账单可以抵扣的科目预收项 |
|
|
|
|
|
|
|
|
//如果是多个店铺的则不能冲抵 |
|
|
Long shopId = null; |
|
|
Long shopId = null; |
|
|
|
|
|
List<Long> billIdList = new ArrayList<Long>(); |
|
|
for (int i = 0 ; i < dto.getBills().size() ; i ++) { |
|
|
for (int i = 0 ; i < dto.getBills().size() ; i ++) { |
|
|
WxAllBill be = dto.getBills().get(i); |
|
|
WxAllBill be = dto.getBills().get(i); |
|
|
if (null == shopId) { |
|
|
if (null == shopId) { |
|
|
@@ -366,18 +405,57 @@ public class WxFinanceServiceImpl implements WxFinanceService { |
|
|
if (shopId.longValue() != be.getShopId().longValue()) { |
|
|
if (shopId.longValue() != be.getShopId().longValue()) { |
|
|
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"多个房源合并收款不能冲抵"); |
|
|
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"多个房源合并收款不能冲抵"); |
|
|
} |
|
|
} |
|
|
|
|
|
billIdList.add(be.getId()); |
|
|
} |
|
|
} |
|
|
WxAllBill abq = new WxAllBill(); |
|
|
|
|
|
abq.updateTenantInfo(dto); |
|
|
|
|
|
abq.setEnergyFeesId(dto.getFeesId()); |
|
|
|
|
|
abq.setBillType(EnumBillAllType.ADVANCE.getCode()); |
|
|
|
|
|
abq.setAdvanceHasMoney(EnumYesOrNo.YES.getCode()); |
|
|
|
|
|
abq.setSortColumns(SortField.Createtime_ASC); |
|
|
|
|
|
//如果是多个店铺的则不能冲抵 |
|
|
|
|
|
abq.setShopId(shopId);; |
|
|
|
|
|
List<WxAllBill> advanceList = wxAllBillService.list(abq); |
|
|
|
|
|
if (null == advanceList || advanceList.size() <= 0 ) { |
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<Long> setOffFeesIds = null; |
|
|
|
|
|
List<WxAllBill> advanceList = null; |
|
|
|
|
|
//如果是押金 |
|
|
|
|
|
if (dto.getFeesId().longValue() == Constant.bill_all_deposit_id.longValue()){ |
|
|
|
|
|
WxEnergyFees fq = new WxEnergyFees(); |
|
|
|
|
|
fq.updateTenantInfo(dto); |
|
|
|
|
|
List<Integer> depositTypes = new ArrayList<Integer>(); |
|
|
|
|
|
depositTypes.add(EnumBillAllType.RENT_DEPOSIT.getCode()); |
|
|
|
|
|
depositTypes.add(EnumBillAllType.PROPERTY_DEPOSIT.getCode()); |
|
|
|
|
|
depositTypes.add(EnumBillAllType.OTHER_DEPOSIT.getCode()); |
|
|
|
|
|
fq.setBillTypeList(depositTypes); |
|
|
|
|
|
setOffFeesIds = wxEnergyService.getFeesIdList(fq); |
|
|
|
|
|
if (null == setOffFeesIds || setOffFeesIds.size() <= 0 ) { |
|
|
|
|
|
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"未查询到押金科目"); |
|
|
|
|
|
} |
|
|
|
|
|
//查询出账单可以抵扣的押金项 |
|
|
|
|
|
WxAllBill abq = new WxAllBill(); |
|
|
|
|
|
abq.updateTenantInfo(dto); |
|
|
|
|
|
abq.setNotInIds(billIdList); |
|
|
|
|
|
abq.setDepositHasMoney(EnumYesOrNo.YES.getCode()); |
|
|
|
|
|
abq.setSortColumns(SortField.Createtime_ASC); |
|
|
|
|
|
abq.setShopId(shopId);; |
|
|
|
|
|
advanceList = wxAllBillService.list(abq); |
|
|
|
|
|
if (null == advanceList || advanceList.size() <= 0 ) { |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
|
|
|
}else { |
|
|
|
|
|
//查询预收科目可冲抵的科目 |
|
|
|
|
|
WxEnergyFeesSetoff fsq = new WxEnergyFeesSetoff(); |
|
|
|
|
|
fsq.updateTenantInfo(dto); |
|
|
|
|
|
fsq.setAdvanceFeesId(dto.getFeesId()); |
|
|
|
|
|
setOffFeesIds = wxEnergyService.getAdvanceSetoffFeesids(fsq); |
|
|
|
|
|
if (null == setOffFeesIds || setOffFeesIds.size() <= 0 ) { |
|
|
|
|
|
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"该科目未设置可冲抵科目"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//查询出账单可以抵扣的科目预收项 |
|
|
|
|
|
WxAllBill abq = new WxAllBill(); |
|
|
|
|
|
abq.updateTenantInfo(dto); |
|
|
|
|
|
abq.setEnergyFeesId(dto.getFeesId()); |
|
|
|
|
|
abq.setBillType(EnumBillAllType.ADVANCE.getCode()); |
|
|
|
|
|
abq.setAdvanceHasMoney(EnumYesOrNo.YES.getCode()); |
|
|
|
|
|
abq.setSortColumns(SortField.Createtime_ASC); |
|
|
|
|
|
abq.setShopId(shopId);; |
|
|
|
|
|
advanceList = wxAllBillService.list(abq); |
|
|
|
|
|
if (null == advanceList || advanceList.size() <= 0 ) { |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
//账单排序 |
|
|
//账单排序 |
|
|
List<WxAllBill> bills = dto.getBills(); |
|
|
List<WxAllBill> bills = dto.getBills(); |
|
|
@@ -407,6 +485,7 @@ public class WxFinanceServiceImpl implements WxFinanceService { |
|
|
retList.add(retb); |
|
|
retList.add(retb); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return retList; |
|
|
return retList; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@@ -681,11 +760,7 @@ public class WxFinanceServiceImpl implements WxFinanceService { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//TODO 校验金额+减免是不是超过了应收费用 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//冲抵总金额 |
|
|
|
|
|
|
|
|
//已冲抵总金额 |
|
|
BigDecimal setOffTotal = new BigDecimal(0); |
|
|
BigDecimal setOffTotal = new BigDecimal(0); |
|
|
List<WxAllBill> bills = record.getBills(); |
|
|
List<WxAllBill> bills = record.getBills(); |
|
|
sortBills(bills); |
|
|
sortBills(bills); |
|
|
@@ -702,6 +777,7 @@ public class WxFinanceServiceImpl implements WxFinanceService { |
|
|
calcuteDto.setTotalRemainReceive(receiveTotal); |
|
|
calcuteDto.setTotalRemainReceive(receiveTotal); |
|
|
calcuteDto.setTotalSetoff(setOffTotal); |
|
|
calcuteDto.setTotalSetoff(setOffTotal); |
|
|
calcuteDto.setTotalCut(new BigDecimal(0)); |
|
|
calcuteDto.setTotalCut(new BigDecimal(0)); |
|
|
|
|
|
calcuteDto.setTotalNeedPay(new BigDecimal(0)); |
|
|
//建立子账单关联单 |
|
|
//建立子账单关联单 |
|
|
List<Long> shopIdList = new ArrayList<Long>(); |
|
|
List<Long> shopIdList = new ArrayList<Long>(); |
|
|
StringBuffer shopnumberSb = new StringBuffer(); |
|
|
StringBuffer shopnumberSb = new StringBuffer(); |
|
|
@@ -723,9 +799,17 @@ public class WxFinanceServiceImpl implements WxFinanceService { |
|
|
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"请收款或者冲抵"); |
|
|
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"请收款或者冲抵"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
BigDecimal allHandleMoney = receiveTotal.add(new BigDecimal(0)); |
|
|
if (null != calcuteDto.getTotalSetoff()) { |
|
|
if (null != calcuteDto.getTotalSetoff()) { |
|
|
addreceive.setSetOffMoney(calcuteDto.getTotalSetoff().toPlainString()); |
|
|
addreceive.setSetOffMoney(calcuteDto.getTotalSetoff().toPlainString()); |
|
|
|
|
|
allHandleMoney.add(calcuteDto.getTotalSetoff()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//校验金额+冲抵是不是超过了应收费用 |
|
|
|
|
|
if (calcuteDto.getTotalNeedPay().compareTo(allHandleMoney) < 0 ){ |
|
|
|
|
|
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"实际收款和冲抵之和不能超过应收总金额"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
addreceive.setBillCusName(billCusSb.toString()); |
|
|
addreceive.setBillCusName(billCusSb.toString()); |
|
|
addreceive.setBillShopNumber(shopnumberSb.toString()); |
|
|
addreceive.setBillShopNumber(shopnumberSb.toString()); |
|
|
addreceive.setRemark(record.getRemark()); |
|
|
addreceive.setRemark(record.getRemark()); |
|
|
@@ -771,7 +855,10 @@ public class WxFinanceServiceImpl implements WxFinanceService { |
|
|
//计算账单收款费用,更新账单收款 |
|
|
//计算账单收款费用,更新账单收款 |
|
|
BigDecimal b0 = new BigDecimal(0); |
|
|
BigDecimal b0 = new BigDecimal(0); |
|
|
WxAllBill bill = wxBillAllHelper.getBillDetail(addreceive, be.getId()); |
|
|
WxAllBill bill = wxBillAllHelper.getBillDetail(addreceive, be.getId()); |
|
|
|
|
|
boolean billIsHandled = false; |
|
|
|
|
|
BigDecimal billOldOweDecimal = new BigDecimal(bill.getOwe()); |
|
|
if (calcuteDto.getTotalRemainReceive().compareTo(b0) > 0) { |
|
|
if (calcuteDto.getTotalRemainReceive().compareTo(b0) > 0) { |
|
|
|
|
|
billIsHandled = true; |
|
|
noNeedCreate = false; |
|
|
noNeedCreate = false; |
|
|
//有收款,就要更新账单的收款 |
|
|
//有收款,就要更新账单的收款 |
|
|
//更新账单收款信息 |
|
|
//更新账单收款信息 |
|
|
@@ -815,9 +902,7 @@ public class WxFinanceServiceImpl implements WxFinanceService { |
|
|
if(StringUtils.isNotBlank(be.getCurrentSetOff())) { |
|
|
if(StringUtils.isNotBlank(be.getCurrentSetOff())) { |
|
|
calcuteDto.setTotalSetoff(calcuteDto.getTotalSetoff().add(new BigDecimal(be.getCurrentSetOff()))); |
|
|
calcuteDto.setTotalSetoff(calcuteDto.getTotalSetoff().add(new BigDecimal(be.getCurrentSetOff()))); |
|
|
payDto.setSetOff(be.getCurrentSetOff()); |
|
|
payDto.setSetOff(be.getCurrentSetOff()); |
|
|
//创建一个冲抵收款单 |
|
|
|
|
|
createFinanceReceiveBill(addreceive,bill,be.getCurrentSetOff(),null,Constant.bill_pay_way_setoff); |
|
|
|
|
|
//处理关联抵扣的预收单 |
|
|
|
|
|
|
|
|
//押金冲抵和预收冲抵要分开建收款单 |
|
|
createFinanceReceiveSetoff(addreceive,be,bill); |
|
|
createFinanceReceiveSetoff(addreceive,be,bill); |
|
|
} |
|
|
} |
|
|
//有减免 |
|
|
//有减免 |
|
|
@@ -829,11 +914,10 @@ public class WxFinanceServiceImpl implements WxFinanceService { |
|
|
wxBillAllHelper.updatePay(payDto, user); |
|
|
wxBillAllHelper.updatePay(payDto, user); |
|
|
|
|
|
|
|
|
}else if (StringUtils.isNotBlank(be.getCurrentSetOff())) { |
|
|
}else if (StringUtils.isNotBlank(be.getCurrentSetOff())) { |
|
|
|
|
|
billIsHandled = true; |
|
|
noNeedCreate = false; |
|
|
noNeedCreate = false; |
|
|
calcuteDto.setTotalSetoff(calcuteDto.getTotalSetoff().add(new BigDecimal(be.getCurrentSetOff()))); |
|
|
calcuteDto.setTotalSetoff(calcuteDto.getTotalSetoff().add(new BigDecimal(be.getCurrentSetOff()))); |
|
|
//没收款,有冲抵,就要更新账单的冲抵,然后把对应的预充值使用金额更新,并进行关联 |
|
|
//没收款,有冲抵,就要更新账单的冲抵,然后把对应的预充值使用金额更新,并进行关联 |
|
|
//创建一个冲抵收款单 |
|
|
|
|
|
createFinanceReceiveBill(addreceive,bill,be.getCurrentSetOff(),null,Constant.bill_pay_way_setoff); |
|
|
|
|
|
//处理预充关联 |
|
|
//处理预充关联 |
|
|
createFinanceReceiveSetoff(addreceive,be,bill); |
|
|
createFinanceReceiveSetoff(addreceive,be,bill); |
|
|
|
|
|
|
|
|
@@ -856,6 +940,9 @@ public class WxFinanceServiceImpl implements WxFinanceService { |
|
|
payDto.setRemark("收款单收款["+addreceive.getId()+"]冲抵"+addreceive.getRemark()); |
|
|
payDto.setRemark("收款单收款["+addreceive.getId()+"]冲抵"+addreceive.getRemark()); |
|
|
wxBillAllHelper.updatePay(payDto, user); |
|
|
wxBillAllHelper.updatePay(payDto, user); |
|
|
} |
|
|
} |
|
|
|
|
|
if (billIsHandled) { |
|
|
|
|
|
calcuteDto.setTotalNeedPay(calcuteDto.getTotalNeedPay().add(billOldOweDecimal)); |
|
|
|
|
|
} |
|
|
return noNeedCreate; |
|
|
return noNeedCreate; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@@ -904,9 +991,30 @@ public class WxFinanceServiceImpl implements WxFinanceService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void createFinanceReceiveSetoff(WxFinanceReceive addreceive,WxAllBill be,WxAllBill bill) { |
|
|
public void createFinanceReceiveSetoff(WxFinanceReceive addreceive,WxAllBill be,WxAllBill bill) { |
|
|
|
|
|
BigDecimal advanceMoney = new BigDecimal(0); |
|
|
|
|
|
BigDecimal depositMoney = new BigDecimal(0); |
|
|
for (int j = 0 ; j < be.getSetOffDetailList().size(); j ++ ) { |
|
|
for (int j = 0 ; j < be.getSetOffDetailList().size(); j ++ ) { |
|
|
FinanceSetOffDetailVo setoffdetail = be.getSetOffDetailList().get(j); |
|
|
FinanceSetOffDetailVo setoffdetail = be.getSetOffDetailList().get(j); |
|
|
WxAllBill advance = wxAllBillService.getById(addreceive, setoffdetail.getAdvanceId()); |
|
|
WxAllBill advance = wxAllBillService.getById(addreceive, setoffdetail.getAdvanceId()); |
|
|
|
|
|
EnumBillAllType billType = EnumBillAllType.getEnum(advance.getBillType()); |
|
|
|
|
|
|
|
|
|
|
|
//如果是预冲 |
|
|
|
|
|
if (billType == EnumBillAllType.ADVANCE){ |
|
|
|
|
|
advanceMoney = advanceMoney.add(new BigDecimal(setoffdetail.getSetoff())); |
|
|
|
|
|
}else { |
|
|
|
|
|
//如果是押金 |
|
|
|
|
|
boolean isDeposit = false; |
|
|
|
|
|
for (EnumBillAllType bt : EnumBillAllType.getDepositTypes()) { |
|
|
|
|
|
if (bt == billType) { |
|
|
|
|
|
isDeposit = true; |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (isDeposit) { |
|
|
|
|
|
depositMoney = depositMoney.add(new BigDecimal(setoffdetail.getSetoff())); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
advance.setUseMoney(new BigDecimal(advance.getUseMoney()).add(new BigDecimal(setoffdetail.getSetoff())).toPlainString()); |
|
|
advance.setUseMoney(new BigDecimal(advance.getUseMoney()).add(new BigDecimal(setoffdetail.getSetoff())).toPlainString()); |
|
|
advance.setUpdatetime(new Date()); |
|
|
advance.setUpdatetime(new Date()); |
|
|
wxAllBillService.saveOrUpdate(advance, null); |
|
|
wxAllBillService.saveOrUpdate(advance, null); |
|
|
@@ -926,6 +1034,14 @@ public class WxFinanceServiceImpl implements WxFinanceService { |
|
|
rb.setCreateTime(new Date()); |
|
|
rb.setCreateTime(new Date()); |
|
|
rb.setUpdateTime(new Date()); |
|
|
rb.setUpdateTime(new Date()); |
|
|
wxFinanceReceiveSetoffMapper.insert(rb); |
|
|
wxFinanceReceiveSetoffMapper.insert(rb); |
|
|
|
|
|
|
|
|
|
|
|
//创建一个冲抵收款单 |
|
|
|
|
|
if (advanceMoney.compareTo(new BigDecimal(0)) > 0 ) { |
|
|
|
|
|
createFinanceReceiveBill(addreceive,bill,be.getCurrentSetOff(),null,Constant.bill_pay_way_setoff); |
|
|
|
|
|
} |
|
|
|
|
|
if (depositMoney.compareTo(new BigDecimal(0)) > 0 ) { |
|
|
|
|
|
createFinanceReceiveBill(addreceive,bill,be.getCurrentSetOff(),null,Constant.bill_pay_way_deposit_setoff); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@@ -1002,6 +1118,7 @@ public class WxFinanceServiceImpl implements WxFinanceService { |
|
|
|
|
|
|
|
|
FinanceReceiveCalcuteDTO calcuteDto = new FinanceReceiveCalcuteDTO(); |
|
|
FinanceReceiveCalcuteDTO calcuteDto = new FinanceReceiveCalcuteDTO(); |
|
|
calcuteDto.setTotalCut(new BigDecimal(0)); |
|
|
calcuteDto.setTotalCut(new BigDecimal(0)); |
|
|
|
|
|
calcuteDto.setTotalNeedPay(new BigDecimal(0)); |
|
|
//建立子账单关联单 |
|
|
//建立子账单关联单 |
|
|
List<Long> shopIdList = new ArrayList<Long>(); |
|
|
List<Long> shopIdList = new ArrayList<Long>(); |
|
|
StringBuffer shopnumberSb = new StringBuffer(); |
|
|
StringBuffer shopnumberSb = new StringBuffer(); |
|
|
@@ -1009,6 +1126,8 @@ public class WxFinanceServiceImpl implements WxFinanceService { |
|
|
for (int i = 0 ; i < record.getBills().size(); i++) { |
|
|
for (int i = 0 ; i < record.getBills().size(); i++) { |
|
|
WxAllBill be = record.getBills().get(i); |
|
|
WxAllBill be = record.getBills().get(i); |
|
|
if(StringUtils.isNotBlank(be.getCurrentCut())) { |
|
|
if(StringUtils.isNotBlank(be.getCurrentCut())) { |
|
|
|
|
|
WxAllBill bill = wxBillAllHelper.getBillDetail(record, be.getId()); |
|
|
|
|
|
calcuteDto.setTotalNeedPay(calcuteDto.getTotalNeedPay().add(new BigDecimal(bill.getOwe()))); |
|
|
WxBillPayDTO payDto = new WxBillPayDTO(); |
|
|
WxBillPayDTO payDto = new WxBillPayDTO(); |
|
|
payDto.updateTenantInfo(addreceive); |
|
|
payDto.updateTenantInfo(addreceive); |
|
|
payDto.setId(be.getId()); |
|
|
payDto.setId(be.getId()); |
|
|
@@ -1031,6 +1150,11 @@ public class WxFinanceServiceImpl implements WxFinanceService { |
|
|
if (isAllEmpity) { |
|
|
if (isAllEmpity) { |
|
|
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"请收款或者冲抵"); |
|
|
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"请收款或者冲抵"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//校验减免是不是超过了应收费用 |
|
|
|
|
|
if (calcuteDto.getTotalNeedPay().compareTo(calcuteDto.getTotalCut()) < 0 ){ |
|
|
|
|
|
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"减免金额之和不能超过应收总金额"); |
|
|
|
|
|
} |
|
|
addreceive.setBillCusName(billCusSb.toString()); |
|
|
addreceive.setBillCusName(billCusSb.toString()); |
|
|
addreceive.setBillShopNumber(shopnumberSb.toString()); |
|
|
addreceive.setBillShopNumber(shopnumberSb.toString()); |
|
|
addreceive.setRemark(record.getRemark()); |
|
|
addreceive.setRemark(record.getRemark()); |
|
|
@@ -1089,6 +1213,7 @@ public class WxFinanceServiceImpl implements WxFinanceService { |
|
|
|
|
|
|
|
|
FinanceReceiveCalcuteDTO calcuteDto = new FinanceReceiveCalcuteDTO(); |
|
|
FinanceReceiveCalcuteDTO calcuteDto = new FinanceReceiveCalcuteDTO(); |
|
|
calcuteDto.setTotalRemainPay(payTotal); |
|
|
calcuteDto.setTotalRemainPay(payTotal); |
|
|
|
|
|
calcuteDto.setTotalNeedPay(new BigDecimal(0)); |
|
|
//建立子账单关联单 |
|
|
//建立子账单关联单 |
|
|
List<Long> shopIdList = new ArrayList<Long>(); |
|
|
List<Long> shopIdList = new ArrayList<Long>(); |
|
|
StringBuffer shopnumberSb = new StringBuffer(); |
|
|
StringBuffer shopnumberSb = new StringBuffer(); |
|
|
@@ -1110,6 +1235,12 @@ public class WxFinanceServiceImpl implements WxFinanceService { |
|
|
if (isAllEmpity) { |
|
|
if (isAllEmpity) { |
|
|
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"请付款"); |
|
|
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"请付款"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//校验金额+冲抵是不是超过了应收费用 |
|
|
|
|
|
if (calcuteDto.getTotalNeedPay().compareTo(payTotal) < 0 ){ |
|
|
|
|
|
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"实际付款之和不能超过应付总金额"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
addreceive.setBillCusName(billCusSb.toString()); |
|
|
addreceive.setBillCusName(billCusSb.toString()); |
|
|
addreceive.setBillShopNumber(shopnumberSb.toString()); |
|
|
addreceive.setBillShopNumber(shopnumberSb.toString()); |
|
|
addreceive.setRemark(record.getRemark()); |
|
|
addreceive.setRemark(record.getRemark()); |
|
|
@@ -1155,8 +1286,11 @@ public class WxFinanceServiceImpl implements WxFinanceService { |
|
|
//计算账单收款费用,更新账单收款 |
|
|
//计算账单收款费用,更新账单收款 |
|
|
BigDecimal b0 = new BigDecimal(0); |
|
|
BigDecimal b0 = new BigDecimal(0); |
|
|
WxAllBill bill = wxBillAllHelper.getBillDetail(addreceive, be.getId()); |
|
|
WxAllBill bill = wxBillAllHelper.getBillDetail(addreceive, be.getId()); |
|
|
|
|
|
boolean billIsHandled = false; |
|
|
|
|
|
BigDecimal billOldOweDecimal = new BigDecimal(bill.getRemainReturnPrice()); |
|
|
if (calcuteDto.getTotalRemainPay().compareTo(b0) > 0) { |
|
|
if (calcuteDto.getTotalRemainPay().compareTo(b0) > 0) { |
|
|
noNeedCreate = false; |
|
|
noNeedCreate = false; |
|
|
|
|
|
billIsHandled = true; |
|
|
//有收款,就要更新账单的收款 |
|
|
//有收款,就要更新账单的收款 |
|
|
//更新账单收款信息 |
|
|
//更新账单收款信息 |
|
|
String money = ""; |
|
|
String money = ""; |
|
|
@@ -1195,8 +1329,11 @@ public class WxFinanceServiceImpl implements WxFinanceService { |
|
|
|
|
|
|
|
|
bill.setCurrentReceive(money); |
|
|
bill.setCurrentReceive(money); |
|
|
wxBillAllHelper.updatePayToMerchant(payDto, user); |
|
|
wxBillAllHelper.updatePayToMerchant(payDto, user); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
if (billIsHandled) { |
|
|
|
|
|
calcuteDto.setTotalNeedPay(calcuteDto.getTotalNeedPay().add(billOldOweDecimal)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return noNeedCreate; |
|
|
return noNeedCreate; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@@ -1279,7 +1416,7 @@ public class WxFinanceServiceImpl implements WxFinanceService { |
|
|
@Override |
|
|
@Override |
|
|
public void delteTemp(WxAllBill record,MallUserInfo user) { |
|
|
public void delteTemp(WxAllBill record,MallUserInfo user) { |
|
|
WxAllBill bill = wxAllBillService.getById(record,record.getId()); |
|
|
WxAllBill bill = wxAllBillService.getById(record,record.getId()); |
|
|
if (bill.getCreateBy() != user.getId()) { |
|
|
|
|
|
|
|
|
if (bill.getCreateBy().longValue() != user.getId().longValue()) { |
|
|
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"只能删除自己创建的账单"); |
|
|
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"只能删除自己创建的账单"); |
|
|
} |
|
|
} |
|
|
if (bill.getCanEdit() == EnumYesOrNo.YES.getCode()) { |
|
|
if (bill.getCanEdit() == EnumYesOrNo.YES.getCode()) { |
|
|
|