Commit ddd463b3 authored by 5359's avatar 5359

正式环境参数修改

parent 3df42561
......@@ -278,6 +278,15 @@
${project.basedir}/src/main/webapp/WEB-INF/lib/rfsp-api-1.6.jar
</systemPath>
</dependency>
<dependency>
<groupId>com.chinapay.secss</groupId>
<artifactId>chinapaysecure1_5</artifactId>
<version>1.5</version>
<scope>system</scope>
<systemPath>
${project.basedir}/src/main/webapp/WEB-INF/lib/chinapaysecure1_5.jar
</systemPath>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
......
......@@ -74,6 +74,12 @@ public class HlsEbankCcbTransaction extends BaseDTO {
private String userId;
private String qrCode;
private String cmbOrderId;
private String txnTime;
public Long getTransactionId() {
return transactionId;
}
......@@ -249,4 +255,28 @@ public class HlsEbankCcbTransaction extends BaseDTO {
public void setUserId(String userId) {
this.userId = userId;
}
public String getQrCode() {
return qrCode;
}
public void setQrCode(String qrCode) {
this.qrCode = qrCode;
}
public String getCmbOrderId() {
return cmbOrderId;
}
public void setCmbOrderId(String cmbOrderId) {
this.cmbOrderId = cmbOrderId;
}
public String getTxnTime() {
return txnTime;
}
public void setTxnTime(String txnTime) {
this.txnTime = txnTime;
}
}
\ No newline at end of file
/**
/**
* Copyright (C), 2018-2021
* FileName: HclcCupSignInfo
* Author: lsy
......@@ -26,7 +26,7 @@ import java.util.Date;
*/
@Table(name = "ld037")
@ExtensionAttribute(disable = true)
public class Ld037{
public class Ld037 {
@Id
@GeneratedValue
private Long id;
......@@ -89,6 +89,12 @@ public class Ld037{
private Long num;
private Date procdt;
private Date recdt;
private Date recbatchdt;
public Long getId() {
return id;
}
......@@ -328,4 +334,28 @@ public class Ld037{
public void setNum(Long num) {
this.num = num;
}
public Date getProcdt() {
return procdt;
}
public void setProcdt(Date procdt) {
this.procdt = procdt;
}
public Date getRecdt() {
return recdt;
}
public void setRecdt(Date recdt) {
this.recdt = recdt;
}
public Date getRecbatchdt() {
return recbatchdt;
}
public void setRecbatchdt(Date recbatchdt) {
this.recbatchdt = recbatchdt;
}
}
\ No newline at end of file
package com.cmb.mapper;
import com.cmb.dto.Ld037;
import com.hand.hap.mybatis.common.Mapper;
/**
* Created with IntelliJ IDEA.
* User: lsy
* Date: 2020/2/24
* Time: 9:08
*/
public interface Ld037Mapper extends Mapper<Ld037> {
void updateLd037Fail(Ld037 ld037);
}
......@@ -13,6 +13,8 @@ import com.cmb.util.SM2Util;
import com.cmb.util.SignatureUtil;
import com.cmb.util.Utils;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.hand.app.zhongDengWang.dto.HlsWsRequests;
import com.hand.app.zhongDengWang.mapper.HlsWsRequestsMapper;
import com.hand.hap.core.IRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -37,6 +39,18 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
public static final String appId = "8ab74856-8772-45c9-96db-54cb30ab9f74";
public static final String appSecret = "5b96f20a-011f-4254-8be8-9a5ceb2f317f";
/*接口区分*/
public static final String getQrCode = "GET_QR_CODE";
/*代扣交易状态*/
public static final String transNew = "NEW";
public static final String transDeal = "DEAL";
public static final String transFail = "FAIL";
/*交易结果状态*/
public static final String cmbSuccess = "SUCCESS";
public static final String cmbFail = "FAIL";
@Value("${cmb.version}")
private String version;
@Value("${cmb.encoding}")
......@@ -51,12 +65,15 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
@Autowired
private HlsEbankCcbTransactionMapper hlsEbankCcbTransactionMapper;
@Autowired
private HlsWsRequestsMapper hlsWsRequestsMapper;
@Autowired
private Ld037Mapper ld037Mapper;
private Logger logger = LoggerFactory.getLogger(getClass());
@Override
public JSONObject getQrcode(IRequest iRequest, JSONObject params) {
JSONObject result = new JSONObject();
String resultType = null;
if (Objects.isNull(params.get("recamt_id"))) {
result.put(Constants.RESP_CODE, "E");
......@@ -76,9 +93,12 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
String signResult = getQrRequestParams(hlsEbankCcbTransaction);
if (Objects.isNull(signResult)) {
result.put(Constants.RESP_CODE, "E");
result.put("respMsg", "收款码申请加签发生异常,请检查!");
result.put(Constants.RESP_MSG, "收款码申请加签发生异常,请检查!");
return result;
}
Map<String, String> response = null;
try {
ObjectMapper mapper = new ObjectMapper();
Map<String, String> signResultMap = mapper.readValue(signResult, Map.class);
......@@ -101,8 +121,70 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
apiHeader.put("timestamp", "" + currentTimeMills);
apiHeader.put("apisign", apiSignString);
// 发送HTTP post请求
Map<String, String> response = Utils.postForEntity(url, signResult, apiHeader);
//初始化日志
HlsWsRequests hlsWsRequests = logInterfaceRequest(getQrCode, url, mapper.writeValueAsString(apiHeader), hlsEbankCcbTransaction.getTransactionId());
logger.info("发送收款码申请请求,请求参数: {}", mapper.writeValueAsString(apiHeader));
try {
// 发送HTTP post请求
response = Utils.postForEntity(url, signResult, apiHeader);
//处理接口日志
logger.info("收款码申请返回结果:" + mapper.writeValueAsString(response));
hlsWsRequests.setResponseClob(mapper.writeValueAsString(response));
hlsWsRequests.setReturnStatus("S");
hlsWsRequests.setResponsedDate(new Date());
// 返回结果验签,验证数据的正确性(安全性)
Boolean checkResult1 = checkSign(mapper.writeValueAsString(response));
//数据验签成功
if (checkResult1) {
//获取返回码,返回码不为SUCCESS表示报文内的字段不符合规范
String returnCode = response.get("returnCode");
if ("SUCCESS".equalsIgnoreCase(returnCode)) {
//响应码
String respCode = response.get("returnCode");
if ("SUCCESS".equalsIgnoreCase(respCode)) {
resultType = "1";
} else {
resultType = "2";
}
} else {
resultType = "3";
}
if (!"1".equalsIgnoreCase(resultType)) {
//更新现金事务表ld037失败处理
updateLd037Fail(ld037, response.get("errCode"));
}
}
//数据验签失败
else {
//更新现金事务表ld037失败处理
updateLd037Fail(ld037, "SIGN_ERROR");
//直接返回前端验签失败信息,重发或者直接告诉前端发送失败
resultType = "4";
}
} catch (Exception e) {
e.printStackTrace();
logger.info("发送请求异常: {} ", e.getMessage());
//更新现金事务表ld037失败处理
updateLd037Fail(ld037, "SEND_ERROR");
//处理接口日志
hlsWsRequests.setReturnStatus("E");
hlsWsRequests.setResponsedDate(new Date());
//请求批次事务表状态更新失败处理
hlsEbankCcbTransaction.setReturnMsg(e.getMessage());
result.put(Constants.RESP_MSG, "发送请求异常:" + e.getMessage());
resultType = "5";
}
hlsWsRequestsMapper.updateByPrimaryKeySelective(hlsWsRequests);
/*
版本号 version String(5) 是 固定为0.0.1
编码方式 encoding String(20) 是 固定为UTF-8
......@@ -121,27 +203,99 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
错误码 errCode String(32) 是 请求处理失败的错误码信息
应答信息 respMsg String(256) 是 请求处理失败的详细描述信息
*/
} catch (Exception e) {
e.printStackTrace();
logger.info("组装请求报文信息失败: {} ", e.getMessage());
logger.info("收款码申请返回结果:" + mapper.writeValueAsString(response));
//更新现金事务表ld037失败处理
updateLd037Fail(ld037, "MESSAGE_ERROR");
// 返回结果验签,验证数据的正确性(安全性)
Boolean checkResult1 = checkSign(mapper.writeValueAsString(response));
if (!checkResult1) {
//数据验签失败的处理,重发或者直接告诉前端发送失败
result.put("respCode", response.get("errCode"));
}
//获取响应结果内容
String success = response.get("returnCode");
System.out.println("返回结果:" + success);
//请求批次事务表状态更新失败处理
hlsEbankCcbTransaction.setReturnMsg("组装请求报文信息失败:" + e.getMessage());
result.put(Constants.RESP_MSG, "组装请求报文信息失败:" + e.getMessage());
resultType = "5";
}
setEbankTransaction(hlsEbankCcbTransaction, response, resultType);
hlsEbankCcbTransactionMapper.updateByPrimaryKeySelective(hlsEbankCcbTransaction);
result = putResult(result, response, resultType);
return result;
}
private JSONObject putResult(JSONObject result, Map<String, String> response, String type) {
//接口请求成功
if ("1".equalsIgnoreCase(type)) {
result.put(Constants.RESP_CODE, response.get("returnCode"));
result.put(Constants.RESP_MSG, "请求成功");
result.put("qrcode", response.get("qrcode"));
result.put("respMsg", response.get("respMsg"));
//业务数据的封装。。。
return result;
} catch (Exception e) {
e.printStackTrace();
result.put("respCode", "服务器问题");
return result;
result.put("cmborderid", response.get("cmbOrderId"));
result.put("txnTime", response.get("txnTime"));
}
//接口返回成功,响应失败
else if ("2".equalsIgnoreCase(type)) {
result.put(Constants.RESP_CODE, response.get("errCode"));
result.put(Constants.RESP_MSG, response.get("respMsg"));
}
//接口返回失败
else if ("3".equalsIgnoreCase(type)) {
result.put(Constants.RESP_CODE, response.get("errCode"));
result.put(Constants.RESP_MSG, response.get("respMsg"));
}
//验签失败
else if ("4".equalsIgnoreCase(type)) {
result.put(Constants.RESP_CODE, cmbFail);
result.put(Constants.RESP_MSG, "验签失败,请检查!");
}
//组装请求报文信息失败
else if ("5".equalsIgnoreCase(type)) {
result.put(Constants.RESP_CODE, cmbFail);
}
return result;
}
private HlsEbankCcbTransaction setEbankTransaction(HlsEbankCcbTransaction hlsEbankCcbTransaction, Map<String, String> response, String type) {
//接口请求成功
if ("1".equalsIgnoreCase(type)) {
hlsEbankCcbTransaction.setStatus(transDeal);
hlsEbankCcbTransaction.setQrCode(response.get("qrCode"));
hlsEbankCcbTransaction.setCmbOrderId(response.get("cmbOrderId"));
hlsEbankCcbTransaction.setTxnTime(response.get("txnTime"));
}
//接口返回成功,响应失败
else if ("2".equalsIgnoreCase(type)) {
hlsEbankCcbTransaction.setStatus(transFail);
hlsEbankCcbTransaction.setReturnCode(response.get("errCode"));
hlsEbankCcbTransaction.setReturnMsg(response.get("respMsg"));
hlsEbankCcbTransaction.setOrderStatus("0000");
}
//接口返回失败
else if ("3".equalsIgnoreCase(type)) {
hlsEbankCcbTransaction.setStatus(transFail);
hlsEbankCcbTransaction.setReturnCode(response.get("errCode"));
hlsEbankCcbTransaction.setReturnMsg(response.get("respMsg"));
hlsEbankCcbTransaction.setOrderStatus("0003");
}
//验签失败
else if ("4".equalsIgnoreCase(type)) {
hlsEbankCcbTransaction.setStatus(transFail);
hlsEbankCcbTransaction.setReturnCode("SIGN_ERROR");
hlsEbankCcbTransaction.setReturnMsg("接口请求验签失败");
hlsEbankCcbTransaction.setOrderStatus("0003");
}
//组装请求报文信息失败
else if ("5".equalsIgnoreCase(type)) {
hlsEbankCcbTransaction.setStatus(transFail);
hlsEbankCcbTransaction.setReturnCode("SEND_ERROR");
hlsEbankCcbTransaction.setOrderStatus("0003");
}
return hlsEbankCcbTransaction;
}
private void updateLd037Fail(Ld037 ld037, String errorCd) {
ld037.setErrorcd(errorCd);
ld037Mapper.updateLd037Fail(ld037);
}
//生成招行扫码交易业务批次数据
......@@ -150,7 +304,7 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
ccbTransaction.setMerId("3089991701201D0");
ccbTransaction.setVersion("0.0.1");
ccbTransaction.setUserId("N003574551");
ccbTransaction.setStatus("NEW");
ccbTransaction.setStatus(transNew);
ccbTransaction.setBankType("CMB");
ccbTransaction.setCount(1L);
ccbTransaction.setAmount(ld037.getAmount());
......@@ -265,4 +419,34 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
return null;
}
public HlsWsRequests logInterfaceRequest(String functionName, String url, String request, Long pkValue) {
HlsWsRequests hlsWsRequests = new HlsWsRequests();
hlsWsRequests.setRequestDate(new Date());
hlsWsRequests.setRequestWsdlUrl(url);
hlsWsRequests.setFunctionName(functionName);
String tableName = getTableName(functionName);
hlsWsRequests.setTableName(tableName);
hlsWsRequests.setStatusCode("1");
hlsWsRequests.setStatusDate(new Date());
hlsWsRequests.setPkValue(pkValue);
hlsWsRequests.setRequestClob(request);
hlsWsRequestsMapper.insertSelective(hlsWsRequests);
return hlsWsRequests;
}
private String getTableName(String functionName) {
String tableName = "";
if ("GET_QR_CODE".equalsIgnoreCase(functionName)) {
tableName = "HLS_EBANK_CCB_TRANSACTION";
} else if ("QUERY_PAY_RESULT".equalsIgnoreCase(functionName)) {
tableName = "HLS_EBANK_CMB_QUERY";
}
return tableName;
}
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.cmb.mapper.Ld037Mapper">
<!--获取角色下的模块-->
<resultMap id="AppLd037Map" type="com.cmb.dto.Ld037">
<result column="ID" property="id" jdbcType="VARCHAR"/>
<result column="CONTRACTNO" property="contractno" jdbcType="VARCHAR"/>
<result column="TIMES" property="times" jdbcType="DECIMAL"/>
<result column="generatedt" property="generatedt" jdbcType="Date"/>
<result column="recamtno" property="recamtno" jdbcType="VARCHAR"/>
<result column="recduedt" property="recduedt" jdbcType="Date"/>
<result column="bankname" property="bankname" jdbcType="VARCHAR"/>
<result column="accountid" property="accountid" jdbcType="VARCHAR"/>
<result column="accountname" property="accountname" jdbcType="VARCHAR"/>
<result column="amount" property="amount" jdbcType="DECIMAL"/>
<result column="filestatus" property="filestatus" jdbcType="VARCHAR"/>
<result column="receiptstatus" property="receiptstatus" jdbcType="VARCHAR"/>
<result column="receiptcfmstatus" property="receiptcfmstatus" jdbcType="VARCHAR"/>
<result column="errorcd" property="errorcd" jdbcType="VARCHAR"/>
<result column="dealercd" property="dealercd" jdbcType="VARCHAR"/>
<result column="branchcd" property="branchcd" jdbcType="VARCHAR"/>
<result column="customercd" property="customercd" jdbcType="VARCHAR"/>
<result column="customername" property="customername" jdbcType="VARCHAR"/>
<result column="outfilename" property="outfilename" jdbcType="VARCHAR"/>
<result column="infilename" property="infilename" jdbcType="VARCHAR"/>
<result column="characterid" property="characterid" jdbcType="VARCHAR"/>
<result column="errormsg" property="errormsg" jdbcType="VARCHAR"/>
<result column="chargeaccountno" property="chargeaccountno" jdbcType="VARCHAR"/>
<result column="actdbtamount" property="actdbtamount" jdbcType="DECIMAL"/>
<result column="version" property="version" jdbcType="VARCHAR"/>
<result column="ctino" property="ctino" jdbcType="VARCHAR"/>
<result column="cup_pin" property="cup_pin" jdbcType="VARCHAR"/>
<result column="phone" property="phone" jdbcType="VARCHAR"/>
<result column="transaction_id" property="transaction_id" jdbcType="DECIMAL"/>
<result column="num" property="num" jdbcType="DECIMAL"/>
<result column="procdt" property="procdt" jdbcType="Date"/>
<result column="recdt" property="recdt" jdbcType="Date"/>
<result column="recbatchdt" property="recbatchdt" jdbcType="Date"/>
</resultMap>
<update id="updateLd037Fail" parameterType="com.cmb.dto.Ld037">
UPDATE LD037
SET LD037.ProcDt = sysdate, /*文件处理日期*/
LD037.RecDt = sysdate, /*文件返回系统日期*/
LD037.RecBatchDt = sysdate, /*文件返回批处理日期*/
LD037.ReceiptStatus = '0', /*扣款成功与否状态*/
LD037.ReceiptCfmStatus = '1', /*扣款结果信息确认状态*/
LD037.ERRORMSG = (select h.description from hls_ebank_cmb_recode h where h.code=#{errorcd}), /*错误代码*/
LD037.ErrorCd = #{errorcd}, /*错误信息*/
LD037.UPDATEDDT = SYSDATE, /*更新日期*/
LD037.UPDATEDPERSON = 'CMB', /*更新者*/
LD037.Actdbtamount = 0 /* 实际扣款金额 */
WHERE LD037.id = #{id};
</update>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment