Commit fbe8bb2f authored by 5359's avatar 5359

Merge remote-tracking branch 'origin/uat' into uat

parents c5d938f2 aa93037f
......@@ -3,6 +3,7 @@ package com.hand.app.pingAn.controllers;
import com.alibaba.fastjson.JSONObject;
import com.hand.app.pingAn.service.PingAnService;
import com.hand.app.pingAn.utils.ApiUtils;
import com.hand.hap.core.IRequest;
import com.hand.hap.system.controllers.BaseController;
import com.hand.hap.system.dto.ResponseData;
import com.pingan.openbank.api.sdk.common.http.HttpResult;
......@@ -12,6 +13,7 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.HashMap;
......@@ -27,9 +29,9 @@ public class PingAnController extends BaseController {
@ApiModelProperty("子账户维护(BEDL_C002)")
@RequestMapping("/bedl/SubAcctMaintenance")
@ResponseBody
public ResponseData bindSubAccount(){
public ResponseData bindSubAccount(HttpServletRequest request){
// 模拟请求参数
HashMap<String, String> reqParams = new HashMap<>();
JSONObject reqParams = new JSONObject();
reqParams.put("OpFlag","A");
reqParams.put("SubAccountSeq","123456");
reqParams.put("SubAccountName","测试别名");
......@@ -50,12 +52,10 @@ public class PingAnController extends BaseController {
@ApiModelProperty("近期明细查询(BEDL_C00602)")
@RequestMapping("/bedl/InquiryIntoTheCurrentDetailsOfMainSubaccountAccountTwo")
@ResponseBody
public ResponseData recentDetailQuery(){
public ResponseData recentDetailQuery(HttpServletRequest request){
// 模拟请求参数
HashMap<String, String> reqParams = new HashMap<>();
JSONObject reqParams = new JSONObject();
reqParams.put("OpFlag","1");
reqParams.put("SubAccountSeq","123456");
reqParams.put("SubAccountName","测试别名");
reqParams.put("StartTime","20221201000000");
reqParams.put("EndTime","20221202000000");
reqParams.put("PageNo","1");
......@@ -63,7 +63,7 @@ public class PingAnController extends BaseController {
String seqNoTime = new SimpleDateFormat("yyMMdd").format(Calendar.getInstance().getTime());
Random random = new Random();
String randomNo = "";
for (byte i = 0; i < 10; i++) {
for (byte i = 0; i < 8; i++) {
int randomNumber = random.nextInt(10);
randomNo += randomNumber;
}
......@@ -76,18 +76,25 @@ public class PingAnController extends BaseController {
@ApiModelProperty("明细通知接口(BEDL_ZNA001)")
@RequestMapping("/api/public/pingAn/notify")
@ResponseBody
public ResponseData DetailsNotify(JSONObject data){
// 类似支付结果通知的接口,每次返回一条记录。
// 将数据推送到业务系统
return pingAnService.detailNotify(data);
public ResponseData DetailsNotify(HttpServletRequest request, JSONObject data){
IRequest iRequest = createRequestContext(request);
return pingAnService.detailNotify(iRequest,data);
}
@ApiModelProperty("清分台账明细下载(BEDL_F0P101)")
@RequestMapping("/bedl/DetailReportQueryNew")
@ResponseBody
public ResponseData downloadDetail(JSONObject data){
return pingAnService.detailNotify(data);
public ResponseData downloadDetail(HttpServletRequest request){
IRequest iRequest = createRequestContext(request);
JSONObject reqParams = new JSONObject();
Calendar cal = Calendar.getInstance();
SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmssSSS");
String today = df.format(cal.getTime());
reqParams.put("CnsmrSeqNo", today+"000");
reqParams.put("QueryDate", "20221213");
reqParams.put("Account",ApiUtils.AcctNo);
reqParams.put("BsnCode","C006A");
// reqParams.put("BatchNo","");
return pingAnService.invoke("bedl/DetailReportQueryNew", reqParams);
}
}
package com.hand.app.pingAn.service;
import com.alibaba.fastjson.JSONObject;
import com.hand.hap.core.IRequest;
import com.hand.hap.system.dto.ResponseData;
import java.util.HashMap;
public interface PingAnService {
ResponseData invoke(String interfaceName, HashMap params);
ResponseData invoke(String interfaceName, JSONObject params);
ResponseData detailNotify(JSONObject data);
ResponseData detailNotify(IRequest iRequest, JSONObject data);
}
package com.hand.app.pingAn.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.chinapay.dto.HlsEbankCcbTransaction;
import com.chinapay.mapper.HlsEbankCcbTransactionMapper;
import com.chinapay.service.IHlsEbankCcbTransactionService;
import com.chinapay.service.impl.HlsEbankCcbTransactionServiceImpl;
import com.chinapay.util.StringUtil;
import com.hand.app.cmb.dto.Ld037;
import com.hand.app.cmb.service.impl.HclcCmbPolyServiceImpl;
import com.hand.app.cmb.service.impl.HlsEbankCmbTransqryServiceImpl;
import com.hand.app.cmb.util.Utils;
import com.hand.app.esignHclc.utils.SignHclcUtils;
import com.hand.app.pingAn.service.PingAnService;
import com.hand.app.pingAn.utils.ApiUtils;
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.dto.HapInterfaceHeader;
import com.hand.hap.intergration.service.IHapInterfaceHeaderService;
import com.hand.hap.system.dto.ResponseData;
import com.pingan.openbank.api.sdk.common.http.HttpResult;
import com.pingan.openbank.api.sdk.entity.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.*;
@Service
......@@ -24,32 +41,69 @@ public class PingAnServiceImpl implements PingAnService {
private HlsWsRequestsMapper hlsWsRequestsMapper;
@Autowired
private IHapInterfaceHeaderService headerService;
@Autowired
private IHlsEbankCcbTransactionService hlsEbankCcbTransactionService;
private Logger logger = LoggerFactory.getLogger(getClass());
private static Properties pro = null;
static {
String path = Thread.currentThread().getContextClassLoader().getResource("").getPath().substring(1);
pro = Utils.loadProp(path + "pingAn.properties");
if (Objects.isNull(pro)) {
LoggerFactory.getLogger(HclcCmbPolyServiceImpl.class).error("配置文件初始化异常");
}
}
/**
* 还需要考虑是否要开启事务,但是貌似不太需要
* @param interfaceName
* @param params
* @return
*/
@Override
public ResponseData invoke(String interfaceName, HashMap params) {
public ResponseData invoke(String interfaceName, JSONObject params) {
ResponseData responseData = new ResponseData();
JSONObject requestBody = ApiUtils.getBaseReqBody();
requestBody.putAll(params);
/*插入接口日志表*/
HlsWsRequests hlsWsRequests = new HlsWsRequests();
hlsWsRequests = createRequestLog("url", requestBody.toJSONString(), "pingAn_"+interfaceName.substring(interfaceName.lastIndexOf('/')+1), 1L);
hlsWsRequests = createRequestLog(pro.getProperty("baseUrl")+"/V1.0/"+interfaceName, requestBody.toJSONString(), 1L);
HttpResult result = ApiUtils.invoke(interfaceName, requestBody);
if (Objects.nonNull(result)) {
if ("000000".equals(result.getCode())) {
ArrayList<String> list = new ArrayList<>();
JSONObject res = JSONObject.parseObject(responseData.getMessage());
// todo 记录返回信息并存表
JSONObject res;
if ("200".equals(result.getCode() + "")) {
hlsWsRequests.setReturnStatus("s");
responseData.setSuccess(true);
responseData.setRows(list);
// todo 不同接口返回不同数据,需要确认返回结果的格式
switch (interfaceName) {
case "bedl/SubAcctMaintenance" :
hlsWsRequests.setFunctionName("pingAn_SubAcctMaintenance");
res = JSONObject.parseObject(result.getData());
// do something
ArrayList<String> strings = new ArrayList<>();
strings.add(res.getString("SubAccountNo"));
responseData.setRows(strings);
break;
case "bedl/InquiryIntoTheCurrentDetailsOfMainSubaccountAccountTwo" :
hlsWsRequests.setFunctionName("pingAn_recentDetailQuery");
res = JSONObject.parseObject(result.getData());
//do something
ArrayList<JSONObject> jsonObjects = new ArrayList<>();
jsonObjects.add(res);
responseData.setRows(jsonObjects);
break;
case "bedl/DetailReportQueryNew" :
hlsWsRequests.setFunctionName("pingAn_DetailReportQueryNew");
// 做文件下载
JSONObject arrRes = JSONArray.parseObject(result.getData());
ArrayList<JSONObject> fileInfo = new ArrayList<>();
fileInfo.add(arrRes);
responseData.setRows(fileInfo);
break;
}
} else {
//请求失败
hlsWsRequests.setReturnStatus("f");
......@@ -57,10 +111,6 @@ public class PingAnServiceImpl implements PingAnService {
}
hlsWsRequests.setResponseJson(result.getData());
hlsWsRequests.setResponsedDate(new Date());
// todo 处理响应信息
}
//更新日志
hlsWsRequestsMapper.updateByPrimaryKeySelective(hlsWsRequests);
......@@ -68,23 +118,27 @@ public class PingAnServiceImpl implements PingAnService {
}
public ResponseData detailNotify(JSONObject data){
public ResponseData detailNotify(IRequest iRequest, JSONObject data){
ResponseData responseData = new ResponseData();
// todo 返回单条数据,存记录
HlsWsRequests hlsWsRequests = new HlsWsRequests();
hlsWsRequests = createRequestLog("url", data.toJSONString(), "pingAn_notify", 1L);
// 调用系统的接口服务,推送通知数据
postNotify(data);
if (Objects.nonNull(data) && data.size() > 0){
// 存表
HlsEbankCcbTransaction hlsEbankCcbTransaction = saveTransaction(iRequest,data);
// 调用系统的接口服务,推送通知数据
postNotify(JSONObject.toJSONString(hlsEbankCcbTransaction));
responseData.setSuccess(true);
responseData.setMessage("接收成功");
}else{
responseData.setSuccess(false);
responseData.setMessage("接收失败");
}
return responseData;
}
private HlsWsRequests createRequestLog(String wsdlUrl, String requestClob, String functionName , Long pkValue) {
private HlsWsRequests createRequestLog(String wsdlUrl, String requestClob, Long pkValue) {
HlsWsRequests hlsWsRequests = new HlsWsRequests();
hlsWsRequests.setRequestDate(new Date());
hlsWsRequests.setRequestWsdlUrl(wsdlUrl);
hlsWsRequests.setFunctionName(functionName);
hlsWsRequests.setRequestJson(requestClob);
hlsWsRequests.setStatusDate(new Date());
hlsWsRequests.setParameterType("json");
......@@ -94,7 +148,7 @@ public class PingAnServiceImpl implements PingAnService {
return hlsWsRequests;
}
private String postNotify(JSONObject params) {
private String postNotify(String params) {
String sysName = "HCL_UPLOAD_FILE";
// todo 待修改
String apiName = "writeOffLd037";
......@@ -113,7 +167,7 @@ public class PingAnServiceImpl implements PingAnService {
headInfo.put("Content-Type", "application/x-www-form-urlencoded");
JSONObject requestData = new JSONObject();
requestData.put("requestData", params.toString());
requestData.put("requestData", params);
//发送http请求
SignHclcUtils signHclcUtils1 = new SignHclcUtils();
......@@ -132,4 +186,26 @@ public class PingAnServiceImpl implements PingAnService {
}
}
private HlsEbankCcbTransaction saveTransaction(IRequest iRequest, JSONObject data) {
HlsEbankCcbTransaction ccbTransaction = new HlsEbankCcbTransaction();
ccbTransaction.setMerId(ApiUtils.AcctNo);
ccbTransaction.setSttVchCardNo(data.getString("STT_VCH_CARD_NO"));
ccbTransaction.setSttAcDate(data.getString("STT_AC_DATE"));
ccbTransaction.setTranDate(data.getString("STT_TR_TIME"));
ccbTransaction.setMerOrderNo(data.getString("STT_CONSUMER_SEQ_NO"));
ccbTransaction.setCmbOrderId(data.getString("STT_JRN_NO"));
ccbTransaction.setSttVchSeqNo(data.getString("STT_VCH_SEQ_NO"));
ccbTransaction.setTranType(data.getString("STT_VCH_SIGN"));
ccbTransaction.setAmount(data.getDouble("STT_VCH_AMT"));
ccbTransaction.setSttAmtRmb(data.getDouble("STT_AMT_RMB"));
ccbTransaction.setSttVchBal(data.getDouble("STT_VCH_BAL"));
ccbTransaction.setSttVchRcvAcNo(data.getString("STT_VCH_RCV_AC_NO"));
ccbTransaction.setSttVchRcvAcName(data.getString("STT_VCH_RCV_AC_NAME"));
ccbTransaction.setSttVchRcvBkName(data.getString("STT_VCH_RCV_BK_NAME"));
ccbTransaction.setSttVchRcvBkNo(data.getString("STT_VCH_RCV_BK_NO"));
ccbTransaction.setSttVchRemark(data.getString("STT_VCH_REMARK"));
ccbTransaction.setReturnCode(data.getString("STT_VCH_MARKCODE"));
ccbTransaction.setReturnMsg(data.getString("STT_VCH_PART"));
return hlsEbankCcbTransactionService.insertSelective(iRequest, ccbTransaction);
}
}
......@@ -3,13 +3,16 @@ package com.hand.app.pingAn.utils;
import com.alibaba.fastjson.JSONObject;
import com.pingan.openbank.api.sdk.client.ApiClient;
import com.pingan.openbank.api.sdk.common.http.HttpResult;
import com.pingan.openbank.api.sdk.entity.SdkRequest;
import com.pingan.openbank.api.sdk.entity.*;
import java.io.File;
import java.util.List;
public class ApiUtils {
private static ApiClient apiClient = ApiClient.getInstance("pingAn.properties");
public static JSONObject baseReqBody = new JSONObject();
private static JSONObject baseReqBody = new JSONObject();
private static String MrchCode = "0090108040000KTAR000";
private static String AcctNo = "15000101414037";
public static String AcctNo = "15000101414037";
static{
// todo 设置通用的请求参数,比如主账号,流水号,企业银企直连标准代码等
baseReqBody.put("MrchCode",MrchCode);
......@@ -26,4 +29,5 @@ public class ApiUtils {
public static JSONObject getBaseReqBody(){
return baseReqBody.clone();
}
}
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