From 713d1cfb53474d3f3078d19edde9fa845457fc68 Mon Sep 17 00:00:00 2001 From: luozukai Date: Thu, 5 Sep 2019 12:43:38 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=90=88=E5=90=8C][=E4=BF=AE=E6=94=B9][?= =?UTF-8?q?=E5=BC=80=E5=8F=91=E7=BB=93=E7=AE=97=E5=8D=95]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/WxBillSettleServiceImpl.java | 28 +++++++++++-------- .../resources/mapper/WxBillDailyMapper.xml | 2 +- .../mapper/WxBillOtherDepositMapper.xml | 2 +- .../resources/mapper/WxBillOtherMapper.xml | 2 +- .../resources/mapper/WxBillPropertyMapper.xml | 2 +- .../resources/mapper/WxBillRentMapper.xml | 2 +- .../resources/mapper/WxBillSettleMapper.xml | 7 ++--- 7 files changed, 25 insertions(+), 20 deletions(-) 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 - - -