diff --git a/mallinkService/src/main/resources/mapper/WxBillAllMapper.xml b/mallinkService/src/main/resources/mapper/WxBillAllMapper.xml index 722969558..efe661eb7 100644 --- a/mallinkService/src/main/resources/mapper/WxBillAllMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxBillAllMapper.xml @@ -248,11 +248,12 @@ bill.receive_pay receivePay,bill.pay,bill.owe,bill.receive_date receiveDate,bill.pay_date payDate,DATEDIFF(now(),bill.receive_date) expiredDay,bill.status, bill.tenant_id tenantId,m.name merchantName,s.shop_number shopNumber,bill.starttime,bill.endtime,bill.name,pb.pay_bill_status payBillStatus, pb.pay_time_end tradeTime,pb.transaction_id transactionId,pb.pay_amount payAmount,bill.rent_shop_type - rentShopType,bill.price_detail priceDetail,bill.freeze from ( + rentShopType,bill.price_detail priceDetail,bill.freeze,bill.late_pay_price latePayPrice,bill.service_charge_pay + serviceChargePay from ( select '' settle_number,id,merchant_id,shop_id,tenant_id,'租金' name,1 bill_type_value,'租金' bill_type,need_pay,receive_pay,pay,(receive_pay+service_charge_pay+ifnull(late_pay_price,0)-pay) owe,receive_date,pay_date,expired_day,status,starttime,endtime,rent_shop_type,'' - price_detail,freeze + price_detail,freeze,ifnull(late_pay_price,0) late_pay_price,service_charge_pay from wx_bill_rent where is_preview = 0 and tenant_id=#{tenantId} and rent_contract_id in (select id from wx_rent_contract where status in (2,3,4)) @@ -260,14 +261,14 @@ select '' settle_number,id,merchant_id,shop_id,tenant_id,'租赁押金' name,2 bill_type_value,'租赁押金' bill_type,need_pay,receive_pay,pay,(receive_pay+service_charge_pay-pay) owe,receive_date,pay_date,expired_day,status,starttime,endtime,rent_shop_type,'' - price_detail,freeze + price_detail,freeze,0 late_pay_price,service_charge_pay from wx_bill_rent_deposit where tenant_id=#{tenantId} and rent_contract_id in (select id from wx_rent_contract where status in (2,3,4)) union all select '' settle_number,id,merchant_id,shop_id,tenant_id,'物业费' name,3 bill_type_value,'物业费' bill_type,need_pay,receive_pay,pay,(receive_pay+service_charge_pay+ifnull(late_pay_price,0)-pay) owe,receive_date,pay_date,expired_day,status,starttime,endtime,rent_shop_type,'' - price_detail,freeze + price_detail,freeze,ifnull(late_pay_price,0) late_pay_price,service_charge_pay from wx_bill_property where is_preview = 0 and tenant_id=#{tenantId} and property_contract_id in (select id from wx_property_contract where status in(2,3,4)) @@ -275,7 +276,7 @@ select '' settle_number,id,merchant_id,shop_id,tenant_id,'物业押金' name,4 bill_type_value,'物业押金' bill_type,need_pay,receive_pay,pay,(receive_pay+service_charge_pay-pay) owe,receive_date,pay_date,expired_day,status,starttime,endtime,rent_shop_type,'' - price_detail,freeze + price_detail,freeze,0 late_pay_price,service_charge_pay from wx_bill_property_deposit where tenant_id=#{tenantId} and property_contract_id in (select id from wx_property_contract where status in (2,3,4)) @@ -283,57 +284,66 @@ select '' settle_number,id,merchant_id,shop_id,tenant_id,case when type=1 then '水费' when type=2 then '电费' else '空调费' end name, case when type=1 then 5 when type=2 then 6 else 9 end bill_type_value, case when type=1 then '水费' when type=2 then '电费' else '空调费' end bill_type, 0 as need_pay,receive_pay, - pay,(receive_pay+service_charge_pay-pay) - owe,receive_date,pay_date,expired_day,status,starttime,endtime,rent_shop_type,price_detail,freeze + pay,(receive_pay+service_charge_pay-pay) owe,receive_date,pay_date,expired_day,status,starttime,endtime, + rent_shop_type,price_detail,freeze,0 late_pay_price,service_charge_pay from wx_bill_daily where tenant_id=#{tenantId} union all select '' settle_number,id,merchant_id,shop_id,tenant_id,name,7 bill_type_vaue,'其他费用' bill_type,0 as need_pay,receive_pay,pay,(receive_pay+service_charge_pay-pay) owe,receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type,'' - price_detail,freeze + price_detail,freeze,0 late_pay_price,service_charge_pay from wx_bill_other where tenant_id=#{tenantId} union all select '' settle_number,id,merchant_id,shop_id,tenant_id,comments as name,8 bill_type_value,'其他押金' bill_type,0 as need_pay,receive_pay,pay,(receive_pay+service_charge_pay-pay) owe,receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type,'' - price_detail,freeze + price_detail,freeze,0 late_pay_price,service_charge_pay from wx_bill_other_deposit where tenant_id=#{tenantId} union all select s.settle_number,s.id,s.merchant_id,'' shop_id,s.tenant_id,'结算单' name, 10 bill_type_value,'结算单' bill_type,0 need_pay, ((select IFNULL(sum(bill.owe),0) from wx_bill_settle_bill bb left join (select id,merchant_id,shop_id,tenant_id,1 bill_type_value,'租金' - bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_rent where is_preview = 0 + bill_type,need_pay,receive_pay,pay,(receive_pay+service_charge_pay+ifnull(late_pay_price,0)-pay) + owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_rent where is_preview = 0 union all select id,merchant_id,shop_id,tenant_id,2 bill_type_value,'租赁押金' - bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from + bill_type,need_pay,receive_pay,pay,(receive_pay+service_charge_pay-pay) + owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_rent_deposit union all select id,merchant_id,shop_id,tenant_id,3 bill_type_value,'物业费' - bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from + bill_type,need_pay,receive_pay,pay,(receive_pay+service_charge_pay+ifnull(late_pay_price,0)-pay) + owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_property where is_preview = 0 union all select id,merchant_id,shop_id,tenant_id,4 bill_type_value,'物业押金' - bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from + bill_type,need_pay,receive_pay,pay,(receive_pay+service_charge_pay-pay) + owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_property_deposit union all select id,merchant_id,shop_id,tenant_id,5 bill_type_value,'水费' bill_type,0 as - need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where + need_pay,receive_pay,pay,(receive_pay+service_charge_pay-pay) + owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where type=1 union all select id,merchant_id,shop_id,tenant_id,6 bill_type_value,'电费' bill_type,0 as - need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where + need_pay,receive_pay,pay,(receive_pay+service_charge_pay-pay) + owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where type=2 union all select id,merchant_id,shop_id,tenant_id,9 bill_type_value,'空调费' bill_type,0 as - need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where + need_pay,receive_pay,pay,(receive_pay+service_charge_pay-pay) + owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where type=3 union all select id,merchant_id,shop_id,tenant_id,7 bill_type_value,'其他费用' bill_type,0 as - need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_other + need_pay,receive_pay,pay,(receive_pay+service_charge_pay-pay) + owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_other union all select id,merchant_id,shop_id,tenant_id,8 bill_type_value,'其他押金' bill_type,0 as - need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_other_deposit + need_pay,receive_pay,pay,(receive_pay+service_charge_pay-pay) + owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_other_deposit union all select id,id merchant_id,'' shop_id,tenant_id,10 bill_type_value,'补贴' bill_type,0 as need_pay,subsidy receive_pay,0 pay,0 owe,'' receive_date,'' pay_date,'' expired_day,status,'' rent_shop_type from wx_merchant_subsidy @@ -342,37 +352,45 @@ - (select IFNULL(sum(bill.owe),0) from wx_bill_settle_bill bb left join (select id,merchant_id,shop_id,tenant_id,1 bill_type_value,'租金' - bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_rent where is_preview = 0 + bill_type,need_pay,receive_pay,pay,(receive_pay+service_charge_pay+ifnull(late_pay_price,0)-pay) + owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_rent where is_preview = 0 union all select id,merchant_id,shop_id,tenant_id,2 bill_type_value,'租赁押金' - bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from + bill_type,need_pay,receive_pay,pay,(receive_pay+service_charge_pay-pay) + owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_rent_deposit union all select id,merchant_id,shop_id,tenant_id,3 bill_type_value,'物业费' - bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from + bill_type,need_pay,receive_pay,pay,(receive_pay+service_charge_pay+ifnull(late_pay_price,0)-pay) + owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_property where is_preview = 0 union all select id,merchant_id,shop_id,tenant_id,4 bill_type_value,'物业押金' - bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from + bill_type,need_pay,receive_pay,pay,(receive_pay+service_charge_pay-pay) + owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_property_deposit union all select id,merchant_id,shop_id,tenant_id,5 bill_type_value,'水费' bill_type,0 as - need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where + need_pay,receive_pay,pay,(receive_pay+service_charge_pay-pay) + owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where type=1 union all select id,merchant_id,shop_id,tenant_id,6 bill_type_value,'电费' bill_type,0 as - need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where + need_pay,receive_pay,pay,(receive_pay+service_charge_pay-pay) + owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where type=2 union all select id,merchant_id,shop_id,tenant_id,9 bill_type_value,'空调费' bill_type,0 as - need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where + need_pay,receive_pay,pay,(receive_pay+service_charge_pay-pay) + owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where type=3 union all select id,merchant_id,shop_id,tenant_id,7 bill_type_value,'其他费用' bill_type,0 as need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_other union all select id,merchant_id,shop_id,tenant_id,8 bill_type_value,'其他押金' bill_type,0 as - need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_other_deposit + need_pay,receive_pay,pay,(receive_pay+service_charge_pay-pay) + owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_other_deposit union all select id,id merchant_id,'' shop_id,tenant_id,10 bill_type_value,'补贴' bill_type,0 as need_pay,subsidy receive_pay,0 pay,subsidy owe,'' receive_date,'' pay_date,'' expired_day,status,'' rent_shop_type from wx_merchant_subsidy @@ -380,7 +398,9 @@ on(bb.bill_id=bill.id) where bb.settle_id = s.id and bb.type=1 ) ) receive_pay - ,0 pay,0 owe,s.createtime receive_date,'' pay_date,0 expired_day,status,'' starttime,'' endtime,'' rent_shop_type,'' price_detail, 0 freeze + ,0 pay,0 owe,s.createtime receive_date,'' pay_date,0 expired_day, + status,'' starttime,'' endtime,'' rent_shop_type,'' price_detail, 0 freeze, + 0 late_pay_price,0 service_charge_pay from wx_bill_settle s where s.tenant_id=#{tenantId} and s.status >0 ) bill