一、事務記錄補償表設計

三、業務補償函數
@Override public void compensation(BidPaymentDetailConfirmRecord confirmRecord, ProviderUserSession userSession) throws Exception { Long type = confirmRecord.getBusinessType(); Long detailId = confirmRecord.getPaymentDetailId(); if(type == null || detailId == null) { throw new Exception("事務補償失敗,必要參數為空,type:"+type+",detailId:"+detailId); } BidPaymentsDetail detail = bidPaymentsDetailService.selectByPrimaryKey(detailId); BidPayments payments = bidPaymentsService.selectByPrimaryKey(detail.getPaymentId()); if(payments == null) { throw new Exception("事務補償失敗,收款申請已不存在:"+detail.getPaymentId()); } TrcTrack trcTrack = trcTrackProvider.selectByPrimaryKey(payments.getTrackId()); if(trcTrack == null) { throw new Exception("事務補償失敗,商機信息已不存在:"+payments.getTrackId()); } CstCustomer customer = cstCustomerProvider.selectByPrimaryKey(trcTrack.getCustomerId()); if(customer == null) { throw new Exception("事務補償失敗,客戶信息已不存在:"+trcTrack.getCustomerId()); } final BidContract bidContract = bidContractService.getEffectContract(trcTrack.getId()); try { if (0 == confirmRecord.getStatus()) { switch (type.intValue()) { case 10: bizBidPaymentProvider.receiveDeposit(trcTrack, customer, detail.getReceiveType(), detail.getReceiveAmount(), userSession); break; case 20: //首期款20%,不足額 bizBidPaymentProvider.receiveContractAmount(trcTrack, customer, detail.getReceiveType(), detail.getReceiveAmount(), bidContract.getContractAmount(), false, false, userSession); break; case 21: //首期款20%足額,新建合同號 bizBidPaymentProvider.receiveContractAmount(trcTrack, customer, detail.getReceiveType(), detail.getReceiveAmount(), bidContract.getContractAmount(), true, true, userSession); break; case 22: //首期款20%足額,但不是新建合同號 bizBidPaymentProvider.receiveContractAmount(trcTrack, customer, detail.getReceiveType(), detail.getReceiveAmount(), bidContract.getContractAmount(), true, false, userSession); break; case 23: //1、創建EBS客戶 Map<String, String> resultMap = bidPaymentsDetailService.import_customer( payments, userSession.getEbsBizId(), bidContract.getContractNo()); //2、定金轉首期款 if (resultMap != null && !EbsWebServiceConstants.RETURN_STATUS_ERROR.equals(resultMap.get("status"))) { bidPaymentsDetailService.intentionToDownpayment(payments, trcTrack.getId(), userSession.getEbsBizId(), bidContract.getContractNo()); } break; case 24: //1、定金首期款 bidPaymentsDetailService.intentionToDownpayment(payments, trcTrack.getId(), userSession.getEbsBizId(), bidContract.getContractNo()); break; case 30: //創建收款確認跟進記錄 bidPaymentsDetailService.insertReceivedAmountAction(trcTrack, customer, detail, userSession); break; } confirmRecord.setStatus(2); //設置為已補償 bidPaymentDetailConfirmRecordMapper.updateByPrimaryKeySelective(confirmRecord); } else { LogUtil.error("無效的事務補償,status狀態為:" + confirmRecord.getStatus()); } } catch (Exception e) { throw new Exception("事務補償失敗,"+e.getMessage()); } }
調用rest接口,傳事務記錄ID,進行事務補償

