Commit 25702b02 authored by fangxinjiang's avatar fangxinjiang

Merge remote-tracking branch 'origin/MVP1.7.2' into MVP1.7.2

parents 55d81f01 72c5e8f5
......@@ -16,5 +16,5 @@ public class EkpBankResultVo implements Serializable {
private String fdId;
private String fdParentId;
private String fdWxNo;
private String num;
private Integer num;
}
package com.yifu.cloud.plus.v1.ekp.controller;
import com.icbc.api.response.JftApiPayrollQueryDetailResponseV1;
import com.yifu.cloud.plus.v1.ekp.service.IcbcTransactionFlowIssueService;
import com.yifu.cloud.plus.v1.ekp.vo.EkpBankAttaReturnVo;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
......@@ -60,8 +61,9 @@ public class IcbcTransactionFlowIssueController {
*/
@Operation(summary = "代发工资明细查询", description = "代发工资明细查询")
@PostMapping("/page")
public R selectIcbcTransactionFlowInfo() {
return icbcTransactionFlowIssueService.selectIcbcTransactionFlowInfo();
public JftApiPayrollQueryDetailResponseV1 selectIcbcTransactionFlowInfo(@RequestParam String wxNo
, @RequestParam String startId, @RequestParam String endId) {
return icbcTransactionFlowIssueService.selectIcbcTransactionFlowInfo(wxNo, startId, endId);
}
/**
......
......@@ -48,4 +48,10 @@ public interface EkpBankGrantDetailMapper extends BaseMapper<EkpBankGrantDetail>
// 主表发放时,更新明细表的发放时间与状态
void updateStatusByGrant(@Param("fdParentId") String fdParentId);
// 主表拒绝授权时,批量更新明细表为发放失败,原因为拒绝授权
void updateStatusByGrantFail(@Param("fdParentId") String fdParentId);
// 获取明细表ID来更新状态
List<EkpBankGrantDetail> getListByParentId(@Param("fdParentId") String fdParentId);
}
......@@ -46,4 +46,10 @@ public interface EkpBankGrantDetailService extends IService<EkpBankGrantDetail>
// 主表发放时,更新明细表的发放时间与状态
void updateStatusByGrant(String fdParentId);
// 主表拒绝授权时,批量更新明细表为发放失败,原因为拒绝授权
void updateStatusByGrantFail(String fdParentId);
// 获取明细表ID来更新状态
List<EkpBankGrantDetail> getListByParentId(String fdParentId);
}
package com.yifu.cloud.plus.v1.ekp.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.icbc.api.response.JftApiPayrollQueryDetailResponseV1;
import com.yifu.cloud.plus.v1.ekp.entity.EkpBankAtta;
import com.yifu.cloud.plus.v1.ekp.entity.EkpSocialInfo;
import com.yifu.cloud.plus.v1.ekp.vo.EkpBankAttaReturnVo;
......@@ -32,7 +33,7 @@ public interface IcbcTransactionFlowIssueService extends IService<EkpSocialInfo>
* @Date: 2024-11-12
* @return: R
**/
R selectIcbcTransactionFlowInfo();
JftApiPayrollQueryDetailResponseV1 selectIcbcTransactionFlowInfo(String wxNo, String startId, String endId);
R asyncNotice(HttpServletRequest request) throws Exception;
......@@ -64,6 +65,7 @@ public interface IcbcTransactionFlowIssueService extends IService<EkpSocialInfo>
**/
R<String> submitBankTask(String fdId, String type);
// 验证下载文件的正确性
void exportAll(HttpServletResponse response);
/**
......
......@@ -61,4 +61,15 @@ public class EkpBankGrantDetailServiceImpl extends ServiceImpl<EkpBankGrantDetai
public void updateStatusByGrant(String fdParentId) {
baseMapper.updateStatusByGrant(fdParentId);
}
@Override
public void updateStatusByGrantFail(String fdParentId) {
baseMapper.updateStatusByGrantFail(fdParentId);
}
@Override
public List<EkpBankGrantDetail> getListByParentId(String fdParentId) {
return baseMapper.getListByParentId(fdParentId);
}
}
......@@ -148,7 +148,7 @@ public class IcbcTransactionFlowIssueServiceImpl extends ServiceImpl<EkpSocialIn
* @Date: 2024-11-12
* @return: R
**/
public R selectIcbcTransactionFlowInfo() {
public JftApiPayrollQueryDetailResponseV1 selectIcbcTransactionFlowInfo(String wxNo, String startId, String endId) {
DefaultIcbcClient client = new DefaultIcbcClient(icbcConfigProperties.getAppId(), IcbcConstants.SIGN_TYPE_RSA2,
icbcConfigProperties.getAppPrivateKey(), IcbcConstants.CHARSET_UTF8, IcbcConstants.FORMAT_JSON,
......@@ -164,24 +164,26 @@ public class IcbcTransactionFlowIssueServiceImpl extends ServiceImpl<EkpSocialIn
//查询类型:1 批次 2 批次明细
bizContent.setType("2");
//批次号,appSerialno为空时,必输
bizContent.setAppBatserialno("WX203");
// bizContent.setAppBatserialno("WX203")
bizContent.setAppBatserialno(wxNo);
//内部批次号,组成规则:批次号-顺序号,appBatserialno为空时必输
// bizContent.setAppSerialno("WX04-1");
//开始条数,如果送1,则返回排序的第一条开始,appBatserialno不为空时必输
bizContent.setStartId("0");
//bizContent.setStartId("0")
bizContent.setStartId(startId);
//结束条数,每次最多返回50条,返回条数按照结束-开始+1,appBatserialno不为空时必输
bizContent.setEndId("10");
//bizContent.setEndId("10")
bizContent.setEndId(endId);
request.setBizContent(bizContent);
try {
JftApiPayrollQueryDetailResponseV1 responseV1 = client.execute(request);
if (Common.isNotNull(responseV1)) {
return R.ok();
return responseV1;
}
} catch (IcbcApiException e) {
e.printStackTrace();
return R.failed();
log.error("查询银企付款结果出错:", e);
}
return R.ok();
return null;
}
/**
......@@ -501,10 +503,10 @@ public class IcbcTransactionFlowIssueServiceImpl extends ServiceImpl<EkpSocialIn
}
}
}
String batchNo = "WX" + DateUtil.getThisTimeNoLine() + "000" + new Date().getTime();
String batchNo = "WX" + new Date().getTime();
String cur = ekpBankGrantDetailService.getWxNoByWxNo(batchNo);
if (Common.isNotNull(cur)) {
batchNo = "WXCUR" + DateUtil.getThisTimeNoLine() + "000" + new Date().getTime();
batchNo = "WX" + new Date().getTime();
}
// 组装、上传文件
return getEkpBankAttaVo(batchNo, vo, fdId, Integer.parseInt(type), list);
......@@ -727,37 +729,114 @@ public class IcbcTransactionFlowIssueServiceImpl extends ServiceImpl<EkpSocialIn
// 2:获取主表已发放且明细表发放中的明细表数据,查询工行接口
List<EkpBankResultVo> detailList = ekpBankPayTaskService.getEkpBankMainByNeedResultDetail();
DefaultIcbcClient client = new DefaultIcbcClient(icbcConfigProperties.getAppId(), IcbcConstants.SIGN_TYPE_RSA2,
icbcConfigProperties.getAppPrivateKey(), IcbcConstants.CHARSET_UTF8, IcbcConstants.FORMAT_JSON,
icbcConfigProperties.getApigwPublicKey(), IcbcConstants.ENCRYPT_TYPE_AES, icbcConfigProperties.getAesKey()
, null, null);
JftApiPayrollQueryDetailRequestV1 request = new JftApiPayrollQueryDetailRequestV1();
request.setServiceUrl("https://gw.open.icbc.com.cn/api/jft/api/payroll/querydetail/V1");
JftApiPayrollQueryDetailRequestV1.JftApiPayrollQueryDetailRequestV1Biz bizContent = new
JftApiPayrollQueryDetailRequestV1.JftApiPayrollQueryDetailRequestV1Biz();
bizContent.setAppId(icbcConfigProperties.getAppId());
//企业编号
bizContent.setOutVendorId(icbcConfigProperties.getCompanyNo());
//查询类型:1 批次 2 批次明细
bizContent.setType("2");
//批次号,appSerialno为空时,必输
bizContent.setAppBatserialno("WX203");
//内部批次号,组成规则:批次号-顺序号,appBatserialno为空时必输
// bizContent.setAppSerialno("WX04-1");
//开始条数,如果送1,则返回排序的第一条开始,appBatserialno不为空时必输
bizContent.setStartId("0");
//结束条数,每次最多返回50条,返回条数按照结束-开始+1,appBatserialno不为空时必输
bizContent.setEndId("10");
request.setBizContent(bizContent);
try {
JftApiPayrollQueryDetailResponseV1 responseV1 = client.execute(request);
JftApiPayrollQueryDetailResponseV1 responseV1;
// 主表
if (mainList != null && !mainList.isEmpty()) {
int startNum;
int endNum;
List<JftApiPayrollQueryDetailResponseV1.JftApiPayrollDetail> dataList;
List<EkpBankGrantDetail> detailDataList;
EkpBankGrantDetail detailData;
EkpBankPayTask main;
List<EkpBankGrantDetail> oldDetailList;
Map<String, EkpBankGrantDetail> oldMap;
for (EkpBankResultVo vo : mainList) {
for (int i = 0; i < vo.getNum(); i += 50) {
startNum = i + 1;
endNum = i + 50;
if (endNum > vo.getNum()) {
endNum = vo.getNum();
}
responseV1 = selectIcbcTransactionFlowInfo(vo.getFdWxNo(), String.valueOf(startNum), String.valueOf(endNum));
if (Common.isNotNull(responseV1)) {
// 返回码,交易成功返回0,正表示业务报错,负表示系统报错
if ("0".equals(responseV1.getReturn_code())) {
// 处理状态: 00-待提交,01-已提交 02-待授权 03-待银行处理, 04-处理成功,05-处理失败
if ("04".equals(responseV1.getStatus())) {
//
dataList = responseV1.getDatalist();
oldDetailList = ekpBankGrantDetailService.getListByParentId(vo.getFdId());
oldMap = new HashMap<>();
if (oldDetailList != null && !oldDetailList.isEmpty()) {
for (EkpBankGrantDetail temp : oldDetailList) {
oldMap.put(temp.getFdSerialNumber(), temp);
}
}
if (dataList != null && !dataList.isEmpty()) {
detailDataList = new ArrayList<>();
for (JftApiPayrollQueryDetailResponseV1.JftApiPayrollDetail data : dataList) {
detailData = oldMap.get(data.getPlatDetailId());
if (detailData != null) {
if ("02".equals(data.getResult())) {
detailData.setFdGrantStatus("发放成功");
} else {
detailData.setFdGrantStatus("发放失败");
detailData.setFdFailureFeedback(data.getCompanyHandlerResult());
// todo-生成发放失败待处理表数据-也可以 批量 生成
}
detailDataList.add(detailData);
}
}
main = new EkpBankPayTask();
main.setFdId(vo.getFdId());
main.setFdGrantStatus("已发放");
ekpBankPayTaskService.updateById(main);
// 更新明细状态为成功或失败
ekpBankGrantDetailService.updateBatchById(detailDataList);
}
} else if ("05".equals(responseV1.getStatus())) {
main = new EkpBankPayTask();
main.setFdId(vo.getFdId());
main.setFdGrantStatus("拒绝授权");
ekpBankPayTaskService.updateById(main);
// 更新明细状态为 发放失败,原因为拒绝授权
ekpBankGrantDetailService.updateStatusByGrantFail(vo.getFdId());
}
}
return R.ok();
}
} catch (IcbcApiException e) {
e.printStackTrace();
return R.failed();
}
}
}
// 明细表
if (detailList != null && !detailList.isEmpty()) {
List<JftApiPayrollQueryDetailResponseV1.JftApiPayrollDetail> dataList;
List<EkpBankGrantDetail> detailDataList = new ArrayList<>();
EkpBankGrantDetail detailData;
for (EkpBankResultVo vo : detailList) {
responseV1 = selectIcbcTransactionFlowInfo(vo.getFdWxNo(), "1", "10");
if (Common.isNotNull(responseV1)) {
// Return_code返回码,交易成功返回0,正表示业务报错,负表示系统报错
// Status处理状态: 00-待提交,01-已提交 02-待授权 03-待银行处理, 04-处理成功,05-处理失败
if ("0".equals(responseV1.getReturn_code()) && "04".equals(responseV1.getStatus())) {
dataList = responseV1.getDatalist();
if (dataList != null && !dataList.isEmpty()) {
for (JftApiPayrollQueryDetailResponseV1.JftApiPayrollDetail data : dataList) {
detailData = new EkpBankGrantDetail();
detailData.setFdParentId(vo.getFdId());
detailData.setFdSerialNumber(data.getPlatDetailId());
if ("02".equals(data.getResult())) {
detailData.setFdGrantStatus("发放成功");
} else {
detailData.setFdGrantStatus("发放失败");
detailData.setFdFailureFeedback(data.getCompanyHandlerResult());
// todo-生成发放失败待处理表数据-也可以 批量 生成
}
detailDataList.add(detailData);
}
}
}
}
}
// todo-生成发放失败待处理表数据-也可以 批量 生成
// todo-更新明细状态为成功或失败
//ekpBankGrantDetailService.updateStatusByGrant(detailDataList);
}
return R.ok();
}
......
......@@ -111,4 +111,15 @@
update ekp_bank_grant_detail a set a.fd_create_time = NOW(),a.fd_grant_status='发放中' where a.fd_parent_id = #{fdParentId}
</update>
<!-- 主表拒绝授权时,批量更新明细表为发放失败,原因为拒绝授权 -->
<update id="updateStatusByGrantFail">
update ekp_bank_grant_detail a set a.fd_grant_status='发放失败',a.fd_failure_feedback = '拒绝授权' where a.fd_parent_id = #{fdParentId}
</update>
<select id="getListByParentId" resultMap="ekpBankGrantDetailMap">
select
a.fd_id,fd_serial_number
from ekp_bank_grant_detail a where a.fd_parent_id = #{fdParentId}
</select>
</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