Commit ffded0b9 authored by 5359's avatar 5359

获取支付二维码接口代码调整

parent e57ef08c
package com.chinapay.service;
import com.alibaba.fastjson.JSONObject;
import com.chinapay.dto.HclcCupSignInfo;
import com.chinapay.dto.HlsEbankCcbTransaction;
import com.hand.hap.core.IRequest;
import com.hand.hap.core.ProxySelf;
import com.hand.hap.system.service.IBaseService;
/**
* Created with IntelliJ IDEA.
* User: lsy
* Date: 2020/2/24
* Time: 9:08
*/
public interface IHlsEbankCcbTransactionService extends IBaseService<HlsEbankCcbTransaction>, ProxySelf<IHlsEbankCcbTransactionService> {
}
package com.chinapay.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.chinapay.comm.Constants;
import com.chinapay.dto.HclcCupSignInfo;
import com.chinapay.dto.HlsEbankCcbTransaction;
import com.chinapay.dto.HlsWsConfig;
import com.chinapay.mapper.HclcCupSignInfoMapper;
import com.chinapay.mapper.HlsEbankCcbTransactionMapper;
import com.chinapay.mapper.HlsWsConfigMapper;
import com.chinapay.secss.SecssConstants;
import com.chinapay.secss.SecssUtil;
import com.chinapay.service.IHclcChinaPayService;
import com.chinapay.service.IHlsEbankCcbTransactionService;
import com.chinapay.util.HttpUtils;
import com.chinapay.util.StringUtil;
import com.hand.app.zhongDengWang.dto.HlsWsRequests;
import com.hand.app.zhongDengWang.mapper.HlsWsRequestsMapper;
import com.hand.hap.core.IRequest;
import com.hand.hap.intergration.service.IHapInterfaceHeaderService;
import com.hand.hap.system.service.impl.BaseServiceImpl;
import org.apache.commons.codec.binary.Base64;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.*;
import java.util.*;
/**
* Created with IntelliJ IDEA.
* User: lsy
* Date: 2020/2/24
* Time: 9:08
*/
@Service
public class HlsEbankCcbTransactionServiceImpl extends BaseServiceImpl<HlsEbankCcbTransaction> implements IHlsEbankCcbTransactionService {
}
......@@ -171,7 +171,7 @@ public class StringUtil {
Double amount=106.02D;
BigDecimal a1 = new BigDecimal(Double.toString(amount));
BigDecimal b1 = new BigDecimal(Double.toString(100));
System.out.println(a1.multiply(b1).longValue());
System.out.println(a1.multiply(b1).stripTrailingZeros());
}
/**
......
......@@ -8,11 +8,11 @@
* <author> <time> <version> <desc>
* lishuangyi 修改时间 版本号 描述
*/
package com.cmb.controllers;
package com.hand.app.cmb.controllers;
import com.alibaba.fastjson.JSONObject;
import com.chinapay.service.IHclcChinaPayService;
import com.cmb.service.HclcCmbPolyService;
import com.hand.app.cmb.service.HclcCmbPolyService;
import com.hand.hap.core.IRequest;
import com.hand.hap.system.controllers.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -31,6 +31,7 @@ import javax.servlet.http.HttpServletRequest;
* @since 1.0.0
*/
@Controller
@RequestMapping(value = {"/r/api", "/"})
public class HclcCmbPolyController extends BaseController {
@Autowired
......
package com.hand.app.cmb.controllers;
import com.alibaba.fastjson.JSONObject;
import com.hand.app.esignHclc.service.ISignInfoHclcFaceService;
import com.hand.app.esignHclc.service.ISignInfoHclcService;
import com.hand.hap.system.controllers.BaseController;
import com.hand.hap.system.dto.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
/**
* Created with IntelliJ IDEA.
* User: lsy
* Date: 2020/2/25
* Time: 21:32
*/
@Controller
public class HclcCmbPolyListenController extends BaseController {
@Autowired
private ISignInfoHclcFaceService iSignInfoHclcFaceService;
@Autowired
private ISignInfoHclcService iSignInfoHclcService;
@ResponseBody
@RequestMapping(value = "/api/public/cmb/get/qr/code/listen", method = RequestMethod.POST)
public JSONObject chinaSignListen(HttpServletRequest request) {
JSONObject responseData = new JSONObject();
return responseData;
}
}
......@@ -8,7 +8,7 @@
* <author> <time> <version> <desc>
* lishuangyi 修改时间 版本号 描述
*/
package com.cmb.dto;
package com.hand.app.cmb.dto;
import com.hand.hap.mybatis.annotation.ExtensionAttribute;
......
package com.cmb.mapper;
package com.hand.app.cmb.mapper;
import com.cmb.dto.Ld037;
import com.hand.app.cmb.dto.Ld037;
import com.hand.hap.mybatis.common.Mapper;
/**
......
package com.cmb.service;
package com.hand.app.cmb.service;
import com.alibaba.fastjson.JSONObject;
import com.hand.hap.core.IRequest;
......
package com.cmb.service.impl;
package com.hand.app.cmb.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.chinapay.comm.Constants;
import com.chinapay.dto.HlsEbankCcbTransaction;
import com.chinapay.mapper.HlsEbankCcbTransactionMapper;
import com.chinapay.secss.LogUtil;
import com.cmb.dto.Ld037;
import com.cmb.mapper.Ld037Mapper;
import com.cmb.service.HclcCmbPolyService;
import com.cmb.util.MD5Utils;
import com.cmb.util.SM2Util;
import com.cmb.util.SignatureUtil;
import com.cmb.util.Utils;
import com.chinapay.service.IHlsEbankCcbTransactionService;
import com.chinapay.util.StringUtil;
import com.hand.app.cmb.dto.Ld037;
import com.hand.app.cmb.mapper.Ld037Mapper;
import com.hand.app.cmb.dto.Ld037;
import com.hand.app.cmb.mapper.Ld037Mapper;
import com.hand.app.cmb.service.HclcCmbPolyService;
import com.hand.app.cmb.util.MD5Utils;
import com.hand.app.cmb.util.SM2Util;
import com.hand.app.cmb.util.SignatureUtil;
import com.hand.app.cmb.util.Utils;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.hand.app.zhongDengWang.dto.HlsWsRequests;
import com.hand.app.zhongDengWang.mapper.HlsWsRequestsMapper;
......@@ -65,6 +70,8 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
@Autowired
private HlsEbankCcbTransactionMapper hlsEbankCcbTransactionMapper;
@Autowired
private IHlsEbankCcbTransactionService hlsEbankCcbTransactionService;
@Autowired
private HlsWsRequestsMapper hlsWsRequestsMapper;
@Autowired
private Ld037Mapper ld037Mapper;
......@@ -74,6 +81,7 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
public JSONObject getQrcode(IRequest iRequest, JSONObject params) {
JSONObject result = new JSONObject();
String resultType = null;
String errorCd = null;
if (Objects.isNull(params.get("recamt_id"))) {
result.put(Constants.RESP_CODE, "E");
......@@ -86,7 +94,19 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
Ld037 ld037 = new Ld037();
ld037.setId(recamtId);
ld037 = ld037Mapper.selectByPrimaryKey(ld037);
HlsEbankCcbTransaction hlsEbankCcbTransaction = createTransaction(ld037);
if (Objects.nonNull(ld037.getReceiptstatus())) {
result.put(Constants.RESP_CODE, "E");
result.put("respMsg", "支付订单状态异常,请检查!");
return result;
}
HlsEbankCcbTransaction hlsEbankCcbTransaction = createTransaction(iRequest, ld037);
//生成单据编号 日期+id
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
String dateString = formatter.format(new Date());
hlsEbankCcbTransaction.setTransactionNumber(dateString + String.format("%08d", hlsEbankCcbTransaction.getTransactionId()));
// Map<String, String> requestPublicParams = JSONObject.parseObject(params.toJSONString(), Map.class);
// 组装requestBody并加签
......@@ -155,13 +175,13 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
if (!"1".equalsIgnoreCase(resultType)) {
//更新现金事务表ld037失败处理
updateLd037Fail(ld037, response.get("errCode"));
errorCd = response.get("errCode");
}
}
//数据验签失败
else {
//更新现金事务表ld037失败处理
updateLd037Fail(ld037, "SIGN_ERROR");
errorCd = "SIGN_ERROR";
//直接返回前端验签失败信息,重发或者直接告诉前端发送失败
resultType = "4";
......@@ -171,7 +191,7 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
logger.info("发送请求异常: {} ", e.getMessage());
//更新现金事务表ld037失败处理
updateLd037Fail(ld037, "SEND_ERROR");
errorCd = "SEND_ERROR";
//处理接口日志
hlsWsRequests.setReturnStatus("E");
......@@ -207,18 +227,21 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
e.printStackTrace();
logger.info("组装请求报文信息失败: {} ", e.getMessage());
//更新现金事务表ld037失败处理
updateLd037Fail(ld037, "MESSAGE_ERROR");
//请求批次事务表状态更新失败处理
hlsEbankCcbTransaction.setReturnMsg("组装请求报文信息失败:" + e.getMessage());
result.put(Constants.RESP_MSG, "组装请求报文信息失败:" + e.getMessage());
errorCd = "MESSAGE_ERROR";
resultType = "5";
}
hlsEbankCcbTransaction = setEbankTransaction(hlsEbankCcbTransaction, response, resultType);
hlsEbankCcbTransactionMapper.updateByPrimaryKeySelective(hlsEbankCcbTransaction);
hlsEbankCcbTransactionMapper.updateByPrimaryKey(hlsEbankCcbTransaction);
//更新现金事务表ld037失败处理
if (Objects.nonNull(errorCd)) {
updateLd037Fail(ld037, errorCd);
}
result = putResult(result, response, resultType);
return result;
......@@ -227,11 +250,13 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
private JSONObject putResult(JSONObject result, Map<String, String> response, String type) {
//接口请求成功
if ("1".equalsIgnoreCase(type)) {
JSONObject bizContent = new JSONObject();
bizContent = JSONObject.parseObject(response.get("biz_content").toString());
result.put(Constants.RESP_CODE, response.get("returnCode"));
result.put(Constants.RESP_MSG, "请求成功");
result.put("qrcode", response.get("qrcode"));
result.put("cmborderid", response.get("cmbOrderId"));
result.put("txnTime", response.get("txnTime"));
result.put("qrcode", bizContent.getString("qrCode"));
result.put("cmborderid", bizContent.getString("cmbOrderId"));
result.put("txnTime", bizContent.getString("txnTime"));
}
//接口返回成功,响应失败
else if ("2".equalsIgnoreCase(type)) {
......@@ -258,10 +283,15 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
private HlsEbankCcbTransaction setEbankTransaction(HlsEbankCcbTransaction hlsEbankCcbTransaction, Map<String, String> response, String type) {
//接口请求成功
if ("1".equalsIgnoreCase(type)) {
JSONObject bizContent = new JSONObject();
bizContent = JSONObject.parseObject(response.get("biz_content").toString());
hlsEbankCcbTransaction.setStatus(transDeal);
hlsEbankCcbTransaction.setQrCode(response.get("qrCode"));
hlsEbankCcbTransaction.setCmbOrderId(response.get("cmbOrderId"));
hlsEbankCcbTransaction.setTxnTime(response.get("txnTime"));
hlsEbankCcbTransaction.setReturnCode(response.get("returnCode"));
hlsEbankCcbTransaction.setReturnMsg("获取二维码成功");
hlsEbankCcbTransaction.setQrCode(bizContent.getString("qrCode"));
hlsEbankCcbTransaction.setCmbOrderId(bizContent.getString("cmbOrderId"));
hlsEbankCcbTransaction.setTxnTime(bizContent.getString("txnTime"));
hlsEbankCcbTransaction.setOrderStatus("0000");
}
//接口返回成功,响应失败
else if ("2".equalsIgnoreCase(type)) {
......@@ -299,7 +329,7 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
}
//生成招行扫码交易业务批次数据
private HlsEbankCcbTransaction createTransaction(Ld037 ld037) {
private HlsEbankCcbTransaction createTransaction(IRequest iRequest, Ld037 ld037) {
HlsEbankCcbTransaction ccbTransaction = new HlsEbankCcbTransaction();
ccbTransaction.setMerId("3089991701201D0");
ccbTransaction.setVersion("0.0.1");
......@@ -311,16 +341,20 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
ccbTransaction.setNewDate(new Date());
ccbTransaction.setCreatedBy(1L);
ccbTransaction.setCreationDate(new Date());
ccbTransaction.setLastUpdatedBy(1L);
ccbTransaction.setTranDate(StringUtil.getRelevantDate(new Date()));
ccbTransaction.setTranTime(StringUtil.getRelevantTime(new Date()));
ccbTransaction.setTranType("APPLY");
hlsEbankCcbTransactionMapper.insert(ccbTransaction);
//生成单据编号 日期+id
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
String dateString = formatter.format(new Date());
ccbTransaction.setTransactionNumber(dateString + String.format("%08d", ccbTransaction.getTransactionId()));
hlsEbankCcbTransactionMapper.updateByPrimaryKeySelective(ccbTransaction);
// //生成单据编号 日期+id
// SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
// String dateString = formatter.format(new Date());
// ccbTransaction.setTransactionNumber(dateString + String.format("%08d", ccbTransaction.getTransactionId()));
// ccbTransaction = hlsEbankCcbTransactionService.updateByPrimaryKeySelective(iRequest, ccbTransaction);
return ccbTransaction;
return hlsEbankCcbTransactionMapper.selectByPrimaryKey(ccbTransaction);
}
private String getQrRequestParams(HlsEbankCcbTransaction hlsEbankCcbTransaction) {
......@@ -339,11 +373,11 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
requestTransactionParams.put("userId", hlsEbankCcbTransaction.getUserId()); //收银员
// requestTransactionParams.put("termId", "00774411"); //终端号
requestTransactionParams.put("payValidTime", "900"); //支付有效时间,默认15分钟
requestTransactionParams.put("notifyUrl", ""); //交易通知地址(必传)
requestTransactionParams.put("notifyUrl", "http://sign.hitachics.com/core/api/public/cmb/get/qr/code/listen"); //交易通知地址(必传)
BigDecimal a1 = new BigDecimal(Double.toString(hlsEbankCcbTransaction.getAmount()));
BigDecimal b1 = new BigDecimal(Double.toString(100));
requestTransactionParams.put("txnAmt", a1.multiply(b1).toString()); //交易金额,单位为分(必传)
requestTransactionParams.put("txnAmt", a1.multiply(b1).stripTrailingZeros().toPlainString()); //交易金额,单位为分(必传)
requestTransactionParams.put("currencyCode", currencyCode); //交易币种,默认156,目前只支持人民币(156)
requestTransactionParams.put("body", "聚合支付测试"); //商户号(必传)
......
package com.cmb.util;
package com.hand.app.cmb.util;
import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.ASN1Integer;
......
package com.cmb.util;
package com.hand.app.cmb.util;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
......
package com.cmb.util;
package com.hand.app.cmb.util;
import org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPrivateKey;
import org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPublicKey;
......
package com.cmb.util;
package com.hand.app.cmb.util;
public class Sm2Vo {
......
package com.cmb.util;
package com.hand.app.cmb.util;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
......
......@@ -2,15 +2,15 @@
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.cmb.mapper.Ld037Mapper">
<mapper namespace="com.hand.app.cmb.mapper.Ld037Mapper">
<!--获取角色下的模块-->
<resultMap id="AppLd037Map" type="com.cmb.dto.Ld037">
<resultMap id="AppLd037Map" type="com.hand.app.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="generatedt" property="generatedt" jdbcType="DATE"/>
<result column="recamtno" property="recamtno" jdbcType="VARCHAR"/>
<result column="recduedt" property="recduedt" jdbcType="Date"/>
<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"/>
......@@ -35,24 +35,24 @@
<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"/>
<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 /* 实际扣款金额 */
<update id="updateLd037Fail" parameterType="com.hand.app.cmb.dto.Ld037">
UPDATE LD037 t
SET t.ProcDt = sysdate,
t.RecDt = sysdate,
t.RecBatchDt = sysdate,
t.ReceiptStatus = '0',
t.ReceiptCfmStatus = '1',
t.ERRORMSG = (select h.description from hls_ebank_cmb_recode h where h.code=#{errorcd,jdbcType=VARCHAR}),
t.ErrorCd = #{errorcd,jdbcType=VARCHAR},
t.UPDATEDDT = SYSDATE,
t.UPDATEDPERSON = 'CMB',
t.Actdbtamount = 0
WHERE LD037.id = #{id};
WHERE t.id = #{id,jdbcType=DECIMAL}
</update>
</mapper>
......@@ -19,7 +19,8 @@
<sift>
<appender name="REQ-${logName}" class="ch.qos.logback.core.rolling.RollingFileAppender">
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%X{userId}] [%X{requestId}] %logger - %msg%n</pattern>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%X{userId}] [%X{requestId}] %logger - %msg%n
</pattern>
</encoder>
<file>${catalina.base}/logs/hls-${logName}.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
......@@ -54,7 +55,8 @@
<sift>
<appender name="REQ-${logName}" class="ch.qos.logback.core.rolling.RollingFileAppender">
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%X{userId}] [%X{requestId}] %logger - %msg%n</pattern>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%X{userId}] [%X{requestId}] %logger - %msg%n
</pattern>
</encoder>
<file>${catalina.base}/logs/hls-cup-${logName}.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
......@@ -64,6 +66,25 @@
</sift>
</appender>
<appender name="CMB-FILE" class="ch.qos.logback.classic.sift.SiftingAppender">
<discriminator>
<key>logName</key>
<defaultValue>default</defaultValue>
</discriminator>
<sift>
<appender name="REQ-${logName}" class="ch.qos.logback.core.rolling.RollingFileAppender">
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%X{userId}] [%X{requestId}] %logger - %msg%n
</pattern>
</encoder>
<file>${catalina.base}/logs/hls-cmb-${logName}.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${catalina.base}/logs/%d{yyyy-MM-dd}/hls-cmb-${logName}.log</fileNamePattern>
</rollingPolicy>
</appender>
</sift>
</appender>
<root level="ERROR">
<appender-ref ref="STDOUT"/>
......@@ -112,6 +133,7 @@
<logger name="com.timevale" level="INFO" additivity="false">
<appender-ref ref="STDOUT"/>
</logger>
<logger name="com.chinapay.mapper.HlsEbankCcbTransactionMapper" level="DEBUG"/>
<logger name="com.hand.app.zhongDengWang.mapper" level="DEBUG"/>
<logger name="com.chinapay.service.impl.HclcChinaPayServiceImpl" level="INFO" additivity="false">
<appender-ref ref="CUP-FILE"/>
......@@ -119,4 +141,7 @@
<logger name="com.chinapay.util.HttpUtils" level="INFO" additivity="false">
<appender-ref ref="CUP-FILE"/>
</logger>
<logger name="com.cmb.service.impl.HclcCmbPolyServiceImpl" level="INFO" additivity="false">
<appender-ref ref="CMB-FILE"/>
</logger>
</configuration>
\ No newline at end of file
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