| @@ -65,36 +65,42 @@ public class WxBillSettleServiceImpl implements WxBillSettleService { | |||||
| public WxBillSettle getById(Long id){ | public WxBillSettle getById(Long id){ | ||||
| WxBillSettle billSettle = wxBillSettleMapper.selectByPrimaryKey(id); | WxBillSettle billSettle = wxBillSettleMapper.selectByPrimaryKey(id); | ||||
| if(billSettle != null) { | |||||
| if(billSettle != null){ | |||||
| WxMerchant merchant = wxMerchantMapper.selectByPrimaryKey(billSettle.getMerchantId()); | WxMerchant merchant = wxMerchantMapper.selectByPrimaryKey(billSettle.getMerchantId()); | ||||
| if(merchant != null){ | if(merchant != null){ | ||||
| billSettle.setMerchantName(merchant.getName()); | 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 wxBillSettleBill = new WxBillSettleBill(); | ||||
| wxBillSettleBill.setTenantId(billSettle.getTenantId()); | wxBillSettleBill.setTenantId(billSettle.getTenantId()); | ||||
| wxBillSettleBill.setSettleId(billSettle.getId()); | wxBillSettleBill.setSettleId(billSettle.getId()); | ||||
| wxBillSettleBill.setType(EnumSettleBillType.R.getCode()); | wxBillSettleBill.setType(EnumSettleBillType.R.getCode()); | ||||
| billSettle.setReceiveBillIds(wxBillSettleBillMapper.findBySettleId(wxBillSettleBill)); | billSettle.setReceiveBillIds(wxBillSettleBillMapper.findBySettleId(wxBillSettleBill)); | ||||
| wxBillSettleBill.setType(EnumSettleBillType.P.getCode()); | wxBillSettleBill.setType(EnumSettleBillType.P.getCode()); | ||||
| billSettle.setPayBillIds(wxBillSettleBillMapper.findBySettleId(wxBillSettleBill)); | billSettle.setPayBillIds(wxBillSettleBillMapper.findBySettleId(wxBillSettleBill)); | ||||
| //加载清算历史 | |||||
| WxBillSettleRecord wxBillSettleRecord = new WxBillSettleRecord(); | WxBillSettleRecord wxBillSettleRecord = new WxBillSettleRecord(); | ||||
| wxBillSettleRecord.setTenantId(billSettle.getTenantId()); | wxBillSettleRecord.setTenantId(billSettle.getTenantId()); | ||||
| wxBillSettleRecord.setSettleId(billSettle.getId()); | wxBillSettleRecord.setSettleId(billSettle.getId()); | ||||
| billSettle.setSettleRecordList(wxBillSettleRecordMapper.findList(wxBillSettleRecord)); | 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; | return billSettle; | ||||
| } | } | ||||
| @@ -77,7 +77,7 @@ | |||||
| select br.`id`,br.`receive_pay`,br.`pay`,br.`receive_date`,br.`pay_date`,br.`createtime`,br.`expired_day` , | 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, | 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.`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 | 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 | left join wx_shop s on br.shop_id=s.id | ||||
| <where> | <where> | ||||
| @@ -79,7 +79,7 @@ | |||||
| <select id="queryBillList" parameterType="com.iformall.domain.po.WxBillOtherDeposit" resultMap="BaseResultMap"> | <select id="queryBillList" parameterType="com.iformall.domain.po.WxBillOtherDeposit" resultMap="BaseResultMap"> | ||||
| select br.`id`,br.`receive_pay`,br.`pay`,br.`receive_date`,br.`pay_date`,br.`createtime`,br.`expired_day`, | select br.`id`,br.`receive_pay`,br.`pay`,br.`receive_date`,br.`pay_date`,br.`createtime`,br.`expired_day`, | ||||
| br.`owe`,br.`status`,m.`name` merchant_name,s.shop_number,br.`updatetime`,br.`return_price`,br.`merchant_id`, | br.`owe`,br.`status`,m.`name` merchant_name,s.shop_number,br.`updatetime`,br.`return_price`,br.`merchant_id`, | ||||
| br.shop_id,br.name,br.comments,br.`rent_shop_type`,br.pay_way,br.`starttime`,br.`endtime` | |||||
| br.shop_id,br.name,br.comments,br.`rent_shop_type`,br.pay_way,br.`starttime`,br.`endtime`,br.freeze | |||||
| from wx_bill_other_deposit br left join wx_merchant m on br.merchant_id=m.id | from wx_bill_other_deposit br left join wx_merchant m on br.merchant_id=m.id | ||||
| left join wx_shop s on br.shop_id=s.id | left join wx_shop s on br.shop_id=s.id | ||||
| <where> | <where> | ||||
| @@ -75,7 +75,7 @@ | |||||
| select br.`id`,br.`receive_pay`,br.`pay`,br.`receive_date`, br.`pay_date`,br.`createtime`,br.`expired_day`, | 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` | case when br.status=1 then br.owe else 0 end owe,br.`status`,m.`name` | ||||
| merchant_name,s.shop_number,br.`updatetime`, | merchant_name,s.shop_number,br.`updatetime`, | ||||
| br.`merchant_id`,br.shop_id,br.name,br.comments,br.`rent_shop_type`,br.pay_way,br.`starttime`,br.`endtime` | |||||
| br.`merchant_id`,br.shop_id,br.name,br.comments,br.`rent_shop_type`,br.pay_way,br.`starttime`,br.`endtime`,br.freeze | |||||
| from wx_bill_other br left join wx_merchant m on br.merchant_id=m.id | from wx_bill_other br left join wx_merchant m on br.merchant_id=m.id | ||||
| left join wx_shop s on br.shop_id=s.id | left join wx_shop s on br.shop_id=s.id | ||||
| <where> | <where> | ||||
| @@ -97,7 +97,7 @@ | |||||
| br.late_pay_price,d.`status` | br.late_pay_price,d.`status` | ||||
| deposit_status,br.`shop_info`,br.pay_way,br.late_pay_status, | deposit_status,br.`shop_info`,br.pay_way,br.late_pay_status, | ||||
| br.`comments`,br.starttime,br.endtime, | br.`comments`,br.starttime,br.endtime, | ||||
| r.late_pay_day,r.late_pay_ratio | |||||
| r.late_pay_day,r.late_pay_ratio,br.freeze | |||||
| from wx_bill_property br left join wx_merchant m on br.merchant_id=m.id | from wx_bill_property br left join wx_merchant m on br.merchant_id=m.id | ||||
| left join wx_shop s on br.shop_id=s.id | left join wx_shop s on br.shop_id=s.id | ||||
| left join wx_property_contract r on br.property_contract_id=r.id | left join wx_property_contract r on br.property_contract_id=r.id | ||||
| @@ -105,7 +105,7 @@ | |||||
| r.pay_ratio,br.`revenue`,r.`late_pay_ratio`,br.`late_pay_time`,br.`period`,br.`rent_contract_id`, | r.pay_ratio,br.`revenue`,r.`late_pay_ratio`,br.`late_pay_time`,br.`period`,br.`rent_contract_id`, | ||||
| d.receive_pay deposit,d.`status` | d.receive_pay deposit,d.`status` | ||||
| deposit_status,br.late_pay_price,br.shop_info,br.pay_way,br.late_pay_status,br.`comments`,br.starttime,br.endtime, | deposit_status,br.late_pay_price,br.shop_info,br.pay_way,br.late_pay_status,br.`comments`,br.starttime,br.endtime, | ||||
| r.late_pay_day,r.late_pay_ratio,br.bus_discount_ratio | |||||
| r.late_pay_day,r.late_pay_ratio,br.bus_discount_ratio,br.freeze | |||||
| from wx_bill_rent br | from wx_bill_rent br | ||||
| left join wx_shop s on br.shop_id=s.id | left join wx_shop s on br.shop_id=s.id | ||||
| left join wx_rent_contract r on br.rent_contract_id=r.id | left join wx_rent_contract r on br.rent_contract_id=r.id | ||||
| @@ -49,7 +49,9 @@ | |||||
| </sql> | </sql> | ||||
| <select id="findList" parameterType="com.iformall.domain.po.WxBillSettle" resultMap="BaseResultMap"> | <select id="findList" parameterType="com.iformall.domain.po.WxBillSettle" resultMap="BaseResultMap"> | ||||
| 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 s.*,m.name merchantName, | ||||
| (select IFNULL(sum(bill.receive_pay),0) from wx_bill_settle_bill bb left join | (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,'租金' | (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) | from wx_bill_settle s left JOIN wx_merchant m on(s.merchant_id=m.id) | ||||
| ) tt | ) tt | ||||
| <include refid="dynamicWhereConditions"/> | <include refid="dynamicWhereConditions"/> | ||||
| </select> | </select> | ||||