Commit ff4f9183 authored by wujiang's avatar wujiang

修改工行回调

parent 8d0a176d
package com.yeejoin.amos.boot.module.hygf.api.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import java.util.Date;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
/**
* (hygf_icbc_record)实体类
*
* @author yangyang
* @description
* @since 2024-07-18 11:40:46
*/
@Data
@NoArgsConstructor
@Accessors(chain = true)
@TableName(value = "hygf_icbc_request", autoResultMap = true)
public class HygfIcbcRequest extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 内容状态
*/
@TableField("content")
private String content;
@TableField("phase")
private String phase;
/**
* 内容状态
*/
@TableField("exception")
private String exception;
}
\ No newline at end of file
package com.yeejoin.amos.boot.module.hygf.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.hygf.api.config.UserEmpower;
import com.yeejoin.amos.boot.module.hygf.api.dto.AcceptanceDto;
import com.yeejoin.amos.boot.module.hygf.api.dto.HygfIcbcRecordDTO;
import com.yeejoin.amos.boot.module.hygf.api.dto.HygfIcbcRecordQueryDTO;
import com.yeejoin.amos.boot.module.hygf.api.entity.HygfIcbcRecord;
import com.yeejoin.amos.boot.module.hygf.api.entity.HygfIcbcRequest;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* (hygf_icbc_record)数据Mapper
*
* @author yangyang
* @description
* @since 2024-07-18 11:40:46
*/
public interface HygfIcbcRequestMapper extends BaseMapper<HygfIcbcRequest> {
}
package com.yeejoin.amos.boot.module.hygf.biz.service.impl;
import cn.hutool.core.codec.Base64;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
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;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.icbc.api.DefaultIcbcClient;
import com.icbc.api.IcbcApiException;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.icbc.api.IcbcConstants;
import com.icbc.api.UiIcbcClient;
import com.icbc.api.request.JftApiUserEntrustopenacctQueryRequestV1;
......@@ -18,40 +44,14 @@ import com.yeejoin.amos.boot.module.hygf.api.Enum.IcbcEnum;
import com.yeejoin.amos.boot.module.hygf.api.dto.HygfIcbcRecordDTO;
import com.yeejoin.amos.boot.module.hygf.api.dto.HygfIcbcRecordQueryDTO;
import com.yeejoin.amos.boot.module.hygf.api.entity.HygfIcbcRecord;
import com.yeejoin.amos.boot.module.hygf.api.entity.HygfIcbcRequest;
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.mapper.HygfIcbcRequestMapper;
import com.yeejoin.amos.boot.module.hygf.api.service.IHygfIcbcService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
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;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import cn.hutool.core.codec.Base64;
import lombok.extern.slf4j.Slf4j;
/**
* 并网信息服务实现类
......@@ -61,8 +61,8 @@ import java.util.stream.Collectors;
*/
@Service
@Slf4j
public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbcRecord, HygfIcbcRecordMapper> implements IHygfIcbcService {
public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbcRecord, HygfIcbcRecordMapper>
implements IHygfIcbcService {
private static final String trxChannel = "05"; // 05表示小程序
......@@ -78,58 +78,61 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
// private static final String PROJECT_ID = "PJ14001401B000160171";
// 测试环境
@Value ("${hygf.icbc.appId}")
@Value("${hygf.icbc.appId}")
private String APP_ID;
@Value ("${hygf.icbc.corpNo}")
@Value("${hygf.icbc.corpNo}")
private String corpNo;
@Value ("${hygf.icbc.myPrivateKey}")
@Value("${hygf.icbc.myPrivateKey}")
private String MY_PRIVATE_KEY;
@Value ("${hygf.icbc.serviceUrl}")
@Value("${hygf.icbc.serviceUrl}")
private String serviceUrl;
@Value ("${hygf.icbc.aesKey}")
@Value("${hygf.icbc.aesKey}")
private String AES_Key;
@Value ("${hygf.icbc.camsPublicKey}")
@Value("${hygf.icbc.camsPublicKey}")
private String CAMS_PUBLIC_KEY;
@Value ("${hygf.icbc.apigwPublicKey}")
@Value("${hygf.icbc.apigwPublicKey}")
private String APIGW_PUBLIC_KEY;
@Value ("${hygf.icbc.outVendorId}")
@Value("${hygf.icbc.outVendorId}")
private String OUT_VENDOR_ID;
@Value ("${hygf.icbc.projectId}")
@Value("${hygf.icbc.projectId}")
private String PROJECT_ID;
/**
* 协议总限额
*/
@Value ("${hygf.icbc.protocolLimitAmount:2500000000}")
@Value("${hygf.icbc.protocolLimitAmount:2500000000}")
private String protocolLimitAmount;
/**
* 单笔限额
*/
@Value ("${hygf.icbc.trxLmtAmt:10000000}")
@Value("${hygf.icbc.trxLmtAmt:10000000}")
private String trxLmtAmt;
/**
* 日累计限额
*/
@Value ("${hygf.icbc.dayLmtAmt:20000000}")
@Value("${hygf.icbc.dayLmtAmt:20000000}")
private String dayLmtAmt;
@Value ("${hygf.icbc.loanTotalAmt:0}")
@Value("${hygf.icbc.loanTotalAmt:0}")
private String loanTotalAmt;
/**
* 合作方接收结果通知 URL
*/
@Value ("${hygf.icbc.callbackUrl:}")
@Value("${hygf.icbc.callbackUrl:}")
private String callbackUrl;
@Resource (type = PeasantHouseholdServiceImpl.class)
@Resource(type = PeasantHouseholdServiceImpl.class)
private PeasantHouseholdServiceImpl peasantHouseholdService;
@Resource (type = HygfIcbcRecordMapper.class)
@Resource(type = HygfIcbcRecordMapper.class)
private HygfIcbcRecordMapper hygfIcbcRecordMapper;
@Resource(type = HygfIcbcRequestMapper.class)
private HygfIcbcRequestMapper hygfIcbcRequestMapper;
public void icbcRegisterWalletUrl(HttpServletRequest req, HttpServletResponse resp) {
try {
UiIcbcClient client = new UiIcbcClient(APP_ID, IcbcConstants.SIGN_TYPE_RSA2, MY_PRIVATE_KEY, IcbcConstants.CHARSET_UTF8);
UiIcbcClient client = new UiIcbcClient(APP_ID, IcbcConstants.SIGN_TYPE_RSA2, MY_PRIVATE_KEY,
IcbcConstants.CHARSET_UTF8);
String userId = req.getParameter("userId");
// String userId = "071301";
......@@ -177,7 +180,8 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
PrintWriter out = resp.getWriter();
out.write("<html>");
out.write("<head>");
out.write("<meta http-equiv=\"Content-Type\" content=\"text/html;charset=" + IcbcConstants.CHARSET_UTF8 + "\">");
out.write("<meta http-equiv=\"Content-Type\" content=\"text/html;charset=" + IcbcConstants.CHARSET_UTF8
+ "\">");
out.write("</head>");
out.write("<body>");
out.write(form);
......@@ -191,20 +195,12 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
throw new RuntimeException(e.getMessage());
}
}
public JftApiUserEntrustopenacctQueryResponseV1 getHygfIcbcWalletInfo(String userId) {
DefaultIcbcClient client = new DefaultIcbcClient(
APP_ID,
IcbcConstants.SIGN_TYPE_RSA2,
MY_PRIVATE_KEY,
IcbcConstants.CHARSET_UTF8,
IcbcConstants.FORMAT_JSON,
APIGW_PUBLIC_KEY,
IcbcConstants.ENCRYPT_TYPE_AES,
AES_Key,
"", "");
DefaultIcbcClient client = new DefaultIcbcClient(APP_ID, IcbcConstants.SIGN_TYPE_RSA2, MY_PRIVATE_KEY,
IcbcConstants.CHARSET_UTF8, IcbcConstants.FORMAT_JSON, APIGW_PUBLIC_KEY, IcbcConstants.ENCRYPT_TYPE_AES,
AES_Key, "", "");
JftApiUserEntrustopenacctQueryRequestV1 request = new JftApiUserEntrustopenacctQueryRequestV1();
request.setServiceUrl(serviceUrl + "/api/jft/api/user/entrustopenacct/query/V1");
......@@ -231,6 +227,7 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
log.error("聚富通委托代扣签约同步开户结果查询数据接口V1 error => ", e);
throw new BadRequest(e.getErrMsg());
} catch (Exception e) {
e.printStackTrace();
log.error("聚富通委托代扣签约同步开户结果查询数据接口V1 error => ", e);
throw new RuntimeException(e.getMessage());
}
......@@ -249,11 +246,43 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
public Object registerWalletCallback(HttpServletRequest request, HttpServletResponse response) throws Exception {
log.info("户用光伏开户签约异步通知, => 验签");
String returnJson;
// 网关公钥
Map<String, String> params = new HashMap<>();
String api = request.getParameter("api");
String from = request.getParameter("from");
String app_id = request.getParameter("app_id");
String charset = request.getParameter("charset");
String format = request.getParameter("format");
String encrypt_type = request.getParameter("encrypt_type");
String timestamp = request.getParameter("timestamp");
String biz_content = request.getParameter("biz_content");
String sign_type = request.getParameter("sign_type");
String sign = request.getParameter("sign");
params.put("from", from);
params.put("api", api);
params.put("app_id", app_id);
params.put("charset", charset);
params.put("format", format);
params.put("encrypt_type",
encrypt_type);
params.put("timestamp", timestamp);
//params.put("biz_content", "{\"busiCode\":\"11098243\",\"return_msg\":\"success\",\"outUserId\":\"11098243\",\"custName\":\"5p2O5Y2r5Lic\",\"marketingStaffId\":\"\",\"newPayAcc\":\"NjIxNDc2MTUwMjYwMjc5MDc4OQ==\",\"signEntrsutPrtlSucceedFlag\":\"1\",\"certNo\":\"MjI5MDA1MTk3MzEwMjUwMjFY\",\"appId\":\"11000000000000028870\",\"msg_id\":\"20240814190453416\",\"projectId\":\"PJ140014023565102203\",\"openAccoutSucceedFlag\":\"02\",\"return_code\":0}");
params.put("biz_content", biz_content);
params.put("sign_type", sign_type);// 目前上行网关签名暂时仅支持RSA
params.put("sign", sign);
HygfIcbcRequest hygfIcbcRequest = new HygfIcbcRequest();
hygfIcbcRequest.setPhase("验签");
hygfIcbcRequest.setContent(JSONObject.toJSONString(params));
hygfIcbcRequest.setRecDate(new Date());
hygfIcbcRequestMapper.insert(hygfIcbcRequest);
try {
boolean verifyFlag = verifySignData(request, "/hygf/icbc/notify");
if (verifyFlag) {
// 验签成功
String biz_content = request.getParameter("biz_content");
hygfIcbcRequest.setPhase("查询");
hygfIcbcRequestMapper.updateById(hygfIcbcRequest);
// String biz_content = request.getParameter("biz_content");
String decode = URLDecoder.decode(biz_content, "utf-8");
Map<String, String> data = JSONObject.parseObject(decode, Map.class);
log.debug("解密后参数:{}", data);// 进行自己的处理,此处默认处理成功,返回通知方成功,return_code=0
......@@ -267,13 +296,20 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
String signEntrsutPrtlSucceedFlag = data.get("signEntrsutPrtlSucceedFlag");
JftApiUserEntrustopenacctQueryResponseV1 hygfIcbcWalletInfo = this.getHygfIcbcWalletInfo(outUserId);
// region 保存数据
HygfIcbcRecord hygfIcbcRecord = this.lambdaQuery().eq(HygfIcbcRecord::getAmosUserId, outUserId).last(" limit 1").one();
HygfIcbcRecord hygfIcbcRecord = this.lambdaQuery().eq(HygfIcbcRecord::getAmosUserId, outUserId)
.last(" limit 1").one();
if (hygfIcbcRecord == null) {
hygfIcbcRecord = new HygfIcbcRecord();
}
hygfIcbcRecord.setCustName(custName);
hygfIcbcRecord.setIdCard(certNo);
PeasantHousehold peasantHousehold = peasantHouseholdService.lambdaQuery().select(PeasantHousehold::getTelephone).eq(PeasantHousehold::getAmosUserId, outUserId).last("limit 1").one();
hygfIcbcRequest.setPhase("组装");
hygfIcbcRequestMapper.updateById(hygfIcbcRequest);
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);
......@@ -293,21 +329,36 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
// hygfIcbcRecord.setDiscardStatus();
hygfIcbcRecord.setAmosUserId(outUserId);
hygfIcbcRecord.setRecDate(new Date());
hygfIcbcRequest.setPhase("入库");
hygfIcbcRequestMapper.updateById(hygfIcbcRequest);
this.saveOrUpdate(hygfIcbcRecord);
// endregion
String copReturnCode = "0";// 通知合作方接收成功的返回码,固定
String copReturnMsg = "success";// 合作方的返回信息,固定
hygfIcbcRequest.setPhase("加签返回");
hygfIcbcRequestMapper.updateById(hygfIcbcRequest);
returnJson = sign(request, copReturnCode, copReturnMsg);
log.info("通知响应json结果:{}", returnJson);
return returnJson;
} else {// 验签失败
hygfIcbcRequest.setPhase("验签失败");
hygfIcbcRequestMapper.updateById(hygfIcbcRequest);
String copReturnCode = "‐12345";
String copReturnMsg = "icbc jft sign not pass.";
returnJson = sign(request, copReturnCode, copReturnMsg);
log.error("通知响应json结果:{}", returnJson);
}
} catch (Exception e) {
log.error("户用光伏开户签约异步通知, => error:", e);
hygfIcbcRequest.setException(JSONObject.toJSONString(e));
hygfIcbcRequestMapper.updateById(hygfIcbcRequest);
String copReturnCode = "‐1";
String copReturnMsg = "icbc jft error";
returnJson = sign(request, copReturnCode, copReturnMsg);
......@@ -316,39 +367,50 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
}
public HygfIcbcRecordDTO getObject(String amosUserId) {
HygfIcbcRecord hygfIcbcRecord = this.lambdaQuery().eq(HygfIcbcRecord::getAmosUserId, amosUserId).last("limit 1").one();
HygfIcbcRecord hygfIcbcRecord = this.lambdaQuery().eq(HygfIcbcRecord::getAmosUserId, amosUserId).last("limit 1")
.one();
HygfIcbcRecordDTO hygfIcbcRecordDTO = new HygfIcbcRecordDTO();
if (hygfIcbcRecord == null) {
PeasantHousehold peasantHousehold = peasantHouseholdService.lambdaQuery()
.select(PeasantHousehold::getTelephone, PeasantHousehold::getOwnersName, PeasantHousehold::getIdCard)
.select(PeasantHousehold::getTelephone, PeasantHousehold::getOwnersName,
PeasantHousehold::getIdCard)
.eq(PeasantHousehold::getAmosUserId, amosUserId).last("limit 1").one();
hygfIcbcRecordDTO.setCustName(peasantHousehold.getOwnersName());
hygfIcbcRecordDTO.setIdCard(peasantHousehold.getIdCard());
hygfIcbcRecordDTO.setPhone(peasantHousehold.getTelephone());
hygfIcbcRecordDTO.setOpenAccountStatus(IcbcEnum.OpenAccountState.INITIAL.getCode());
hygfIcbcRecordDTO.setOpenAccountStatusName(IcbcEnum.OpenAccountState.getNameByCode(IcbcEnum.OpenAccountState.INITIAL.getCode(), IcbcEnum.OpenAccountState.INITIAL.getName()));
hygfIcbcRecordDTO.setOpenAccountStatusName(IcbcEnum.OpenAccountState.getNameByCode(
IcbcEnum.OpenAccountState.INITIAL.getCode(), IcbcEnum.OpenAccountState.INITIAL.getName()));
} else if (IcbcEnum.OpenAccountState.FAIL.getCode().equals(hygfIcbcRecord.getOpenAccountStatus())) {
Bean.toModel(hygfIcbcRecord, hygfIcbcRecordDTO);
PeasantHousehold peasantHousehold = peasantHouseholdService.lambdaQuery()
.select(PeasantHousehold::getTelephone, PeasantHousehold::getOwnersName, PeasantHousehold::getIdCard)
.select(PeasantHousehold::getTelephone, PeasantHousehold::getOwnersName,
PeasantHousehold::getIdCard)
.eq(PeasantHousehold::getAmosUserId, amosUserId).last("limit 1").one();
hygfIcbcRecordDTO.setCustName(peasantHousehold.getOwnersName());
hygfIcbcRecordDTO.setIdCard(peasantHousehold.getIdCard());
hygfIcbcRecordDTO.setPhone(peasantHousehold.getTelephone());
hygfIcbcRecordDTO.setOpenAccountStatusName(IcbcEnum.OpenAccountState.getNameByCode(hygfIcbcRecordDTO.getOpenAccountStatus(), IcbcEnum.OpenAccountState.INITIAL.getName()));
hygfIcbcRecordDTO.setProtocolStatusName(IcbcEnum.ProtocolStatus.getNameByCode(hygfIcbcRecordDTO.getProtocolStatus(), ""));
hygfIcbcRecordDTO.setOpenAccountStatusName(IcbcEnum.OpenAccountState.getNameByCode(
hygfIcbcRecordDTO.getOpenAccountStatus(), IcbcEnum.OpenAccountState.INITIAL.getName()));
hygfIcbcRecordDTO.setProtocolStatusName(
IcbcEnum.ProtocolStatus.getNameByCode(hygfIcbcRecordDTO.getProtocolStatus(), ""));
} else {
Bean.toModel(hygfIcbcRecord, hygfIcbcRecordDTO);
hygfIcbcRecordDTO.setOpenAccountStatusName(IcbcEnum.OpenAccountState.getNameByCode(hygfIcbcRecordDTO.getOpenAccountStatus(), IcbcEnum.OpenAccountState.INITIAL.getName()));
hygfIcbcRecordDTO.setProtocolStatusName(IcbcEnum.ProtocolStatus.getNameByCode(hygfIcbcRecordDTO.getProtocolStatus(), ""));
hygfIcbcRecordDTO.setOpenAccountStatusName(IcbcEnum.OpenAccountState.getNameByCode(
hygfIcbcRecordDTO.getOpenAccountStatus(), IcbcEnum.OpenAccountState.INITIAL.getName()));
hygfIcbcRecordDTO.setProtocolStatusName(
IcbcEnum.ProtocolStatus.getNameByCode(hygfIcbcRecordDTO.getProtocolStatus(), ""));
}
List<String> amosUserIds = Arrays.asList(amosUserId);
List<PeasantHousehold> peasantHouseholds = peasantHouseholdService.lambdaQuery().in(PeasantHousehold::getAmosUserId, amosUserIds).list();
Map<String, List<PeasantHousehold>> peasantHouseholdMap = peasantHouseholds.stream().collect(Collectors.groupingBy(PeasantHousehold::getAmosUserId));// 根据农户 ID 分组
List<PeasantHousehold> peasantHouseholds = peasantHouseholdService.lambdaQuery()
.in(PeasantHousehold::getAmosUserId, amosUserIds).list();
Map<String, List<PeasantHousehold>> peasantHouseholdMap = peasantHouseholds.stream()
.collect(Collectors.groupingBy(PeasantHousehold::getAmosUserId));// 根据农户 ID 分组
List<PeasantHousehold> peasantHouseholdList = peasantHouseholdMap.get(amosUserId);
hygfIcbcRecordDTO.setPeasantHouseholds(Bean.toModels(peasantHouseholdList, HygfIcbcRecordDTO.IcbcPeasantHousehold.class));
hygfIcbcRecordDTO.setPeasantHouseholds(
Bean.toModels(peasantHouseholdList, HygfIcbcRecordDTO.IcbcPeasantHousehold.class));
return hygfIcbcRecordDTO;
}
......@@ -380,12 +442,19 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
if (CollectionUtils.isEmpty(hygfIcbcRecords)) {
return Collections.emptyList();
}
List<String> amosUserIds = hygfIcbcRecords.stream().map(HygfIcbcRecordDTO::getAmosUserId).collect(Collectors.toList());
List<PeasantHousehold> peasantHouseholds = peasantHouseholdService.lambdaQuery().select(PeasantHousehold::getAmosUserId, PeasantHousehold::getRegionalCompaniesName, PeasantHousehold::getOwnersName, PeasantHousehold::getIdCard, PeasantHousehold::getTelephone).in(PeasantHousehold::getAmosUserId, amosUserIds).list();
Map<String, List<PeasantHousehold>> PeasantHouseholdMap = peasantHouseholds.stream().collect(Collectors.groupingBy(PeasantHousehold::getAmosUserId));// 根据农户 ID 分组
List<String> amosUserIds = hygfIcbcRecords.stream().map(HygfIcbcRecordDTO::getAmosUserId)
.collect(Collectors.toList());
List<PeasantHousehold> peasantHouseholds = peasantHouseholdService.lambdaQuery()
.select(PeasantHousehold::getAmosUserId, PeasantHousehold::getRegionalCompaniesName,
PeasantHousehold::getOwnersName, PeasantHousehold::getIdCard, PeasantHousehold::getTelephone)
.in(PeasantHousehold::getAmosUserId, amosUserIds).list();
Map<String, List<PeasantHousehold>> PeasantHouseholdMap = peasantHouseholds.stream()
.collect(Collectors.groupingBy(PeasantHousehold::getAmosUserId));// 根据农户 ID 分组
return hygfIcbcRecords.stream().map(hygfIcbcRecordDTO -> {
hygfIcbcRecordDTO.setOpenAccountStatusName(IcbcEnum.OpenAccountState.getNameByCode(hygfIcbcRecordDTO.getOpenAccountStatus(), IcbcEnum.OpenAccountState.INITIAL.getName()));
hygfIcbcRecordDTO.setProtocolStatusName(IcbcEnum.ProtocolStatus.getNameByCode(hygfIcbcRecordDTO.getProtocolStatus(), ""));
hygfIcbcRecordDTO.setOpenAccountStatusName(IcbcEnum.OpenAccountState.getNameByCode(
hygfIcbcRecordDTO.getOpenAccountStatus(), IcbcEnum.OpenAccountState.INITIAL.getName()));
hygfIcbcRecordDTO.setProtocolStatusName(
IcbcEnum.ProtocolStatus.getNameByCode(hygfIcbcRecordDTO.getProtocolStatus(), ""));
List<PeasantHousehold> peasantHouseholdList = PeasantHouseholdMap.get(hygfIcbcRecordDTO.getAmosUserId());
if (IcbcEnum.OpenAccountState.FAIL.getCode().equals(hygfIcbcRecordDTO.getOpenAccountStatus())) {
hygfIcbcRecordDTO.setCustName(peasantHouseholds.get(0).getOwnersName());
......@@ -394,8 +463,11 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
}
if (!CollectionUtils.isEmpty(peasantHouseholdList)) {
// 根据区域经销商名称去重
List<HygfIcbcRecordDTO.IcbcPeasantHousehold> icbcPeasantHouseholds = Bean.toModels(peasantHouseholdList, HygfIcbcRecordDTO.IcbcPeasantHousehold.class);
hygfIcbcRecordDTO.setPeasantHouseholds(icbcPeasantHouseholds.stream().filter(distinctByKey(HygfIcbcRecordDTO.IcbcPeasantHousehold::getRegionalCompaniesName)).collect(Collectors.toList()));
List<HygfIcbcRecordDTO.IcbcPeasantHousehold> icbcPeasantHouseholds = Bean.toModels(peasantHouseholdList,
HygfIcbcRecordDTO.IcbcPeasantHousehold.class);
hygfIcbcRecordDTO.setPeasantHouseholds(icbcPeasantHouseholds.stream()
.filter(distinctByKey(HygfIcbcRecordDTO.IcbcPeasantHousehold::getRegionalCompaniesName))
.collect(Collectors.toList()));
}
return hygfIcbcRecordDTO;
}).collect(Collectors.toList());
......@@ -450,15 +522,21 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
* @throws Exception
*/
private String sign(HttpServletRequest request, String copReturnCode, String copReturnMsg) throws Exception {
String msg_id = new SimpleDateFormat("yyyyMMdd").format(new Date()) + new SimpleDateFormat("HHmmss").format(new Date());
String responseBizContent = "{\"return_code\":\"" + copReturnCode + "\",\"return_msg\":\"" + copReturnMsg + "\"" + ",\"msg_id\":\"" + msg_id + "\"}";
String msg_id = new SimpleDateFormat("yyyyMMdd").format(new Date())
+ new SimpleDateFormat("HHmmss").format(new Date());
String responseBizContent = "{\"return_code\":\"" + copReturnCode + "\",\"return_msg\":\"" + copReturnMsg + "\""
+ ",\"msg_id\":\"" + msg_id + "\"}";
String charset = request.getParameter("charset");// 调用过程使用的编码格式
/**********商户对消息返回响应进行签名,签名方式需与在API平台登记APP的sign_type保持一致(目前基本都是RSA2)**********/
/**********
* 商户对消息返回响应进行签名,签名方式需与在API平台登记APP的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 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 + "\"}";
String returnJson = "{\"response_biz_content\":" + responseBizContent + ",\"sign_type\":\"" + signType + "\""
+ ",\"sign\":\"" + signParam + "\"}";
return returnJson;
}
......
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