Commit 10bd1225 authored by hongguangwu's avatar hongguangwu

MVP1.7.2 工行5次提交_明细发放状态更新

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