|
|
|
@@ -8,6 +8,7 @@ import com.iformall.common.ErrorCode; |
|
|
|
import com.iformall.common.IdWorker; |
|
|
|
import com.iformall.common.Result; |
|
|
|
import com.iformall.common.ResultData; |
|
|
|
import com.iformall.domain.dto.FinanceSetOffCalcuteDTO; |
|
|
|
import com.iformall.domain.dto.FinanceSetOffDTO; |
|
|
|
import com.iformall.domain.dto.WxBillPayDTO; |
|
|
|
import com.iformall.domain.po.MallUserInfo; |
|
|
|
@@ -247,15 +248,16 @@ public class WxFinanceServiceImpl implements WxFinanceService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void setSetOff(WxBillBaseEntity bill,List<WxFinanceReceive> advanceList,Integer currentIndex) { |
|
|
|
//根据预充值收款单来冲抵账单 |
|
|
|
private void setSetOff(WxBillBaseEntity bill,FinanceSetOffCalcuteDTO calcuteDto) { |
|
|
|
BigDecimal owe = new BigDecimal(bill.getOwe()); |
|
|
|
BigDecimal b0 = new BigDecimal(0); |
|
|
|
if (owe.compareTo(b0) <= 0) { |
|
|
|
return; |
|
|
|
}else { |
|
|
|
List<FinanceSetOffDetailVo> setoffList = bill.getSetOffDetailList(); |
|
|
|
for (int j = currentIndex ; j < advanceList.size() ; j++) { |
|
|
|
WxFinanceReceive advance = advanceList.get(j); |
|
|
|
for (int j = calcuteDto.getCurrentIndex(); j < calcuteDto.getAdvanceList().size() ; j++) { |
|
|
|
WxFinanceReceive advance = calcuteDto.getAdvanceList().get(j); |
|
|
|
BigDecimal remain = new BigDecimal(advance.getRemain()); |
|
|
|
if (remain.compareTo(b0) > 0) { |
|
|
|
if (null == setoffList) { |
|
|
|
@@ -269,7 +271,10 @@ public class WxFinanceServiceImpl implements WxFinanceService { |
|
|
|
}else { |
|
|
|
billSetOff = b0; |
|
|
|
} |
|
|
|
BigDecimal billCurrentSetOff = new BigDecimal(bill.getCurrentSetOff()); |
|
|
|
BigDecimal billCurrentSetOff = new BigDecimal(0); |
|
|
|
if (StringUtils.isNotBlank(bill.getCurrentSetOff())) { |
|
|
|
billCurrentSetOff = new BigDecimal(bill.getCurrentSetOff()); |
|
|
|
} |
|
|
|
//如果前面的不够,则后面的继续补 |
|
|
|
if (remain.compareTo(owe) <= 0 ) { |
|
|
|
//设置账单历史抵扣 |
|
|
|
@@ -280,16 +285,18 @@ public class WxFinanceServiceImpl implements WxFinanceService { |
|
|
|
advance.setUseMoney(advance.getReceiveMoney()); |
|
|
|
dv.setSetoff(remain.toPlainString()); |
|
|
|
setoffList.add(dv); |
|
|
|
setSetOff(bill,advanceList,currentIndex); |
|
|
|
bill.setSetOffDetailList(setoffList); |
|
|
|
setSetOff(bill,calcuteDto); |
|
|
|
}else { |
|
|
|
bill.setSetOff(billSetOff.add(owe).toPlainString()); |
|
|
|
bill.setCurrentSetOff(billCurrentSetOff.add(owe).toPlainString()); |
|
|
|
advance.setUseMoney(new BigDecimal(advance.getUseMoney()).add(owe).toPlainString()); |
|
|
|
dv.setSetoff(owe.toPlainString()); |
|
|
|
setoffList.add(dv); |
|
|
|
bill.setSetOffDetailList(setoffList); |
|
|
|
} |
|
|
|
}else { |
|
|
|
currentIndex = currentIndex+1; |
|
|
|
calcuteDto.setCurrentIndex(calcuteDto.getCurrentIndex()+1); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@@ -313,7 +320,9 @@ public class WxFinanceServiceImpl implements WxFinanceService { |
|
|
|
//每个账单去计算抵扣 |
|
|
|
WxMerchant merchant = new WxMerchant(); |
|
|
|
merchant.updateTenantInfo(dto); |
|
|
|
Integer currentIndex = 0; |
|
|
|
FinanceSetOffCalcuteDTO calcuteDto = new FinanceSetOffCalcuteDTO(); |
|
|
|
calcuteDto.setCurrentIndex(0); |
|
|
|
calcuteDto.setAdvanceList(advanceList); |
|
|
|
List<WxBillBaseEntity> retList = new ArrayList<WxBillBaseEntity>(); |
|
|
|
for (int i = 0 ; i < bills.size() ; i ++) { |
|
|
|
WxBillBaseEntity be = bills.get(i); |
|
|
|
@@ -321,10 +330,12 @@ public class WxFinanceServiceImpl implements WxFinanceService { |
|
|
|
be.setReceivePay(bill.getReceivePay()); |
|
|
|
be.setPay(bill.getPay()); |
|
|
|
be.setSetOff(bill.getSetOff()); |
|
|
|
setSetOff(be, advanceList,currentIndex); |
|
|
|
setSetOff(be, calcuteDto); |
|
|
|
WxBillBaseEntity retb = new WxBillBaseEntity(); |
|
|
|
retb.setId(be.getId()); |
|
|
|
retb.setSetOffDetailList(be.getSetOffDetailList()); |
|
|
|
retb.setCurrentSetOff(be.getCurrentSetOff()); |
|
|
|
retb.setCurrentReceive(be.getCurrentReceive()); |
|
|
|
retList.add(retb); |
|
|
|
} |
|
|
|
return retList; |
|
|
|
|