diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxBillSettleServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxBillSettleServiceImpl.java index c2980aab8..6f57fd549 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxBillSettleServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxBillSettleServiceImpl.java @@ -65,36 +65,42 @@ public class WxBillSettleServiceImpl implements WxBillSettleService { public WxBillSettle getById(Long id){ WxBillSettle billSettle = wxBillSettleMapper.selectByPrimaryKey(id); - if(billSettle != null) { + if(billSettle != null){ WxMerchant merchant = wxMerchantMapper.selectByPrimaryKey(billSettle.getMerchantId()); if(merchant != null){ billSettle.setMerchantName(merchant.getName()); } - if(billSettle.getReceiveMoney() > billSettle.getPayMoney()){ - billSettle.setSettleWay(EnumSettleWay.B.getCode()); - }else{ - billSettle.setSettleWay(EnumSettleWay.M.getCode()); - } + //加载账单列表 WxBillSettleBill wxBillSettleBill = new WxBillSettleBill(); wxBillSettleBill.setTenantId(billSettle.getTenantId()); wxBillSettleBill.setSettleId(billSettle.getId()); wxBillSettleBill.setType(EnumSettleBillType.R.getCode()); billSettle.setReceiveBillIds(wxBillSettleBillMapper.findBySettleId(wxBillSettleBill)); - wxBillSettleBill.setType(EnumSettleBillType.P.getCode()); billSettle.setPayBillIds(wxBillSettleBillMapper.findBySettleId(wxBillSettleBill)); + //加载清算历史 WxBillSettleRecord wxBillSettleRecord = new WxBillSettleRecord(); wxBillSettleRecord.setTenantId(billSettle.getTenantId()); wxBillSettleRecord.setSettleId(billSettle.getId()); billSettle.setSettleRecordList(wxBillSettleRecordMapper.findList(wxBillSettleRecord)); - //计算结余金额 - Long sumSettleMoney = wxBillSettleRecordMapper.getSumMoneyBySettleId(billSettle); - billSettle.setBalance(billSettle.getReceiveMoney() - (billSettle.getPayMoney()+sumSettleMoney)); - } + //加载应收、承付、结余 + WxBillSettle query = new WxBillSettle(); + query.setId(id); + query = wxBillSettleMapper.findList(query).get(0); + billSettle.setReceiveMoney(query.getReceiveMoney()); + billSettle.setPayMoney(query.getPayMoney()); + billSettle.setBalance(query.getBalance()); + //清算方向 + if(billSettle.getReceiveMoney() > billSettle.getPayMoney()){ + billSettle.setSettleWay(EnumSettleWay.B.getCode()); + }else{ + billSettle.setSettleWay(EnumSettleWay.M.getCode()); + } + } return billSettle; } diff --git a/mallinkService/src/main/resources/mapper/WxBillDailyMapper.xml b/mallinkService/src/main/resources/mapper/WxBillDailyMapper.xml index f9d30857e..490c4b446 100644 --- a/mallinkService/src/main/resources/mapper/WxBillDailyMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxBillDailyMapper.xml @@ -77,7 +77,7 @@ select br.`id`,br.`receive_pay`,br.`pay`,br.`receive_date`,br.`pay_date`,br.`createtime`,br.`expired_day` , case when br.status=1 then br.owe else 0 end owe,br.`status`,m.`name` merchant_name,s.shop_number, br.`updatetime`,br.`merchant_id`,br.shop_id,br.type,br.`rent_shop_type`,br.pay_way,br.price_detail, - br.`starttime`,br.`endtime`,br.`build_way` + br.`starttime`,br.`endtime`,br.`build_way`,br.freeze from wx_bill_daily br left join wx_merchant m on br.merchant_id=m.id left join wx_shop s on br.shop_id=s.id diff --git a/mallinkService/src/main/resources/mapper/WxBillOtherDepositMapper.xml b/mallinkService/src/main/resources/mapper/WxBillOtherDepositMapper.xml index 6e0ff7564..772f6d851 100644 --- a/mallinkService/src/main/resources/mapper/WxBillOtherDepositMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxBillOtherDepositMapper.xml @@ -79,7 +79,7 @@ - select tt.*,(tt.receiveMoney-tt.payMoney) balance from ( + select tt.*,(tt.receiveMoney-tt.payMoney- + (select IFNULL(sum(settle_money),0) from wx_bill_settle_record where settle_id = tt.id) + ) balance from ( select s.*,m.name merchantName, (select IFNULL(sum(bill.receive_pay),0) from wx_bill_settle_bill bb left join (select id,merchant_id,shop_id,tenant_id,1 bill_type_value,'租金' @@ -126,9 +128,6 @@ from wx_bill_settle s left JOIN wx_merchant m on(s.merchant_id=m.id) ) tt - - -