| @@ -41,5 +41,5 @@ public interface WxBillSettleService { | |||
| void downloadBill(HttpServletRequest request, HttpServletResponse response, WxBillSettle wxBillSettle); | |||
| void updateFreeze(List<WxBillSettleBill> billList, int status); | |||
| void updateFreezeOrStatus(List<WxBillSettleBill> billList, Integer freezeStatus, Integer status); | |||
| } | |||
| @@ -4,7 +4,10 @@ import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.IdWorker; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.MallUserInfo; | |||
| import com.iformall.domain.po.WxBillSettle; | |||
| import com.iformall.domain.po.WxBillSettleRecord; | |||
| import com.iformall.enums.EnumSettleStatus; | |||
| import com.iformall.mapper.WxBillSettleMapper; | |||
| import com.iformall.mapper.WxBillSettleRecordMapper; | |||
| import com.iformall.service.WxBillSettleRecordService; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| @@ -18,7 +21,8 @@ import org.springframework.stereotype.Service; | |||
| public class WxBillSettleRecordServiceImpl implements WxBillSettleRecordService { | |||
| @Autowired | |||
| private WxBillSettleRecordMapper wxBillSettleRecordMapper; | |||
| @Autowired | |||
| private WxBillSettleMapper wxBillSettleMapper; | |||
| @Override | |||
| public PageInfo<WxBillSettleRecord> listAsPage(WxBillSettleRecord record, Integer pageIndex, Integer pageSize) { | |||
| @@ -30,10 +34,29 @@ public class WxBillSettleRecordServiceImpl implements WxBillSettleRecordService | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| if (record.getId() == null) { | |||
| record.setId(idWorker.nextId()); | |||
| //清算完成 | |||
| if(record.getSettleMoney().intValue() == abs(record.getBalance().intValue())){ | |||
| WxBillSettle wxBillSettle = new WxBillSettle(); | |||
| wxBillSettle.setId(record.getSettleId()); | |||
| wxBillSettle.setStatus(EnumSettleStatus.FINISH.getCode()); | |||
| wxBillSettleMapper.updateByPrimaryKeySelective(wxBillSettle); | |||
| } | |||
| if(record.getBalance() < 0){ | |||
| record.setSettleMoney(-record.getSettleMoney()); | |||
| } | |||
| wxBillSettleRecordMapper.insertSelective(record); | |||
| }else{ | |||
| wxBillSettleRecordMapper.updateByPrimaryKeySelective(record); | |||
| } | |||
| return new ResultData(); | |||
| } | |||
| public static Integer abs(Integer a){ | |||
| return a>0?a:-a; | |||
| } | |||
| } | |||
| @@ -105,52 +105,61 @@ public class WxBillSettleServiceImpl implements WxBillSettleService { | |||
| } | |||
| @Override | |||
| public void updateFreeze(List<WxBillSettleBill> billList,int status){ | |||
| public void updateFreezeOrStatus(List<WxBillSettleBill> billList,Integer freezeStatus,Integer status){ | |||
| for (WxBillSettleBill bill:billList) { | |||
| if(EnumBillType.RENT.getCode().equals(bill.getBillType())) { | |||
| WxBillRent wxBillRent = new WxBillRent(); | |||
| wxBillRent.setId(bill.getBillId()); | |||
| wxBillRent.setFreeze(status); | |||
| if(freezeStatus != null) wxBillRent.setFreeze(freezeStatus); | |||
| if(status != null) wxBillRent.setStatus(status); | |||
| wxBillRentMapper.updateByPrimaryKeySelective(wxBillRent); | |||
| }else if(EnumBillType.DEPOSIT.getCode().equals(bill.getBillType())) { | |||
| WxBillDeposit wxBillRent = new WxBillDeposit(); | |||
| wxBillRent.setId(bill.getBillId()); | |||
| wxBillRent.setFreeze(status); | |||
| if(freezeStatus != null) wxBillRent.setFreeze(freezeStatus); | |||
| if(status != null) wxBillRent.setStatus(status); | |||
| wxBillDepositMapper.updateByPrimaryKeySelective(wxBillRent); | |||
| }else if(EnumBillType.PROPERTY.getCode().equals(bill.getBillType())) { | |||
| WxBillProperty wxBillRent = new WxBillProperty(); | |||
| wxBillRent.setId(bill.getBillId()); | |||
| wxBillRent.setFreeze(status); | |||
| if(freezeStatus != null) wxBillRent.setFreeze(freezeStatus); | |||
| if(status != null) wxBillRent.setStatus(status); | |||
| wxBillPropertyMapper.updateByPrimaryKeySelective(wxBillRent); | |||
| WxBillPropertyDeposit propertyDeposit = new WxBillPropertyDeposit(); | |||
| propertyDeposit.setId(bill.getBillId()); | |||
| propertyDeposit.setFreeze(status); | |||
| if(freezeStatus != null) wxBillRent.setFreeze(freezeStatus); | |||
| if(status != null) wxBillRent.setStatus(status); | |||
| wxBillPropertyDepositMapper.updateByPrimaryKeySelective(propertyDeposit); | |||
| }else if(EnumBillType.ROUTINE.getCode().equals(bill.getBillType())) { | |||
| WxBillOther wxBillRent = new WxBillOther(); | |||
| wxBillRent.setId(bill.getBillId()); | |||
| wxBillRent.setFreeze(status); | |||
| if(freezeStatus != null) wxBillRent.setFreeze(freezeStatus); | |||
| if(status != null) wxBillRent.setStatus(status); | |||
| wxBillOtherMapper.updateByPrimaryKeySelective(wxBillRent); | |||
| }else if(EnumBillType.OTHER_DEPOSIT.getCode().equals(bill.getBillType())) { | |||
| WxBillOtherDeposit wxBillRent = new WxBillOtherDeposit(); | |||
| wxBillRent.setId(bill.getBillId()); | |||
| wxBillRent.setFreeze(status); | |||
| if(freezeStatus != null) wxBillRent.setFreeze(freezeStatus); | |||
| if(status != null) wxBillRent.setStatus(status); | |||
| wxBillOtherDepositMapper.updateByPrimaryKeySelective(wxBillRent); | |||
| }else if(EnumBillType.OTHER_DEPOSIT.getCode().equals(bill.getBillType())) { | |||
| WxBillOtherDeposit wxBillRent = new WxBillOtherDeposit(); | |||
| wxBillRent.setId(bill.getBillId()); | |||
| wxBillRent.setFreeze(status); | |||
| if(freezeStatus != null) wxBillRent.setFreeze(freezeStatus); | |||
| if(status != null) wxBillRent.setStatus(status); | |||
| wxBillOtherDepositMapper.updateByPrimaryKeySelective(wxBillRent); | |||
| }else{ | |||
| WxBillDaily wxBillRent = new WxBillDaily(); | |||
| wxBillRent.setId(bill.getBillId()); | |||
| wxBillRent.setFreeze(status); | |||
| if(freezeStatus != null) wxBillRent.setFreeze(freezeStatus); | |||
| if(status != null) wxBillRent.setStatus(status); | |||
| wxBillDailyMapper.updateByPrimaryKeySelective(wxBillRent); | |||
| WxMerchantSubsidy wxMerchantSubsidy = new WxMerchantSubsidy(); | |||
| wxMerchantSubsidy.setId(bill.getBillId()); | |||
| wxMerchantSubsidy.setFreeze(status); | |||
| if(freezeStatus != null) wxBillRent.setFreeze(freezeStatus); | |||
| if(status != null) wxBillRent.setStatus(status); | |||
| wxMerchantSubsidyMapper.updateByPrimaryKeySelective(wxMerchantSubsidy); | |||
| } | |||
| } | |||
| @@ -164,8 +173,8 @@ public class WxBillSettleServiceImpl implements WxBillSettleService { | |||
| if (record.getFlowParams() == null || record.getFlowParams().size() == 0) { | |||
| record.setStatus(EnumSettleStatus.NOT_FINISH.getCode()); | |||
| //选择的账单改为已结清 | |||
| updateFreezeOrStatus(record.getReceiveBillIds(), null,EnumBillRentStatus.PAID.getCode()); | |||
| updateFreezeOrStatus(record.getPayBillIds(), null,EnumBillRentStatus.PAID.getCode()); | |||
| } | |||
| if (record.getId() == null) { | |||
| record.setId(idWorker.nextId()); | |||
| @@ -193,8 +202,8 @@ public class WxBillSettleServiceImpl implements WxBillSettleService { | |||
| //改为冻结状态 | |||
| if (record.getFlowParams() != null && record.getFlowParams().size() > 0) { | |||
| updateFreeze(record.getReceiveBillIds(), EnumFreezeType.YES.getCode()); | |||
| updateFreeze(record.getPayBillIds(),EnumFreezeType.YES.getCode()); | |||
| updateFreezeOrStatus(record.getReceiveBillIds(), EnumFreezeType.YES.getCode(),null); | |||
| updateFreezeOrStatus(record.getPayBillIds(),EnumFreezeType.YES.getCode(),null); | |||
| //启动审批流 | |||
| record.getFlowParams().put("businessId",record.getId()); | |||
| @@ -228,7 +228,7 @@ public class WxFlowServiceImpl implements WxFlowService { | |||
| settleBill.setBillType(billType); | |||
| settleBill.setBillId(businessId); | |||
| billList.add(settleBill); | |||
| wxBillSettleService.updateFreeze(billList,EnumFreezeType.YES.getCode()); | |||
| wxBillSettleService.updateFreezeOrStatus(billList,EnumFreezeType.YES.getCode(),null); | |||
| } | |||
| } else if (EnumFlowKey.NEW_COUPON_UPLINE.getCode().equals(flowType) | |||
| || EnumFlowKey.NEW_CARD_UPLINE.getCode().equals(flowType) | |||
| @@ -291,8 +291,8 @@ public class WxFlowServiceImpl implements WxFlowService { | |||
| //审批完成,账单解冻 | |||
| if(EnumRentContractAppStatus.FINISH.getCode().intValue() == applyStatus.intValue()) { | |||
| WxBillSettle settle = wxBillSettleService.getById(businessId); | |||
| wxBillSettleService.updateFreeze(settle.getReceiveBillIds(), EnumFreezeType.DEF.getCode()); | |||
| wxBillSettleService.updateFreeze(settle.getPayBillIds(),EnumFreezeType.DEF.getCode()); | |||
| wxBillSettleService.updateFreezeOrStatus(settle.getReceiveBillIds(), EnumFreezeType.DEF.getCode(),EnumBillRentStatus.PAID.getCode()); | |||
| wxBillSettleService.updateFreezeOrStatus(settle.getPayBillIds(),EnumFreezeType.DEF.getCode(),EnumBillRentStatus.PAID.getCode()); | |||
| } | |||
| } | |||
| } | |||
| @@ -414,6 +414,9 @@ public class WxFlowServiceImpl implements WxFlowService { | |||
| dynamicContentMap.put("contract", businessId.toString()); | |||
| }else if(isCoupon(flowType)){ | |||
| wxMsgRecord.setModelType(EnumMsgModel.FLOW_C_ASSIGNEE_NODIFY.getCode()); | |||
| }else if(isSettle(flowType)){ | |||
| dynamicContentMap.put("bustype","结算单"); | |||
| dynamicContentMap.put("contract", businessId.toString()); | |||
| } | |||
| wxMsgRecord.setDynamicContentMap(dynamicContentMap); | |||
| mqBaseProducer.sendMessage(wxMsgRecord, EnumMsgMqTopic.DEFAULT.getCode(),EnumMsgMqTag.DEFAULT.getCode(),EnumMsgMqKey.DEFAULT.getCode()); | |||
| @@ -492,6 +495,9 @@ public class WxFlowServiceImpl implements WxFlowService { | |||
| msgReplaceMap.put("contract", businessId.toString()); | |||
| }else if(isCoupon(flowType)){ | |||
| mailMsg.setModelType(EnumMailMsgModel.MAIL_C_ASSIGNEE_NODIFY.getCode()); | |||
| }else if(isSettle(flowType)){ | |||
| msgReplaceMap.put("bustype","结算单"); | |||
| msgReplaceMap.put("contract", businessId.toString()); | |||
| } | |||
| mailMsg.setDynamicContentMap(msgReplaceMap); | |||
| mqBaseProducer.sendMessage(mailMsg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||
| @@ -536,6 +542,12 @@ public class WxFlowServiceImpl implements WxFlowService { | |||
| } | |||
| return false; | |||
| } | |||
| public boolean isSettle(Integer flowType){ | |||
| if(EnumFlowKey.SETTLE.getCode().equals(flowType)){ | |||
| return true; | |||
| } | |||
| return false; | |||
| } | |||
| public String variablesToJson(List<Map<String,Object>> variables){ | |||
| HashMap<String,Object> map = new HashMap<>(); | |||
| @@ -932,6 +944,9 @@ public class WxFlowServiceImpl implements WxFlowService { | |||
| WxCoupon wxCoupon = this.wxCouponMapper.selectByPrimaryKey(businessId); | |||
| msgReplaceMap.put("type",EnumCouponType.getEnum(wxCoupon.getType()).getMessage()); | |||
| msgReplaceMap.put("name",wxCoupon.getTitle()); | |||
| }else if(isSettle(flowType)){ | |||
| msgReplaceMap.put("bustype","结算单"); | |||
| msgReplaceMap.put("contract", businessId.toString()); | |||
| } | |||
| wxMsgRecord.setDynamicContentMap(msgReplaceMap); | |||
| mqBaseProducer.sendMessage(wxMsgRecord, EnumMsgMqTopic.DEFAULT.getCode(),EnumMsgMqTag.DEFAULT.getCode(),EnumMsgMqKey.DEFAULT.getCode()); | |||
| @@ -956,6 +971,9 @@ public class WxFlowServiceImpl implements WxFlowService { | |||
| WxCoupon wxCoupon = this.wxCouponMapper.selectByPrimaryKey(businessId); | |||
| msgReplaceMap.put("type",EnumCouponType.getEnum(wxCoupon.getType()).getMessage()); | |||
| msgReplaceMap.put("name",wxCoupon.getTitle()); | |||
| }else if(isSettle(flowType)){ | |||
| msgReplaceMap.put("bustype","结算单"); | |||
| msgReplaceMap.put("contract", businessId.toString()); | |||
| } | |||
| mailMsg.setDynamicContentMap(msgReplaceMap); | |||
| mqBaseProducer.sendMessage(mailMsg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||
| @@ -990,6 +1008,9 @@ public class WxFlowServiceImpl implements WxFlowService { | |||
| WxCoupon wxCoupon = this.wxCouponMapper.selectByPrimaryKey(businessId); | |||
| msgReplaceMap.put("type",EnumCouponType.getEnum(wxCoupon.getType()).getMessage()); | |||
| msgReplaceMap.put("name",wxCoupon.getTitle()); | |||
| }else if(isSettle(flowType)){ | |||
| msgReplaceMap.put("bustype","结算单"); | |||
| msgReplaceMap.put("contract", businessId.toString()); | |||
| } | |||
| wxMsgRecord.setDynamicContentMap(msgReplaceMap); | |||
| mqBaseProducer.sendMessage(wxMsgRecord, EnumMsgMqTopic.DEFAULT.getCode(),EnumMsgMqTag.DEFAULT.getCode(),EnumMsgMqKey.DEFAULT.getCode()); | |||
| @@ -1014,6 +1035,9 @@ public class WxFlowServiceImpl implements WxFlowService { | |||
| WxCoupon wxCoupon = this.wxCouponMapper.selectByPrimaryKey(businessId); | |||
| msgReplaceMap.put("type",EnumCouponType.getEnum(wxCoupon.getType()).getMessage()); | |||
| msgReplaceMap.put("name",wxCoupon.getTitle()); | |||
| }else if(isSettle(flowType)){ | |||
| msgReplaceMap.put("bustype","结算单"); | |||
| msgReplaceMap.put("contract", businessId.toString()); | |||
| } | |||
| mailMsg.setDynamicContentMap(msgReplaceMap); | |||
| mqBaseProducer.sendMessage(mailMsg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||
| @@ -1137,6 +1161,9 @@ public class WxFlowServiceImpl implements WxFlowService { | |||
| WxCoupon wxCoupon = this.wxCouponMapper.selectByPrimaryKey(businessId); | |||
| msgReplaceMap.put("type",EnumCouponType.getEnum(wxCoupon.getType()).getMessage()); | |||
| msgReplaceMap.put("name",wxCoupon.getTitle()); | |||
| }else if (isSettle(flowType)) { | |||
| msgReplaceMap.put("bustype", "结算单"); | |||
| msgReplaceMap.put("contract", businessId.toString()); | |||
| } | |||
| wxMsgRecord.setDynamicContentMap(msgReplaceMap); | |||
| mqBaseProducer.sendMessage(wxMsgRecord, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||
| @@ -1169,6 +1196,9 @@ public class WxFlowServiceImpl implements WxFlowService { | |||
| WxCoupon wxCoupon = this.wxCouponMapper.selectByPrimaryKey(businessId); | |||
| msgReplaceMap.put("type",EnumCouponType.getEnum(wxCoupon.getType()).getMessage()); | |||
| msgReplaceMap.put("name",wxCoupon.getTitle()); | |||
| }else if(isSettle(flowType)){ | |||
| msgReplaceMap.put("bustype","结算单"); | |||
| msgReplaceMap.put("contract", businessId.toString()); | |||
| } | |||
| mailMsg.setDynamicContentMap(msgReplaceMap); | |||
| mqBaseProducer.sendMessage(mailMsg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||
| @@ -79,6 +79,10 @@ | |||
| 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,starttime,endtime 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,'' starttime,'' endtime from wx_merchant_subsidy | |||
| ) bill | |||
| on(bl.bill_id = bill.id) | |||
| where 1=1 | |||
| @@ -122,6 +122,10 @@ | |||
| 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 | |||
| 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 | |||
| ) bill | |||
| on(bb.bill_id=bill.id) where bb.settle_id = s.id and bb.type=1 | |||
| ) payMoney | |||