Commit 1a307e43 authored by yangyang's avatar yangyang

对接聚富通

parent ceda0a63
......@@ -10,7 +10,8 @@
</sql>
<select id="listObjectCount" resultType="integer">
SELECT count(1)
SELECT
count( DISTINCT ph.amos_user_id )
FROM
hygf_peasant_household ph LEFT JOIN hygf_icbc_record icbc ON ph.amos_user_id = icbc.amos_user_id
<where>
......@@ -33,8 +34,6 @@
</if>
</if>
</where>
GROUP BY
ph.amos_user_id
</select>
<select id="listObject" resultType="com.yeejoin.amos.boot.module.hygf.api.dto.HygfIcbcRecordDTO">
......
......@@ -85,14 +85,14 @@ public class HygfIcbcController extends BaseController {
return hygfIcbcService.registerWalletCallback(request, response);
}
@TycloudOperation (ApiLevel = UserType.AGENCY, needAuth = false)
@TycloudOperation (ApiLevel = UserType.AGENCY)
@GetMapping (value = "/{sequenceNbr}")
@ApiOperation (httpMethod = "GET", value = "根据sequenceNbr查询注册电子钱包", notes = "注册电子钱包")
public ResponseModel<HygfIcbcRecordDTO> getObject(@PathVariable String sequenceNbr) {
return ResponseHelper.buildResponse(hygfIcbcService.getObject(Long.valueOf(sequenceNbr)));
}
@TycloudOperation (ApiLevel = UserType.AGENCY, needAuth = false)
@TycloudOperation (ApiLevel = UserType.AGENCY)
@GetMapping (value = "/list")
@ApiOperation (httpMethod = "GET", value = "聚富通电子钱包列表查询", notes = "聚富通电子钱包列表查询")
@UserLimits
......
package com.yeejoin.amos.boot.module.hygf.biz.service.impl;
import cn.hutool.core.codec.Base64;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.icbc.api.DefaultIcbcClient;
import com.icbc.api.IcbcApiException;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.icbc.api.IcbcConstants;
import com.icbc.api.UiIcbcClient;
import com.icbc.api.request.JftApiUserEntrustopenacctQueryRequestV1;
......@@ -22,11 +21,9 @@ import com.yeejoin.amos.boot.module.hygf.api.entity.PeasantHousehold;
import com.yeejoin.amos.boot.module.hygf.api.mapper.HygfIcbcRecordMapper;
import com.yeejoin.amos.boot.module.hygf.api.service.IHygfIcbcService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
......@@ -201,11 +198,16 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
request.setBizContent(bizContent);
JftApiUserEntrustopenacctQueryResponseV1 response;
try {
log.info("户用光伏开户签约同步开户结果查询数据接口, => 入参: {}", JSON.toJSONString(request));
response = client.execute(request, System.currentTimeMillis() + "");
log.info("户用光伏开户签约同步开户结果查询数据接口, => 响应: {}", JSON.toJSONString(response));
return response;
} catch (IcbcApiException e) {
e.printStackTrace();
log.error("聚富通委托代扣签约同步开户结果查询数据接口error: ", e);
log.error("户用光伏开户签约同步开户结果查询数据接口 error: ", e);
return null;
} catch (Exception e) {
log.error("户用光伏开户签约同步开户结果查询数据接口 error: ", e);
return null;
}
}
......@@ -222,8 +224,9 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
*/
public Object registerWalletCallback(HttpServletRequest request, HttpServletResponse response) throws Exception {
log.info("户用光伏开户签约异步通知, => 验签");
boolean verifyFlag = verifySignData(request, callbackUrl);
String returnJson;
String returnJson = null;
try {
boolean verifyFlag = verifySignData(request, "/hygf/icbc/notify");
if (verifyFlag) {
// 验签成功
String biz_content = request.getParameter("biz_content");
......@@ -246,7 +249,8 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
}
hygfIcbcRecord.setCustName(custName);
hygfIcbcRecord.setIdCard(certNo);
// hygfIcbcRecord.setPhone();
PeasantHousehold peasantHousehold = peasantHouseholdService.lambdaQuery().select(PeasantHousehold::getTelephone).eq(PeasantHousehold::getAmosUserId, outUserId).last("limit 1").one();
hygfIcbcRecord.setPhone(peasantHousehold != null ? peasantHousehold.getTelephone() : "");
hygfIcbcRecord.setMediumId(newPayAcc);
hygfIcbcRecord.setProjectId(projectId);
hygfIcbcRecord.setOpenAccountStatus(openAccoutSucceedFlag);
......@@ -278,6 +282,9 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
returnJson = sign(request, copReturnCode, copReturnMsg);
log.error("通知响应json结果:{}", returnJson);
}
} catch (Exception e) {
log.error("户用光伏开户签约异步通知, => error:", e);
}
return returnJson;
}
......@@ -295,7 +302,12 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
// PageHelper.startPage(current, size);
Integer total = hygfIcbcRecordMapper.listObjectCount(hygfIcbcRecordQueryDTO);
hygfIcbcRecordQueryDTO.setLimit(size);
if (current == 0) {
hygfIcbcRecordQueryDTO.setOffset(0);
} else {
// int offset = (current - 1) * size > total ? : (current - 1) * size;
hygfIcbcRecordQueryDTO.setOffset((current - 1) * size);
}
List<HygfIcbcRecordDTO> list = hygfIcbcRecordMapper.listObject(hygfIcbcRecordQueryDTO);
Page<HygfIcbcRecordDTO> page = new Page<>();
page.setSize(size);
......@@ -341,6 +353,7 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
String biz_content = request.getParameter("biz_content");
String sign_type = request.getParameter("sign_type");
String sign = request.getParameter("sign");
log.info("verifySignData入参,from:[[{}]], api:[[{}]], app_id:[[{}]], charset:[[{}]], format:[[{}]], encrypt_type:[[{}]], timestamp:[[{}]], biz_content:[[{}]], sign_type:[[{}]], sign:[[{}]]",from, api, app_id, charset, format, encrypt_type);
params.put("from", from);
params.put("api", api);
params.put("app_id", app_id);
......@@ -352,9 +365,9 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
params.put("sign_type", sign_type);// 目前上行网关签名暂时仅支持RSA
/**********验证工行上行网关RSA签名**********/
String signStr = WebUtils.buildOrderedSignStr(path, params);
log.error("验签入参,signStr:[[{}]], sign_type:[[{}]], APIGW_PUBLIC_KEY: [[{}]],charset:[[{}]],sign:[[{}]]", signStr, sign_type, APIGW_PUBLIC_KEY, charset, sign);
log.info("验签入参,signStr:[[{}]], sign_type:[[{}]], APIGW_PUBLIC_KEY: [[{}]],charset:[[{}]],sign:[[{}]]", signStr, sign_type, APIGW_PUBLIC_KEY, charset, sign);
boolean flag = IcbcSignature.verify(signStr, sign_type, APIGW_PUBLIC_KEY, charset, sign);
log.error("验签结果:[[{}]]", flag);
log.info("验签结果:[[{}]]", flag);
return flag;
}
......@@ -372,7 +385,8 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
String responseBizContent = "{\"return_code\":\"" + copReturnCode + "\",\"return_msg\":\"" + copReturnMsg + "\"" + ",\"msg_id\":\"" + msg_id + "\"}";
String charset = request.getParameter("charset");// 调用过程使用的编码格式
/**********商户对消息返回响应进行签名,签名方式需与在API平台登记APP的sign_type保持一致(目前基本都是RSA2)**********/
String signType = IcbcConstants.SIGN_TYPE_RSA2;
// String signType = IcbcConstants.SIGN_TYPE_RSA2;
String signType = IcbcConstants.SIGN_TYPE_RSA;
String signStr = "\"response_biz_content\":" + responseBizContent + "," + "\"sign_type\":" + "\"" + signType + "\"";
String signParam = IcbcSignature.sign(signStr, signType, MY_PRIVATE_KEY, charset);
String returnJson = "{\"response_biz_content\":" + responseBizContent + ",\"sign_type\":\"" + signType + "\"" + ",\"sign\":\"" + signParam + "\"}";
......
......@@ -248,4 +248,4 @@ spring.elasticsearch.rest.password=123456
spring.elasticsearch.rest.read-timeout=30000
## 聚富通 配置
hygf.icbc.callbackUrl=http://47.92.234.253:8088/hygf/icbc/notify
\ No newline at end of file
hygf.icbc.callbackUrl=https://yth.yunqingtech.com/hygf/icbc/notify
\ 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