|
|
|
@@ -979,6 +979,61 @@ public class WxFinanceServiceImpl implements WxFinanceService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void updateReceive(WxFinanceReceive record,MallUserInfo user) { |
|
|
|
record.setUpdateTime(new Date()); |
|
|
|
record.setUpdateBy(user.getId()); |
|
|
|
record.setUpdateByName(user.getName()); |
|
|
|
wxFinanceReceiveMapper.updateById(record); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void updateReceivePayways(WxFinanceReceive record,MallUserInfo user) { |
|
|
|
WxFinanceReceive receive = this.getReceiveById(record, record.getId()); |
|
|
|
record.setUpdateTime(new Date()); |
|
|
|
record.setUpdateBy(user.getId()); |
|
|
|
record.setUpdateByName(user.getName()); |
|
|
|
List<WxFinanceReceivePayway> receivePayWayList = new ArrayList<WxFinanceReceivePayway>(); |
|
|
|
StringBuffer moneyDetail = new StringBuffer(); |
|
|
|
BigDecimal receiveTotal = new BigDecimal(0); |
|
|
|
if (null != record.getPayWays()) { |
|
|
|
final IdWorker idWorker = IdWorker.get(); |
|
|
|
for (int i = 0 ; i < record.getPayWays().size() ; i ++) { |
|
|
|
WxBillPayWay payWay = record.getPayWays().get(i); |
|
|
|
if (StringUtils.isNotBlank(payWay.getMoney())) { |
|
|
|
if (null == payWay.getId()) { |
|
|
|
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"收款方式不能为空"); |
|
|
|
} |
|
|
|
receiveTotal = receiveTotal.add(new BigDecimal(payWay.getMoney())); |
|
|
|
WxFinanceReceivePayway rpw = new WxFinanceReceivePayway(); |
|
|
|
rpw.setId(idWorker.nextId()); |
|
|
|
rpw.updateTenantInfo(record); |
|
|
|
rpw.setReceiveId(record.getId()); |
|
|
|
rpw.setReceive(payWay.getMoney()); |
|
|
|
rpw.setPayWay(payWay.getId()); |
|
|
|
rpw.setPayWayName(payWay.getName()); |
|
|
|
rpw.setCreateTime(new Date()); |
|
|
|
rpw.setUpdateTime(new Date()); |
|
|
|
rpw.setIsDel(EnumYesOrNo.NO.getCode()); |
|
|
|
receivePayWayList.add(rpw); |
|
|
|
moneyDetail.append(payWay.getName()).append(":").append(payWay.getMoney()).append("元"); |
|
|
|
} |
|
|
|
} |
|
|
|
if (receiveTotal.compareTo(new BigDecimal(receive.getReceiveMoney())) != 0) { |
|
|
|
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"总收款金额不正确"); |
|
|
|
}else { |
|
|
|
record.setMoneyDetail(moneyDetail.toString()); |
|
|
|
//删除之前的收款方式 |
|
|
|
WxFinanceReceivePayway pd = new WxFinanceReceivePayway(); |
|
|
|
pd.updateTenantInfo(record); |
|
|
|
pd.setReceiveId(record.getId()); |
|
|
|
wxFinanceReceivePaywayMapper.deleteByConditon(pd); |
|
|
|
wxFinanceReceivePaywayMapper.insertPayWays(record.getTenantId(),receivePayWayList); |
|
|
|
} |
|
|
|
wxFinanceReceiveMapper.updateById(record); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) |
|
|
|
@Override |
|
|
|
|