修改汇兑后经销商放款

This commit is contained in:
hexiaomou 2018-06-24 23:14:08 +08:00
parent e6882f3a4e
commit ac7f2c66fb
4 changed files with 806 additions and 0 deletions

View File

@ -1351,6 +1351,8 @@
<attribute name="BANK_PAY_ID" label="支付ID" type="STRING" length="32"/>
<attribute name="BANK_REQNBR" label="流程实例号" type="STRING" length="32"/>
<attribute name="BANK_ID" label="支付账户ID" type="STRING" length="32"/>
<attribute name="CMB_PAY_NO" label="支付流水号" type="STRING" length="32"/>
<attribute name="CMB_PAY_LOG" label="支付日志" type="STRING" length="32"/>
</attributes>
<manager>
<managerProperties>
@ -1412,6 +1414,8 @@
<attribute name="BANK_PAY_ID" label="支付ID" type="STRING" length="32"/>
<attribute name="BANK_REQNBR" label="流程实例号" type="STRING" length="32"/>
<attribute name="BANK_ID" label="支付账户ID" type="STRING" length="32"/>
<attribute name="CMB_PAY_NO" label="支付流水号" type="STRING" length="32"/>
<attribute name="CMB_PAY_LOG" label="支付日志" type="STRING" length="32"/>
</attributes>
<manager>
<managerProperties>

View File

@ -3648,6 +3648,139 @@
</manager>
</class>
<class name="LC_FUND_INCOME_CALLBACK_DETAIL_TEMP" label="" keyAttributes="ID">
<attributes>
<attribute name="ID" label="ID" type="STRING" length="32"/>
<attribute name="CMB_PAY_NO" label="付款流水号" type="STRING" length="32"/>
<attribute name="CMB_PAY_LOG" label="付款日志" type="STRING" length="32"/>
<attribute name="DISTRIBUTOR_ID" label="经销商编号" type="STRING" length="32"/>
<attribute name="FLOWUNID" label="流程号" type="STRING" length="32"/>
<attribute name="SQRNBR" label="流水号" type="STRING" length="10"/>
<attribute name="YURREF" label="业务参考号" type="STRING" length="30"/>
<attribute name="REQNBR" label="流程实例号" type="STRING" length="10"/>
<attribute name="REQSTS" label="业务请求状态" type="STRING" length="3"/>
<attribute name="RTNFLG" label="业务处理结果" type="STRING" length="1"/>
<attribute name="OPRSQN" label="待处理操作序列" type="STRING" length="3"/>
<attribute name="OPRALS" label="操作别名" type="STRING" length="32"/>
<attribute name="ERRCOD" label="错误码" type="STRING" length="7"/>
<attribute name="RTNNAR" label="结果摘要" type="STRING" length="1000"/>
<attribute name="ERRTXT" label="错误文本" type="STRING" length="256"/>
<attribute name="INPUTUSERID" label="INPUTUSERID" type="STRING" length="32"/>
<attribute name="INPUTORGID" label="INPUTORGID" type="STRING" length="32"/>
<attribute name="INPUTTIME" label="INPUTTIME" type="STRING" length="32"/>
<attribute name="UPDATEUSERID" label="UPDATEUSERID" type="STRING" length="32"/>
<attribute name="UPDATEORGID" label="UPDATEORGID" type="STRING" length="32"/>
<attribute name="UPDATETIME" label="UPDATETIME" type="STRING" length="32"/>
</attributes>
<manager>
<managerProperties>
<property name="table" value="lc_fund_income_callback_detail_temp" />
<property name="createKey" value="true" />
</managerProperties>
</manager>
</class>
<class name="LC_FUND_INCOME_CALLBACK_INFO_TEMP" label="" keyAttributes="ID">
<attributes>
<attribute name="ID" label="ID" type="STRING" length="32"/>
<attribute name="CMB_PAY_NO" label="付款流水号" type="STRING" length="32"/>
<attribute name="CMB_PAY_LOG" label="付款日志" type="STRING" length="32"/>
<attribute name="FLOWUNID" label="流程号" type="STRING" length="32"/>
<attribute name="INFO_FUNNAM" label="函数名" type="STRING" length="20"/>
<attribute name="INFO_DATTYP" label="数据格式" type="STRING" length="1"/>
<attribute name="INFO_RETCOD" label="返回代码" type="STRING" length="32"/>
<attribute name="INFO_ERRMSG" label="错误信息" type="STRING" length="256"/>
<attribute name="INPUTUSERID" label="INPUTUSERID" type="STRING" length="32"/>
<attribute name="INPUTORGID" label="INPUTORGID" type="STRING" length="32"/>
<attribute name="INPUTTIME" label="INPUTTIME" type="STRING" length="32"/>
<attribute name="UPDATEUSERID" label="UPDATEUSERID" type="STRING" length="32"/>
<attribute name="UPDATEORGID" label="UPDATEORGID" type="STRING" length="32"/>
<attribute name="UPDATETIME" label="UPDATETIME" type="STRING" length="32"/>
</attributes>
<manager>
<managerProperties>
<property name="table" value="lc_fund_income_callback_info_temp" />
<property name="createKey" value="true" />
</managerProperties>
</manager>
</class>
<class name="LC_FUND_INCOME_PAY_DETAIL_TEMP" label="" keyAttributes="ID">
<attributes>
<attribute name="ID" label="ID" type="STRING" length="32"/>
<attribute name="CMB_PAY_NO" label="付款流水号" type="STRING" length="32"/>
<attribute name="CMB_PAY_LOG" label="付款日志" type="STRING" length="32"/>
<attribute name="DISTRIBUTOR_ID" label="经销商编号" type="STRING" length="32"/>
<attribute name="FLOWUNID" label="流程编号" type="STRING" length="32"/>
<attribute name="FACT_MONEY" label="实付款" type="STRING" length="22"/>
<attribute name="NEED_MONEY" label="应付款" type="DOUBLE" length="22" scale="2"/>
<attribute name="YURREF" label="业务参考号" type="STRING" length="32"/>
<attribute name="EPTDAT" label="期望日" type="STRING" length="32"/>
<attribute name="EPTTIM" label="期望时间" type="STRING" length="32"/>
<attribute name="DBTACC" label="付方帐号" type="STRING" length="35"/>
<attribute name="DBTBBK" label="付方开户地区代码" type="STRING" length="2"/>
<attribute name="TRSAMT" label="交易金额" type="DOUBLE" length="22" scale="2"/>
<attribute name="CCYNBR" label="币种代码" type="STRING" length="32"/>
<attribute name="STLCHN" label="结算方式代码" type="STRING" length="32"/>
<attribute name="NUSAGE" label="用途" type="STRING" length="62"/>
<attribute name="BUSNAR" label="业务摘要" type="STRING" length="1000"/>
<attribute name="CRTACC" label="收方帐号" type="STRING" length="35"/>
<attribute name="CRTNAM" label="收方帐户名" type="STRING" length="62"/>
<attribute name="LRVEAN" label="收方长户名 " type="STRING" length="200"/>
<attribute name="BRDNBR" label="收方行号" type="STRING" length="30"/>
<attribute name="BNKFLG" label="系统内外标志" type="STRING" length="1"/>
<attribute name="CRTBNK" label="收方开户行" type="STRING" length="62"/>
<attribute name="CTYCOD" label="城市代码" type="STRING" length="4"/>
<attribute name="CRTPVC" label="收方省份" type="STRING" length="18"/>
<attribute name="CRTCTY" label="收方城市" type="STRING" length="22"/>
<attribute name="CRTDTR" label="收方县/区" type="STRING" length="22"/>
<attribute name="NTFCH1" label="收方电子邮件" type="STRING" length="36"/>
<attribute name="NTFCH2" label="收方移动电话" type="STRING" length="16"/>
<attribute name="CRTSQN" label="收方编号" type="STRING" length="20"/>
<attribute name="TRSTYP" label="业务种类" type="STRING" length="6"/>
<attribute name="RCVCHK" label="行内收方账号户名校验" type="STRING" length="1"/>
<attribute name="RSVFLD" label="保留字段" type="STRING" length="27"/>
<attribute name="INPUTUSERID" label="INPUTUSERID" type="STRING" length="32"/>
<attribute name="INPUTORGID" label="INPUTORGID" type="STRING" length="32"/>
<attribute name="INPUTTIME" label="INPUTTIME" type="STRING" length="32"/>
<attribute name="UPDATEUSERID" label="UPDATEUSERID" type="STRING" length="32"/>
<attribute name="UPDATEORGID" label="UPDATEORGID" type="STRING" length="32"/>
<attribute name="UPDATETIME" label="UPDATETIME" type="STRING" length="32"/>
</attributes>
<manager>
<managerProperties>
<property name="table" value="lc_fund_income_pay_detail_temp" />
<property name="createKey" value="true" />
</managerProperties>
</manager>
</class>
<class name="LC_FUND_INCOME_PAY_INFO_TEMP" label="" keyAttributes="ID">
<attributes>
<attribute name="ID" label="ID" type="STRING" length="32"/>
<attribute name="CMB_PAY_LOG" label="付款日志" type="STRING" length="32"/>
<attribute name="CMB_PAY_NO" label="付款流水号" type="STRING" length="32"/>
<attribute name="FLOWUNID" label="流程号" type="STRING" length="32"/>
<attribute name="INFO_FUNNAM" label="函数名" type="STRING" length="20"/>
<attribute name="INFO_DATTYP" label="数据格式" type="STRING" length="1"/>
<attribute name="INFO_LGNNAM" label="登陆用户名" type="STRING" length="20"/>
<attribute name="SDKPAYRQX_BUSCOD" label="业务类别" type="STRING" length="6"/>
<attribute name="SDKPAYRQX_BUSMOD" label="业务模式编号" type="STRING" length="5"/>
<attribute name="SDKPAYRQX_MODALS" label="业务模式名称" type="STRING" length="255"/>
<attribute name="FACT_MONEY" label="实际放款金额" type="DOUBLE" length="22" scale="2"/>
<attribute name="NEED_MONEY" label="应放款金额" type="DOUBLE" length="22" scale="2"/>
<attribute name="BANK_ID" label="本方放款账号ID" type="STRING" length="32"/>
<attribute name="INPUTUSERID" label="INPUTUSERID" type="STRING" length="32"/>
<attribute name="INPUTORGID" label="INPUTORGID" type="STRING" length="32"/>
<attribute name="INPUTTIME" label="INPUTTIME" type="STRING" length="32"/>
<attribute name="UPDATEUSERID" label="UPDATEUSERID" type="STRING" length="32"/>
<attribute name="UPDATEORGID" label="UPDATEORGID" type="STRING" length="32"/>
<attribute name="UPDATETIME" label="UPDATETIME" type="STRING" length="32"/>
</attributes>
<manager>
<managerProperties>
<property name="table" value="lc_fund_income_pay_info_temp" />
<property name="createKey" value="true" />
</managerProperties>
</manager>
</class>
</package>
<package name="jbo.com.tenwa.lease.carbrand" >
<class name="LB_CLAIMS_BOOK_DETAIL" label="索赔申请书详情表" keyAttributes="ID">

View File

@ -0,0 +1,158 @@
package com.tenwa.sdk.controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.amarsoft.are.jbo.BizObject;
import com.amarsoft.are.jbo.BizObjectManager;
import com.amarsoft.are.jbo.BizObjectQuery;
import com.amarsoft.are.jbo.JBOFactory;
import com.amarsoft.are.jbo.JBOTransaction;
import com.tenwa.flow.action.comm.BaseFlowStartAction;
import com.tenwa.sdk.VO.SDKCheckCallBackVO;
import com.tenwa.sdk.VO.SDKCheckCallDetail;
import com.tenwa.sdk.VO.SDKCheckInfoVO;
import com.tenwa.sdk.VO.SDKNtstLinFxVo;
import com.tenwa.sdk.VO.SDKToCheckVO;
import com.tenwa.sdk.utils.HttpRequest;
import com.tenwa.sdk.utils.XMLStream;
import com.thoughtworks.xstream.XStream;
import jbo.com.tenwa.entity.comm.own.OWN_ACCOUNT;
import jbo.com.tenwa.lease.comm.LC_FUND_INCOME_CALLBACK_DETAIL_TEMP;
import net.sf.json.JSONObject;
public class CmbToCallbackController extends BaseFlowStartAction {
private String FLOWUNID ; //流程号
public String getFLOWUNID() {
return FLOWUNID;
}
public void setFLOWUNID(String fLOWUNID) {
FLOWUNID = fLOWUNID;
}
@SuppressWarnings("unchecked")
public String action(JBOTransaction tx) throws Exception {
Map<String,String> map = new HashMap<String,String>();
map.put("code", "0") ;
map.put("msg", "") ;
if(FLOWUNID==null || "".equals(FLOWUNID)) {
map.put("code", "1") ;
map.put("msg", "流程编号不能为空,请检查") ;
JSONObject jsonObj = JSONObject.fromObject(map);
return jsonObj.toString();
}
/*
* 本方放款账户获取######开始
*/
BizObjectManager accountManager = JBOFactory.getBizObjectManager(OWN_ACCOUNT.CLASS_NAME);
List<BizObject> accountBoList = accountManager.createQuery("select o.acc_number,o.acc_bank,o.acc_name,o.branch_code,oi.OWN_NAME from o join jbo.com.tenwa.entity.comm.own.OWN_INFO oi on o.own_id = oi.OWN_NUMBER where o.money_type='01' and o.state_='0010' and acc_type='0010' and account_type='out_account' ").getResultList(false);
if( accountBoList==null ) {
map.put("code", "1") ;
map.put("msg", "本方账户不存在,请检查") ;
JSONObject jsonObj = JSONObject.fromObject(map);
return jsonObj.toString();
}
if( accountBoList!=null && accountBoList.size()>1 ) {
map.put("code", "1") ;
map.put("msg", "启用的汽车类放款账户有多个请检查,请检查") ;
JSONObject jsonObj = JSONObject.fromObject(map);
return jsonObj.toString();
}
BizObject accountBo = accountBoList.get(0);
/*
* 本方放款账户获取######结束
*/
String LGNNAM = accountBo.getAttribute("OWN_NAME").toString();
String FUNNAM = "NTSTLINF";
int DATTYP = 2;
SDKToCheckVO toCheckVO = new SDKToCheckVO();
SDKCheckInfoVO checkInfo = new SDKCheckInfoVO();
checkInfo.setDATTYP(DATTYP);
checkInfo.setFUNNAM(FUNNAM);
checkInfo.setLGNNAM(LGNNAM);
toCheckVO.setINFO(checkInfo);
BizObjectManager call_back_list_bom = JBOFactory.getBizObjectManager(LC_FUND_INCOME_CALLBACK_DETAIL_TEMP.CLASS_NAME);
String sql = "select * from o where ( REQNBR is not null and REQNBR<>'' ) and FLOWUNID=:FLOWUNID ";
BizObjectQuery check_list_boo = call_back_list_bom.createQuery(sql);
check_list_boo.setParameter("FLOWUNID", FLOWUNID) ;
List<BizObject> check_list_bo = check_list_boo.getResultList(false);
if(check_list_bo!=null && check_list_bo.size()>0) {
List<SDKNtstLinFxVo> ntstLinFxList = new ArrayList<SDKNtstLinFxVo>();
SDKNtstLinFxVo ntstLinFxOne = null ;
for(BizObject check_list_one : check_list_bo) {
ntstLinFxOne = new SDKNtstLinFxVo();
String ONE_REQNBR = check_list_one.getAttribute("BANK_REQNBR").toString();
ntstLinFxOne.setREQNBR(ONE_REQNBR);
ntstLinFxList.add(ntstLinFxOne);
}
toCheckVO.setNtstLinFxList(ntstLinFxList);
XStream xStream = new XMLStream();
xStream.alias("NTSTLINFX", SDKNtstLinFxVo.class);
xStream.alias("CMBSDKPGK", SDKToCheckVO.class);
String xmlStr = xStream.toXML(toCheckVO);
xmlStr = xmlStr.replace("<ntstLinFxList>", "").replace("</ntstLinFxList>", "").replace("<ntstLinFxList/>", "");
HttpRequest request = new HttpRequest();
String data = xmlStr;
SDKCheckCallBackVO result = request.sendCheckRequest(data);
if(result==null) {
map.put("code", "1") ;
map.put("msg", "请求出错") ;
JSONObject jsonObj = JSONObject.fromObject(map);
return jsonObj.toString();
}
if(result.getInfo().getSTATUS()==1) {
List<SDKCheckCallDetail> callback_list = result.getDetails();
if(callback_list!=null && callback_list.size()>0) {
BizObjectManager callback_detail_bom = JBOFactory.getBizObjectManager(LC_FUND_INCOME_CALLBACK_DETAIL_TEMP.CLASS_NAME) ;
tx.join(callback_detail_bom);
BizObjectQuery callback_detail_boo = callback_detail_bom.createQuery("select * from o where REQNBR=:REQNBR and YURREF=:YURREF and FLOWUNID=:FLOWUNID");
BizObject callback_detail_bo = null ;
for(SDKCheckCallDetail callback_detail : callback_list) {
callback_detail_boo.setParameter("REQNBR",callback_detail.getREQNBR()) ;
callback_detail_boo.setParameter("YURREF",callback_detail.getYURREF()) ;
callback_detail_boo.setParameter("FLOWUNID",FLOWUNID) ;
callback_detail_bo = callback_detail_boo.getSingleResult(true);
callback_detail_bo.setAttributeValue("REQSTS",callback_detail.getREQSTS());
callback_detail_bo.setAttributeValue("RTNFLG",callback_detail.getRTNFLG());
callback_detail_bo.setAttributeValue("RTNNAR",callback_detail.getRTNNAR());
this.initTabeUserInfo(callback_detail_bo);
callback_detail_bom.saveObject(callback_detail_bo);
}
map.put("code", "0") ;
map.put("msg", "查询结果刷新成功") ;
JSONObject jsonObj = JSONObject.fromObject(map);
return jsonObj.toString();
}else {
map.put("code", "1") ;
map.put("msg", "没有找到相关数据,请检查") ;
JSONObject jsonObj = JSONObject.fromObject(map);
return jsonObj.toString();
}
}else {
map.put("code", "1") ;
map.put("msg", result.getInfo().getERRMSG()) ;
JSONObject jsonObj = JSONObject.fromObject(map);
return jsonObj.toString();
}
}else {
map.put("code", "1") ;
map.put("msg", "暂无支付申请发起成功数据,请检查") ;
JSONObject jsonObj = JSONObject.fromObject(map);
return jsonObj.toString();
}
}
}

View File

@ -0,0 +1,511 @@
package com.tenwa.sdk.controller;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import com.amarsoft.are.jbo.BizObject;
import com.amarsoft.are.jbo.BizObjectManager;
import com.amarsoft.are.jbo.BizObjectQuery;
import com.amarsoft.are.jbo.JBOFactory;
import com.amarsoft.are.jbo.JBOTransaction;
import com.tenwa.flow.action.comm.BaseFlowStartAction;
import com.tenwa.sdk.VO.SDKDcPayReqxVO;
import com.tenwa.sdk.VO.SDKInfoVO;
import com.tenwa.sdk.VO.SDKPayCallBackVO;
import com.tenwa.sdk.VO.SDKPayCallDetail;
import com.tenwa.sdk.VO.SDKPayRqxVO;
import com.tenwa.sdk.VO.SDKToPayVO;
import com.tenwa.sdk.utils.HttpRequest;
import com.tenwa.sdk.utils.XMLStream;
import com.thoughtworks.xstream.XStream;
import jbo.app.tenwa.calc.LC_FUND_INCOME_TEMP;
import jbo.com.tenwa.entity.comm.own.OWN_ACCOUNT;
import jbo.com.tenwa.lease.comm.LC_FUND_INCOME_CALLBACK_DETAIL_TEMP;
import jbo.com.tenwa.lease.comm.LC_FUND_INCOME_CALLBACK_INFO_TEMP;
import jbo.com.tenwa.lease.comm.LC_FUND_INCOME_PAY_DETAIL_TEMP;
import jbo.com.tenwa.lease.comm.LC_FUND_INCOME_PAY_INFO_TEMP;
import jbo.sys.CODE_LIBRARY;
import net.sf.json.JSONObject;
public class CmbToPayController extends BaseFlowStartAction {
private String distributor_ids; //获取选择的 经销商ID
private String FLOWUNID ; //流程号
public String getFLOWUNID() {
return FLOWUNID;
}
public void setFLOWUNID(String fLOWUNID) {
FLOWUNID = fLOWUNID;
}
public String getDistributor_ids() {
return distributor_ids;
}
public void setDistributor_ids(String distributor_ids) {
this.distributor_ids = distributor_ids;
}
@SuppressWarnings({ "unchecked", "unused" })
public synchronized String action(JBOTransaction tx) throws Exception {
/*
* 定义返回参数
*/
Map<String,String> map = new HashMap<String,String>();
map.put("code", "0") ;
map.put("msg", "") ;
/*
* 基本参数检查######开始
*/
if(FLOWUNID==null || "".equals(FLOWUNID)) {
map.put("code", "1") ;
map.put("msg", "流程编号不能为空,请检查") ;
JSONObject jsonObj = JSONObject.fromObject(map);
return jsonObj.toString();
}
List<String> distributor_id_list = java.util.Arrays.asList(distributor_ids.split("@"));
if(distributor_id_list==null || distributor_id_list.size()<=0) {
map.put("code", "1") ;
map.put("msg", "尚未选择经销商,请检查") ;
JSONObject jsonObj = JSONObject.fromObject(map);
return jsonObj.toString();
}
/*
* 基本参数检查######开始
*/
/*
* 本方放款账户获取######开始
*/
BizObjectManager accountManager = JBOFactory.getBizObjectManager(OWN_ACCOUNT.CLASS_NAME);
List<BizObject> accountBoList = accountManager.createQuery("select o.acc_number,o.acc_bank,o.acc_name,o.branch_code,oi.OWN_NAME from o join jbo.com.tenwa.entity.comm.own.OWN_INFO oi on o.own_id = oi.OWN_NUMBER where o.money_type='01' and o.state_='0010' and acc_type='0010' and account_type='out_account' ").getResultList(false);
if( accountBoList==null ) {
map.put("code", "1") ;
map.put("msg", "本方账户不存在,请检查") ;
JSONObject jsonObj = JSONObject.fromObject(map);
return jsonObj.toString();
}
if( accountBoList!=null && accountBoList.size()>1 ) {
map.put("code", "1") ;
map.put("msg", "启用的汽车类放款账户有多个请检查,请检查") ;
JSONObject jsonObj = JSONObject.fromObject(map);
return jsonObj.toString();
}
BizObject accountBo = accountBoList.get(0);
/*
* 本方放款账户获取######结束
*/
/*
* 付款申请基础信息定义######开始
*/
String LGNNAM = accountBo.getAttribute("OWN_NAME").toString();
String FUNNAM = "DCPAYREQ";
int DATTYP = 2;
String BUSMOD = "00001"; //默认参数 请按照实际情况谨慎修改
String BUSCOD = "N02030"; //默认参数 请按照实际情况谨慎修改
String DBTBBK = accountBo.getAttribute("branch_code").toString();
String DBTACC = accountBo.getAttribute("acc_number").toString();
String STLCHN = "F"; //默认参数
String CCYNBR = "10"; //默认参数
String TRSTYP = "100001"; //默认参数
String RCVCHK = "1"; //默认参数
/*
* 付款申请基础信息定义######结束
*/
/*
* 获取常用代码并将codeno存为主键 方便下面代码调用######开始
*/
BizObjectManager code_library = JBOFactory.getBizObjectManager(CODE_LIBRARY.CLASS_NAME);
List<BizObject> bank_code_list = code_library.createQuery("select codeno,itemno,itemname from o where codeno in ('bank_reqsts','bank_rtnflg','FeeType')").getResultList(false);
Map<String,String> bank_reqsts = new HashMap<String,String>(); //业务请求状态
Map<String,String> bank_rtnflg = new HashMap<String,String>(); //业务处理结果
Map<String,String> fee_type = new HashMap<String,String>(); //费用类型
for(BizObject code_bo:bank_code_list) {
String itemno = code_bo.getAttribute("itemno").toString();
String itemname = code_bo.getAttribute("itemname").toString();
String codeno = code_bo.getAttribute("codeno").toString();
if("bank_reqsts".equals(codeno)) {
bank_reqsts.put(itemno, itemname);
}else if("bank_rtnflg".equals(codeno)) {
bank_rtnflg.put(itemno, itemname);
}else {
fee_type.put(itemno, itemname);
}
}
String[] bank_reqsts_array = {"AUT","NTE","WCF","BNK","FIN","ACK","APD","OPR"};
String[] bank_rtnflg_array = {"S","F","B","R","D","C","M","V","U","T"};
List<String> bank_reqsts_list = Arrays.asList(bank_reqsts_array);
List<String> bank_rtnflg_list = Arrays.asList(bank_rtnflg_array);
/*
* 获取常用代码并将codeno存为主键 方便下面代码调用######结束
*/
/*
*
*/
SDKToPayVO sDKToPayVO = new SDKToPayVO();
SDKInfoVO sDKInfoVO = new SDKInfoVO();
SDKPayRqxVO sDKPayRqxVO = new SDKPayRqxVO();
List<SDKDcPayReqxVO> sDKDcPayReqxVOList = new ArrayList<SDKDcPayReqxVO>();
sDKInfoVO.setLGNNAM(LGNNAM);
sDKInfoVO.setFUNNAM(FUNNAM);
sDKInfoVO.setDATTYP(DATTYP);
sDKPayRqxVO.setBUSCOD(BUSCOD);
sDKPayRqxVO.setBUSMOD(BUSMOD);
BizObjectManager pay_info_bom = JBOFactory.getBizObjectManager(LC_FUND_INCOME_PAY_INFO_TEMP.CLASS_NAME);
BizObject pay_info_bo = pay_info_bom.newObject();
String CMB_PAY_NO = UUID.randomUUID().toString().replaceAll("-", "") ; // 付款流水号
pay_info_bo.setAttributeValue("ID", UUID.randomUUID().toString().replaceAll("-", ""));
pay_info_bo.setAttributeValue("FLOWUNID", FLOWUNID);
pay_info_bo.setAttributeValue("INFO_FUNNAM", FUNNAM);
pay_info_bo.setAttributeValue("INFO_DATTYP", DATTYP);
pay_info_bo.setAttributeValue("INFO_LGNNAM", LGNNAM);
pay_info_bo.setAttributeValue("SDKPAYRQX_BUSCOD", BUSCOD);
pay_info_bo.setAttributeValue("SDKPAYRQX_BUSMOD", BUSMOD);
this.initTabeUserInfo(pay_info_bo);
List<BizObject> pay_detail_list = null;// 声明 付款发起详情list
BizObjectManager bankBo = JBOFactory.getBizObjectManager(LC_FUND_INCOME_TEMP.CLASS_NAME);
BizObject infoOne = null ;
SDKDcPayReqxVO pay_detail = null ;
SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
BizObjectManager pay_detail_bom = null ;
String error_msg_tips = ""; //定义错误信息 是否存在
String error_null_tips = ""; //定义错误信息 是否为空
if(distributor_id_list.size() > 30){ //招行文档规定 单次批量申请不能超过30条
map.put("code", "1") ;
map.put("msg", "单次处理不能超过30条,请检查") ;
JSONObject jsonObj = JSONObject.fromObject(map);
return jsonObj.toString();
}
pay_detail_bom = JBOFactory.getBizObjectManager(LC_FUND_INCOME_PAY_DETAIL_TEMP.CLASS_NAME);
BizObject pay_detail_bo = null;
BizObjectManager call_back_detail_bom = JBOFactory.getBizObjectManager(LC_FUND_INCOME_CALLBACK_DETAIL_TEMP.CLASS_NAME);
BizObject call_back_detail_bo = null ;
tx.join(call_back_detail_bom);
pay_detail_list = new ArrayList<BizObject>();
String temp_str = UUID.randomUUID().toString().replaceAll("-", "").substring(0, 14) ;
String date = df.format(new Date());
BigDecimal all_money = new BigDecimal("0");
List<BizObject> income_all_list = bankBo.createQuery("select o.CMB_PAY_NO,o.FACT_MONEY,o.FLOWUNID,contract_info.CONTRACT_NO,distributor.distributor_id,distributor.acc_number,distributor.open_bank,distributor.account,distributor.district,distributor.provinceInfo from o join jbo.com.tenwa.lease.comm.LB_CONTRACT_INFO contract_info on o.CONTRACT_ID = contract_info.id join jbo.app.tenwa.customer.DISTRIBUTOR_ACCOUNT distributor on contract_info.distributor_id = distributor.distributor_id and distributor.is_main='Y' where FLOWUNID=:FLOWUNID and o.PAY_TYPE = 'pay_type_out' ").setParameter("FLOWUNID", FLOWUNID).getResultList(false);
if(income_all_list==null) {
map.put("code", "1") ;
map.put("msg", "资金收付数据不存在,请检查") ;
JSONObject jsonObj = JSONObject.fromObject(map);
return jsonObj.toString();
}
int index = 1 ;
for (String distributor_id : distributor_id_list) {
infoOne = null ;
BigDecimal distributor_all_money = new BigDecimal("0");
for(BizObject income_one : income_all_list) {
String income_one_distributor_id = income_one.getAttribute("distributor_id").toString();
if(distributor_id.equals(income_one_distributor_id)) {
BigDecimal income_one_fact_money = new BigDecimal(income_one.getAttribute("FACT_MONEY").toString());
distributor_all_money = distributor_all_money.add(income_one_fact_money);
infoOne = income_one ;
}
}
all_money=all_money.add(distributor_all_money);
if(infoOne==null) {
map.put("code", "1") ;
map.put("msg", "第["+index+"]笔数据不存在,请检查") ;
JSONObject jsonObj = JSONObject.fromObject(map);
return jsonObj.toString();
}
String FLOWUNID = this.FLOWUNID ;
String DISTRIBUTOR_ID = infoOne.getAttribute("distributor_id").toString();
String CRTACC = infoOne.getAttribute("acc_number").toString();
String BANK_NAME = infoOne.getAttribute("open_bank").toString();
String CRTNAM = infoOne.getAttribute("account").toString();
String CRTPVC = infoOne.getAttribute("provinceInfo").toString();
String CRTCTY = infoOne.getAttribute("district").toString();
String NUSAGE = infoOne.getAttribute("memo").toString();
String CMB_PAY_NO_ONE = infoOne.getAttribute("CMB_PAY_NO").toString();
/*
* 检查当前付款信息是否存在######开始
*/
if(CMB_PAY_NO_ONE!=null && CMB_PAY_NO_ONE!="" && !"".equals(CMB_PAY_NO_ONE)) {
String temp_sql = "select * from o where FLOWUNID=:FLOWUNID and CMB_PAY_NO=:CMB_PAY_NO_ONE " ;
BizObjectQuery call_back_detail_boo= call_back_detail_bom.createQuery(temp_sql);
call_back_detail_boo.setParameter("FLOWUNID",FLOWUNID) ;
call_back_detail_boo.setParameter("CMB_PAY_NO_ONE",CMB_PAY_NO_ONE) ;
call_back_detail_bo = call_back_detail_boo.getSingleResult(false) ;
if(call_back_detail_bo!=null) {
String CALL_BACK_DETAIL_REQSTS = call_back_detail_bo.getAttribute("REQSTS").toString();
String CALL_BACK_DETAIL_RTNFLG = call_back_detail_bo.getAttribute("RTNFLG").toString();
if(bank_reqsts_list.contains(CALL_BACK_DETAIL_REQSTS)) {
error_msg_tips = error_msg_tips + "第["+index+"]笔付款申请已存在[请求状态:"+bank_reqsts.get(CALL_BACK_DETAIL_REQSTS)+"]" ;
if(CALL_BACK_DETAIL_RTNFLG!="" && CALL_BACK_DETAIL_RTNFLG!=null && !"".equals(CALL_BACK_DETAIL_RTNFLG)) {
error_msg_tips = error_msg_tips+"[处理结果:"+bank_rtnflg.get(CALL_BACK_DETAIL_RTNFLG)+"]";
}
error_msg_tips = error_msg_tips+",请检查\n";
}
}
}
/*
* 检查当前付款信息是否存在######结束
*/
int check=distributor_all_money.compareTo(BigDecimal.ZERO);
if( DISTRIBUTOR_ID==null || "".equals( DISTRIBUTOR_ID )
|| CRTACC==null || "".equals( CRTACC )
|| BANK_NAME==null || "".equals( BANK_NAME )
|| CRTNAM==null || "".equals( CRTNAM )
|| CRTPVC==null || "".equals( CRTPVC )
|| CRTCTY==null || "".equals( CRTCTY )
|| CRTPVC==null || "".equals( CRTPVC )
|| check==-1
|| CRTPVC==null || "".equals( CRTPVC )
){
error_null_tips = error_null_tips+ "第["+index+"]笔相关数据不存在,请检查\n" ;
}
if(CRTPVC!=null && !"".equals(CRTPVC)) {
if(CRTCTY.indexOf(CRTPVC)!=-1) {
CRTCTY = CRTCTY.substring(CRTPVC.length());
}
}
if("6225885910000108".equals(CRTACC)) {
CRTPVC="福建";
CRTCTY="福州";
}
if("6225880230001175".equals(CRTACC)) {
CRTPVC="重庆";
CRTCTY="重庆";
}
String YURREF_INDEX = index+"" ;
if(index<10) {
YURREF_INDEX = String.format("%02d", index);
}
String TRSAMT = distributor_all_money.toPlainString();
String YURREF = YURREF_INDEX + date+ temp_str;
String BNKFLG = checkCMB(BANK_NAME);
NUSAGE = "经销商["+CRTACC+"]发起申请";
String BUSNAR = "[实际付款][经销商:"+CRTACC+"][支付金额:"+TRSAMT+"]";
pay_detail = new SDKDcPayReqxVO();
pay_detail.setYURREF(YURREF);
pay_detail.setDBTACC(DBTACC);
pay_detail.setDBTBBK(DBTBBK);
pay_detail.setTRSAMT(TRSAMT);
pay_detail.setCCYNBR(CCYNBR);
pay_detail.setSTLCHN(STLCHN);
pay_detail.setNUSAGE(NUSAGE);
pay_detail.setBUSNAR(BUSNAR);
pay_detail.setCRTACC(CRTACC);
pay_detail.setCRTNAM(CRTNAM);
pay_detail.setBNKFLG(BNKFLG);
pay_detail.setTRSTYP(TRSTYP);
pay_detail.setRCVCHK(RCVCHK);
pay_detail.setCRTPVC(CRTPVC);
pay_detail.setCRTCTY(CRTCTY);
sDKDcPayReqxVOList.add(pay_detail);
pay_detail_bo = pay_detail_bom.newObject();
pay_detail_bo.setAttributeValue("ID", UUID.randomUUID().toString().replaceAll("-", ""));
pay_detail_bo.setAttributeValue("CMB_PAY_NO", CMB_PAY_NO);
pay_detail_bo.setAttributeValue("DISTRIBUTOR_ID", DISTRIBUTOR_ID);
pay_detail_bo.setAttributeValue("FLOWUNID", FLOWUNID);
pay_detail_bo.setAttributeValue("YURREF", YURREF);
pay_detail_bo.setAttributeValue("DBTACC", DBTACC);
pay_detail_bo.setAttributeValue("DBTBBK", DBTBBK);
pay_detail_bo.setAttributeValue("TRSAMT", TRSAMT);
pay_detail_bo.setAttributeValue("CCYNBR", CCYNBR);
pay_detail_bo.setAttributeValue("STLCHN", STLCHN);
pay_detail_bo.setAttributeValue("NUSAGE", NUSAGE);
pay_detail_bo.setAttributeValue("CRTACC", CRTACC);
pay_detail_bo.setAttributeValue("CRTNAM", CRTNAM);
pay_detail_bo.setAttributeValue("BNKFLG", BNKFLG);
pay_detail_bo.setAttributeValue("TRSTYP", TRSTYP);
pay_detail_bo.setAttributeValue("RCVCHK", RCVCHK);
pay_detail_bo.setAttributeValue("CRTPVC", CRTPVC);
pay_detail_bo.setAttributeValue("CRTCTY", CRTCTY);
this.initTabeUserInfo(pay_detail_bo);
pay_detail_list.add(pay_detail_bo);
++index;
}
if(!"".equals(error_msg_tips)) {
map.put("code", "1") ;
map.put("msg", error_msg_tips) ;
JSONObject jsonObj = JSONObject.fromObject(map);
return jsonObj.toString();
}
if(!"".equals(error_null_tips)) {
map.put("code", "1") ;
map.put("msg", error_null_tips) ;
JSONObject jsonObj = JSONObject.fromObject(map);
return jsonObj.toString();
}
sDKToPayVO.setINFO(sDKInfoVO);
sDKToPayVO.setSDKPAYRQX(sDKPayRqxVO);
if(sDKDcPayReqxVOList!=null && sDKDcPayReqxVOList.size()>0) {
sDKToPayVO.setDcPayReqxList(sDKDcPayReqxVOList);
}
XStream xStream = new XMLStream();
xStream.alias("DCPAYREQX", SDKDcPayReqxVO.class);
xStream.alias("CMBSDKPGK", SDKToPayVO.class);
String xmlStr = xStream.toXML(sDKToPayVO);
xmlStr = xmlStr.replace("<dcPayReqxList>", "").replace("</dcPayReqxList>", "").replace("<dcPayReqxList/>", "");
try {
System.out.println(xmlStr); //控制台打印请求的XML数据
HttpRequest request = new HttpRequest("http://192.168.7.85:65188");
//HttpRequest request = new HttpRequest();
String data = xmlStr;
SDKPayCallBackVO result = request.sendPayRequest(data);
if(result==null) {
map.put("code", "1") ;
map.put("msg", "请求出错") ;
JSONObject jsonObj = JSONObject.fromObject(map);
return jsonObj.toString();
}
if(result.getInfo().getSTATUS()==1) {
if("0".equals( result.getInfo().getRETCOD() )) {
pay_info_bo.setAttributeValue("FACT_MONEY",all_money.toPlainString());
tx.join(pay_info_bom);// 插入支付信息表
pay_info_bom.saveObject(pay_info_bo);
if(pay_detail_bom!=null) {
BizObjectManager income_bom = JBOFactory.getBizObjectManager(LC_FUND_INCOME_TEMP.CLASS_NAME);
tx.join(pay_detail_bom);
tx.join(income_bom);
if(pay_detail_list!=null && pay_detail_list.size()>0)
for (BizObject pay_detail_one : pay_detail_list) {
BizObjectQuery income_boo= income_bom.createQuery("update o join jbo.com.tenwa.lease.comm.LB_CONTRACT_INFO lcf on o.contract_id = lcf.id set o.CMB_PAY_NO=:CMB_PAY_NO where o.PAY_TYPE = 'pay_type_out' and FLOWUNID=:FLOWUNID and lcf.distributor_id=:DISTRIBUTOR_ID");
income_boo.setParameter("CMB_PAY_NO",CMB_PAY_NO) ;
income_boo.setParameter("FLOWUNID",pay_detail_one.getAttribute("FLOWUNID").toString()) ;
income_boo.setParameter("DISTRIBUTOR_ID",pay_detail_one.getAttribute("DISTRIBUTOR_ID").toString()) ;
income_boo.executeUpdate();//更新资金收付表
pay_detail_bom.saveObject(pay_detail_one); //插入支付详情表
}
}
BizObjectManager callback_info_bom = JBOFactory.getBizObjectManager(LC_FUND_INCOME_CALLBACK_INFO_TEMP.CLASS_NAME) ;
BizObjectManager callback_detail_bom = null;
BizObject callback_info_bo = callback_info_bom.newObject();
BizObject callback_detail_bo = null;
tx.join(callback_info_bom);
callback_info_bo.setAttributeValue("ID", UUID.randomUUID().toString().replaceAll("-", ""));
callback_info_bo.setAttributeValue("CMB_PAY_NO",CMB_PAY_NO);
callback_info_bo.setAttributeValue("FLOWUNID",FLOWUNID);
callback_info_bo.setAttributeValue("INFO_FUNNAM",FUNNAM);
callback_info_bo.setAttributeValue("INFO_DATTYP",DATTYP);
callback_info_bo.setAttributeValue("INFO_RETCOD",result.getInfo().getRETCOD());
callback_info_bo.setAttributeValue("INFO_ERRMSG",result.getInfo().getERRMSG());
this.initTabeUserInfo(callback_info_bo);
callback_info_bom.saveObject(callback_info_bo); //插入支付回调信息表
List<SDKPayCallDetail> details = result.getDetails() ;
String error_info = "";
if(details!=null && details.size()>0) {
callback_detail_bom = JBOFactory.getBizObjectManager(LC_FUND_INCOME_CALLBACK_DETAIL_TEMP.CLASS_NAME) ;
tx.join(callback_detail_bom);
int call_index = 1 ;
for (SDKPayCallDetail detail : details) {
if (detail.getREQSTS().equals("FIN") && detail.getRTNFLG().equals("F")) {
error_info= error_info+"\n"+ "第["+call_index+"]笔数据 "+detail.getERRTXT() ;
}
callback_detail_bo = callback_detail_bom.newObject();
String DETAIL_YURREF = detail.getYURREF() ;
callback_detail_bo.setAttributeValue("ID", UUID.randomUUID().toString().replaceAll("-", ""));
callback_detail_bo.setAttributeValue("CMB_PAY_NO",CMB_PAY_NO);
callback_detail_bo.setAttributeValue("YURREF",DETAIL_YURREF);
callback_detail_bo.setAttributeValue("SQRNBR",detail.getSQRNBR());
callback_detail_bo.setAttributeValue("REQNBR",detail.getREQNBR());
callback_detail_bo.setAttributeValue("REQSTS",detail.getREQSTS());
callback_detail_bo.setAttributeValue("RTNFLG",detail.getRTNFLG());
callback_detail_bo.setAttributeValue("OPRSQN",detail.getOPRSQN());
callback_detail_bo.setAttributeValue("OPRALS",detail.getOPRALS());
callback_detail_bo.setAttributeValue("ERRCOD",detail.getERRCOD());
callback_detail_bo.setAttributeValue("ERRTXT",detail.getERRTXT());
this.initTabeUserInfo(callback_detail_bo);
callback_detail_bom.saveObject(callback_detail_bo);//插入支付回调详情表
++call_index;
}
}
if(error_info==""){
map.put("code", "0") ;
map.put("msg", "受理成功,请耐心等待审核") ;
JSONObject jsonObj = JSONObject.fromObject(map);
return jsonObj.toString();
}else {
map.put("code", "2") ;
map.put("msg", "部分发起申请失败,请检查"+error_info) ;
JSONObject jsonObj = JSONObject.fromObject(map);
return jsonObj.toString();
}
}else {
map.put("code", "1") ;
map.put("msg", result.getInfo().getERRMSG()) ;
JSONObject jsonObj = JSONObject.fromObject(map);
return jsonObj.toString();
}
}else {
map.put("code", "1") ;
map.put("msg", result.getInfo().getERRMSG()) ;
JSONObject jsonObj = JSONObject.fromObject(map);
return jsonObj.toString();
}
} catch (Exception e) {
map.put("code", "1") ;
map.put("msg", e.getMessage()) ;
JSONObject jsonObj = JSONObject.fromObject(map);
return jsonObj.toString();
}
}
private String checkCMB(String str) {
if (str.indexOf("招行") != -1 || str.indexOf("招商银行") != -1) {
return "Y";
} else {
return "N";
}
}
}