diff --git a/src_tenwa/com/tenwa/controller/CustomrAccountController.java b/src_tenwa/com/tenwa/controller/CustomrAccountController.java new file mode 100644 index 000000000..615fb17c2 --- /dev/null +++ b/src_tenwa/com/tenwa/controller/CustomrAccountController.java @@ -0,0 +1,93 @@ +package com.tenwa.controller; + +import com.amarsoft.are.jbo.*; +import com.amarsoft.awe.util.Transaction; +import com.base.util.JsonUtil; +import com.tenwa.comm.util.jboutil.DataOperatorUtil; +import jbo.app.tenwa.customer.CUSTOMER_ACCOUNT; +import jbo.app.tenwa.customer.CUSTOMER_ACCOUNT_TEMP; +import jbo.com.tenwa.lease.carbrand.BUSINESS_STATUS; +import jbo.com.tenwa.lease.comm.LB_CONTRACT_INFO; +import jbo.sys.PF_CUSTOMER_ACCOUNT; +import org.codehaus.jackson.map.ObjectMapper; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +public class CustomrAccountController { + + public String serial; + public String currUserId; + public String channel; + public String sourcetype; + public String operationType; + public String applicationNo; + + private String BUSINESS_STATUS_31 = "31"; + + public String change(JBOTransaction tx) { + Map result = new HashMap<>(); + + try { + // 查询合同信息 + BizObjectManager contractInfoManager = JBOFactory.getBizObjectManager(LB_CONTRACT_INFO.CLASS_NAME, tx); + BizObject contractInfo = contractInfoManager.createQuery("CONTRACT_NUMBER=:applicationNo").setParameter("applicationNo", applicationNo).getSingleResult(false); + String contractId = contractInfo.getAttribute(LB_CONTRACT_INFO.ID).toString(); + + // 新的扣款卡信息 + BizObjectManager pfCustomerAccountManager = JBOFactory.getBizObjectManager(PF_CUSTOMER_ACCOUNT.CLASS_NAME, tx); + BizObject pfCustomerAccount = pfCustomerAccountManager.createQuery("SERIAL=:serial").setParameter("serial", serial).getSingleResult(false); + String newAccount = pfCustomerAccount.getAttribute(PF_CUSTOMER_ACCOUNT.account).toString(); + String newAccNumber = pfCustomerAccount.getAttribute(PF_CUSTOMER_ACCOUNT.acc_number).toString(); + String newBankName = pfCustomerAccount.getAttribute(PF_CUSTOMER_ACCOUNT.bank_name).toString(); + String newMobile = pfCustomerAccount.getAttribute(PF_CUSTOMER_ACCOUNT.MOBILE).toString(); + + // 查询合同状态 + BizObjectManager businessStatusManager = JBOFactory.getBizObjectManager(BUSINESS_STATUS.CLASS_NAME, tx); + BizObject businessStatus = businessStatusManager.createQuery("CONTRACT_NUMBER=:applicationNo").setParameter("applicationNo", applicationNo).getSingleResult(false); + + if (businessStatus != null & BUSINESS_STATUS_31.equals(businessStatus.getAttribute(BUSINESS_STATUS.business_status).toString())) { + // TODO 查询流程状态,处于扣款卡变更流程中返回错误 + + // 发起扣款卡信息变更流程 + Map otherProperty = new HashMap<>(); + otherProperty.put(CUSTOMER_ACCOUNT_TEMP.account, newAccount); + otherProperty.put(CUSTOMER_ACCOUNT_TEMP.acc_number, newAccNumber); + otherProperty.put(CUSTOMER_ACCOUNT_TEMP.bank_name, newBankName); + otherProperty.put(CUSTOMER_ACCOUNT_TEMP.MOBILE, newMobile); + + Map fromCondition = new HashMap<>(); + fromCondition.put(CUSTOMER_ACCOUNT.contract_id, contractId); + DataOperatorUtil.copySingleJBO(CUSTOMER_ACCOUNT.CLASS_NAME, fromCondition, CUSTOMER_ACCOUNT_TEMP.CLASS_NAME, null, otherProperty, tx); + + // TODO 发起扣款卡变更流程 + + result.put("success", true); + result.put("msg", "发起扣款卡信息变更流程成功"); + } else { + // 直接变更扣款卡信息 + BizObjectManager custmerAccountManager = JBOFactory.getBizObjectManager(CUSTOMER_ACCOUNT.CLASS_NAME, tx); + BizObject customerAccount = custmerAccountManager.createQuery("contract_id=:contractId").setParameter("contractId", contractId).getSingleResult(false); + customerAccount.setAttributeValue(CUSTOMER_ACCOUNT.account, newAccount); + customerAccount.setAttributeValue(CUSTOMER_ACCOUNT.acc_number, newAccNumber); + customerAccount.setAttributeValue(CUSTOMER_ACCOUNT.bank_name, newBankName); + customerAccount.setAttributeValue(CUSTOMER_ACCOUNT.MOBILE, newMobile); + custmerAccountManager.saveObject(customerAccount); + result.put("success", true); + result.put("msg", "扣款卡信息变更成功"); + } + } catch (JBOException e) { + result.put("success", false); + result.put("msg", "扣款卡信息变更出现异常"); + e.printStackTrace(); + } finally { + try { + return new ObjectMapper().writeValueAsString(result); + } catch (IOException e) { + e.printStackTrace(); + return "{'success': false, 'msg': '扣款卡信息变更出现异常'}"; + } + } + } +}