Commit 23b97fb4 authored by fangxinjiang's avatar fangxinjiang

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

parents db1ab3dd d51efc84
......@@ -221,4 +221,10 @@ public class EkpBankGrantDetail {
@Schema(description = "MD码")
private String fdMdCode;
@ExcelAttribute(name = "工资明细ID", maxLength = 36)
@Length(max = 36, message = "工资明细ID不能超过36个字符")
@ExcelProperty("工资明细ID")
@Schema(description = "工资明细ID,用来同步中信银行状态")
private String fdSalaryId;
}
......@@ -19,6 +19,7 @@ package com.yifu.cloud.plus.v1.ekp.entity;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute;
......@@ -27,7 +28,10 @@ import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
/**
* 发放日志(银企付款任务)
......@@ -64,14 +68,6 @@ public class EkpBankGrantLog {
@ExcelProperty("代发批次号")
@Schema(description = "代发批次号")
private String fdBatchNumber;
/**
* 代发批次号ID:跳转使用
*/
@ExcelAttribute(name = "代发批次号ID:跳转使用", maxLength = 36)
@Length(max = 36, message = "代发批次号ID:跳转使用不能超过36个字符")
@ExcelProperty("代发批次号ID:跳转使用")
@Schema(description = "代发批次号ID:跳转使用")
private String fdBatchNumberId;
/**
* 批量包名称
*/
......@@ -125,28 +121,28 @@ public class EkpBankGrantLog {
@ExcelAttribute(name = "交易时间", isDate = true)
@ExcelProperty("交易时间")
@Schema(description = "交易时间")
private LocalDateTime fdTransactionTime;
private Date fdTransactionTime;
/**
* 成功总金额
*/
@ExcelAttribute(name = "成功总金额")
@ExcelProperty("成功总金额")
@Schema(description = "成功总金额")
private Double fdSuccessFee;
private BigDecimal fdSuccessFee;
/**
* 失败总金额
*/
@ExcelAttribute(name = "失败总金额")
@ExcelProperty("失败总金额")
@Schema(description = "失败总金额")
private Double fdFailFee;
private BigDecimal fdFailFee;
/**
* 总金额
*/
@ExcelAttribute(name = "总金额")
@ExcelProperty("总金额")
@Schema(description = "总金额")
private Double fdSumFee;
private BigDecimal fdSumFee;
/**
* 总笔数
*/
......@@ -167,6 +163,6 @@ public class EkpBankGrantLog {
@ExcelAttribute(name = "失败总笔数")
@ExcelProperty("失败总笔数")
@Schema(description = "失败总笔数")
private Integer fdTransactionFailToal;
private Integer fdTransactionFailTotal;
}
......@@ -27,6 +27,7 @@ import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import java.math.BigDecimal;
/**
* 发放日志明细(银企付款任务)
......@@ -77,7 +78,7 @@ public class EkpBankGrantLogDetail {
@ExcelAttribute(name = "金额")
@ExcelProperty("金额")
@Schema(description = "金额")
private Double fdMoney;
private BigDecimal fdMoney;
/**
* 收款银行
*/
......
package com.yifu.cloud.plus.v1.ekp.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
......@@ -16,5 +17,18 @@ public class EkpBankResultVo implements Serializable {
private String fdId;
private String fdParentId;
private String fdWxNo;
private String fdSalaryId;
@Schema(description = "付款银行名称")
private String fdBankName;
@Schema(description = "付款银行开户行")
private String fdBankNo;
@Schema(description = "付款银行账户")
private String fdBankAccount;
@Schema(description = "收款人名称")
private String fdPayeeName;
private Integer fdGrantNum;
private Integer fdFailNum;
private Integer num;
}
......@@ -51,6 +51,16 @@ public interface EkpBankGrantDetailMapper extends BaseMapper<EkpBankGrantDetail>
// 主表拒绝授权时,批量更新明细表为发放失败,原因为拒绝授权
void updateStatusByGrantFail(@Param("fdParentId") String fdParentId);
// 发放失败,批量更新中信银行交易流水表fd_3b148bc0c28e48为失败,根据 工资明细fdId:fd_3b1fe00b0f5dde
void updateZhongXinStatus(@Param("salaryIdList") List<String> salaryIdList);
// 发放失败,批量更新中信银行交易流水Model表fd_3b148bc0c28e48为失败,根据 工资明细fdId:fd_3b1fe00b0f5dde
void updateZhongXinMainStatus(@Param("salaryIdList") List<String> salaryIdList);
// 发放失败,批量更新中信银行交易流水表fd_3b148bc0c28e48为失败,根据 工资明细fdId:fd_3b1fe00b0f5dde
void updateZhongXinStatusAndBankInfo(@Param("salaryIdList") List<String> salaryIdList);
// 发放失败,批量更新中信银行交易流水Model表fd_3b148bc0c28e48为失败,根据 工资明细fdId:fd_3b1fe00b0f5dde
void updateZhongXinMainStatusAndBankInfo(@Param("salaryIdList") List<String> salaryIdList);
// 获取明细表ID来更新状态
List<EkpBankGrantDetail> getListByParentId(@Param("fdParentId") String fdParentId);
......
......@@ -20,6 +20,7 @@ package com.yifu.cloud.plus.v1.ekp.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.ekp.entity.EkpBankGrantDetail;
import com.yifu.cloud.plus.v1.ekp.vo.EkpBankExcelVo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
......@@ -46,6 +47,14 @@ public interface EkpBankGrantDetailService extends IService<EkpBankGrantDetail>
// 主表发放时,更新明细表的发放时间与状态
void updateStatusByGrant(String fdParentId);
// 发放失败,批量更新中信银行交易流水表fd_3b148bc0c28e48为失败,根据 工资明细fdId:fd_3b1fe00b0f5dde
void updateZhongXinStatus(List<String> salaryIdList);
void updateZhongXinMainStatus(List<String> salaryIdList);
// 明细再次-发放失败,批量更新中信银行交易流水表fd_3b148bc0c28e48为失败,根据 工资明细fdId:fd_3b1fe00b0f5dde
void updateZhongXinStatusAndBankInfo(List<String> salaryIdList);
void updateZhongXinMainStatusAndBankInfo(List<String> salaryIdList);
// 主表拒绝授权时,批量更新明细表为发放失败,原因为拒绝授权
void updateStatusByGrantFail(String fdParentId);
......
......@@ -62,6 +62,30 @@ public class EkpBankGrantDetailServiceImpl extends ServiceImpl<EkpBankGrantDetai
baseMapper.updateStatusByGrant(fdParentId);
}
// 发放失败,批量更新中信银行交易流水表fd_3b148bc0c28e48为失败,根据 工资明细fdId:fd_3b1fe00b0f5dde
@Override
public void updateZhongXinStatus(List<String> salaryIdList) {
baseMapper.updateZhongXinStatus(salaryIdList);
}
// 发放失败,批量更新中信银行交易流水表fd_3b148bc0c28e48为失败,根据 工资明细fdId:fd_3b1fe00b0f5dde
@Override
public void updateZhongXinMainStatus(List<String> salaryIdList) {
baseMapper.updateZhongXinMainStatus(salaryIdList);
}
// 明细再次-发放失败,批量更新中信银行交易流水表fd_3b148bc0c28e48为失败,根据 工资明细fdId:fd_3b1fe00b0f5dde
@Override
public void updateZhongXinStatusAndBankInfo(List<String> salaryIdList) {
baseMapper.updateZhongXinStatusAndBankInfo(salaryIdList);
}
// 明细再次-发放失败,批量更新中信银行交易流水表fd_3b148bc0c28e48为失败,根据 工资明细fdId:fd_3b1fe00b0f5dde
@Override
public void updateZhongXinMainStatusAndBankInfo(List<String> salaryIdList) {
baseMapper.updateZhongXinMainStatusAndBankInfo(salaryIdList);
}
@Override
public void updateStatusByGrantFail(String fdParentId) {
baseMapper.updateStatusByGrantFail(fdParentId);
......
......@@ -2,6 +2,8 @@ package com.yifu.cloud.plus.v1.ekp.service.impl;
import com.alibaba.excel.EasyExcelFactory;
import com.alibaba.excel.support.ExcelTypeEnum;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.icbc.api.DefaultIcbcClient;
......@@ -73,7 +75,27 @@ public class IcbcTransactionFlowIssueServiceImpl extends ServiceImpl<EkpSocialIn
@Autowired
private EkpBankAttaService ekpBankAttaService;
@Autowired
private EkpBankGrantLogService ekpBankGrantLogService;
@Autowired
private EkpBankGrantLogDetailService ekpBankGrantLogDetailService;
@Autowired
private OSSUtil ossUtil;
@Autowired
private RedisUtil redisUtil;
// 处理状态:00-提交成功,01-待银行处理 02-处理成功 03-处理失败,4-收方行处理中 5-收方行处理成功 6-收方行处理失败 7-收方行无法反馈
protected final static Map<String, String> STATUS_MAP;
static {
STATUS_MAP = new HashMap<>();
STATUS_MAP.put("00", "提交成功");
STATUS_MAP.put("01", "待银行处理");
STATUS_MAP.put("02", "处理成功");
STATUS_MAP.put("03", "处理失败");
STATUS_MAP.put("04", "收方行处理中");
STATUS_MAP.put("05", "收方行处理成功");
STATUS_MAP.put("06", "收方行处理失败");
STATUS_MAP.put("07", "收方行无法反馈");
}
//1、网关公钥
//private static final String APIGW_PUBLIC_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCMpjaWjngB4E3ATh+G1DVAmQnIpiPEFAEDqRfNGAVvvH35yDetqewKi0l7OEceTMN1C6NPym3zStvSoQayjYV+eIcZERkx31KhtFu9clZKgRTyPjdKMIth/wBtPKjL/5+PYalLdomM4ONthrPgnkN4x4R0+D4+EBpXo8gNiAFsNwIDAQAB";
......@@ -376,8 +398,9 @@ public class IcbcTransactionFlowIssueServiceImpl extends ServiceImpl<EkpSocialIn
**/
@Override
@Transactional
public synchronized R<EkpBankAttaReturnVo> getIssueFileByFdId(String fdId, String type) {
public R<EkpBankAttaReturnVo> getIssueFileByFdId(String fdId, String type) {
if (Common.isNotNull(fdId) && Common.isNotNull(type)) {
String redisKey = "DOWN_BANK_"+fdId;
// 返回EKP的Vo
EkpBankAttaReturnVo vo = new EkpBankAttaReturnVo();
......@@ -390,9 +413,16 @@ public class IcbcTransactionFlowIssueServiceImpl extends ServiceImpl<EkpSocialIn
return R.failed("未找到表数据!");
} else if (Common.isNotNull(main.getFdDownloadNum()) && Common.isNotNull(main.getFdFailNum())
&& (CommonConstants.ZERO_INT == main.getFdDownloadNum() || main.getFdDownloadNum().equals(main.getFdFailNum()))) {
if (Common.isNotNull(redisUtil.get(redisKey))) {
return R.failed("数据锁定中,请耐心等待!!");
} else {
redisUtil.set(redisKey, 600L);
}
// 新下载
list = ekpBankGrantDetailService.getEkpBankExcelVoByIdAndMain(fdId);
return getNewFileByMain(fdId, type, vo, list, main);
R<EkpBankAttaReturnVo> returnVoR = getNewFileByMain(fdId, type, vo, list, main);
redisUtil.remove(redisKey);
return returnVoR;
} else if (Common.isNotNull(main.getFdAttaSrc())) {
// 取URL数据返回
return getOldAttaUrl(vo, main.getFdAttaSrc(), main.getFdAttaName());
......@@ -404,9 +434,16 @@ public class IcbcTransactionFlowIssueServiceImpl extends ServiceImpl<EkpSocialIn
return R.failed("未找到表数据!");
} else if (Common.isNotNull(detail.getFdDownloadNum()) && Common.isNotNull(detail.getFdFailNum())
&& (CommonConstants.ZERO_INT == detail.getFdDownloadNum() || detail.getFdDownloadNum().equals(detail.getFdFailNum()))) {
if (Common.isNotNull(redisUtil.get(redisKey))) {
return R.failed("数据下载中,请耐心等待!");
} else {
redisUtil.set(redisKey, 600L);
}
// 新下载
list = ekpBankGrantDetailService.getEkpBankExcelVoByIdAndDetail(fdId);
return getNewFileByDetail(fdId, type, vo, list, detail);
R<EkpBankAttaReturnVo> returnVoR = getNewFileByDetail(fdId, type, vo, list, detail);
redisUtil.remove(redisKey);
return returnVoR;
} else if (Common.isNotNull(detail.getFdAttaSrc())) {
// 取URL数据返回
return getOldAttaUrl(vo, detail.getFdAttaSrc(), detail.getFdAttaName());
......@@ -637,27 +674,33 @@ public class IcbcTransactionFlowIssueServiceImpl extends ServiceImpl<EkpSocialIn
**/
@Override
@Transactional
public synchronized R<String> submitBankTask(String fdId, String type) {
public R<String> submitBankTask(String fdId, String type) {
if (Common.isNotNull(fdId) && Common.isNotNull(type)) {
String redisKey = "SUBMIT_BANK_"+fdId;
if (Common.isNotNull(redisUtil.get(redisKey))) {
return R.failed("数据锁定中,请耐心等待!");
} else {
redisUtil.set(redisKey, 600L);
}
// 1主表
if (CommonConstants.ONE_STRING.equals(type)) {
EkpBankPayTask main = ekpBankPayTaskService.getById(fdId);
if (main == null) {
redisUtil.remove(redisKey);
return R.failed("未找到表数据!");
}
if (!"待发放".equals(main.getFdGrantStatus())) {
redisUtil.remove(redisKey);
return R.failed("状态不是待发放!");
}
if (Common.isNotNull(main.getFdDownloadNum()) && Common.isNotNull(main.getFdGrantNum())
&& main.getFdDownloadNum() > main.getFdGrantNum()) {
if (Common.isEmpty(main.getFdMoney())) {
redisUtil.remove(redisKey);
return R.failed("数据错误,无金额!");
}
int count = ekpBankGrantDetailService.getCountByIdAndMain(fdId);
String totalAmt = String.valueOf(BigDecimalUtils.safeMultiply(main.getFdMoney(), new BigDecimal("100"), 0));
if (!"1".equals(totalAmt)) {
return R.failed("测试阶段,金额不是1分钱,请联系hgw解除禁止!");
}
String totalCount = String.valueOf(count);
String wxNo = main.getFdWxNo();
String url = main.getFdAttaName();
......@@ -671,28 +714,30 @@ public class IcbcTransactionFlowIssueServiceImpl extends ServiceImpl<EkpSocialIn
// 同步更新明细的发放时间、发放状态
ekpBankGrantDetailService.updateStatusByGrant(fdId);
}
redisUtil.remove(redisKey);
return returnR;
} else {
redisUtil.remove(redisKey);
return R.failed("请检查状态!");
}
} else {
// 2明细表
EkpBankGrantDetail detail = ekpBankGrantDetailService.getById(fdId);
if (detail == null) {
redisUtil.remove(redisKey);
return R.failed("未找到明细表数据!");
}
if (!"待发放".equals(detail.getFdGrantStatus())) {
if (!"待发放".equals(detail.getFdHandleStatus())) {
redisUtil.remove(redisKey);
return R.failed("状态不是待发放!");
}
if (Common.isNotNull(detail.getFdDownloadNum()) && Common.isNotNull(detail.getFdGrantNum())
&& detail.getFdDownloadNum() > detail.getFdGrantNum()) {
if (Common.isEmpty(detail.getFdMoney())) {
redisUtil.remove(redisKey);
return R.failed("数据错误,无金额!");
}
String totalAmt = String.valueOf(BigDecimalUtils.safeMultiply(detail.getFdMoney(), new BigDecimal("100"), 0));
if (!"1".equals(totalAmt)) {
return R.failed("测试阶段,金额不是1分钱,请联系hgw解除禁止!");
}
String totalCount = "1";
String wxNo = detail.getFdWxNo();
String url = detail.getFdAttaName();
......@@ -704,8 +749,10 @@ public class IcbcTransactionFlowIssueServiceImpl extends ServiceImpl<EkpSocialIn
detail.setFdGrantNum(detail.getFdGrantNum() + 1);
ekpBankGrantDetailService.updateById(detail);
}
redisUtil.remove(redisKey);
return returnR;
} else {
redisUtil.remove(redisKey);
return R.failed("请检查状态!");
}
}
......@@ -726,11 +773,13 @@ public class IcbcTransactionFlowIssueServiceImpl extends ServiceImpl<EkpSocialIn
// 1:获取发放中的主表数据,查询工行接口
List<EkpBankResultVo> mainList = ekpBankPayTaskService.getEkpBankMainByNeedResultMain();
// 2:获取主表已发放且明细表发放中的明细表数据,查询工行接口
List<EkpBankResultVo> detailList = ekpBankPayTaskService.getEkpBankMainByNeedResultDetail();
JftApiPayrollQueryDetailResponseV1 responseV1;
// 发放日志
List<EkpBankGrantLogDetail> logDetailList = new ArrayList<>();
EkpBankGrantLog logs;
EkpBankGrantLogDetail logDetail;
BigDecimal money;
// 主表
if (mainList != null && !mainList.isEmpty()) {
int startNum;
......@@ -740,11 +789,17 @@ public class IcbcTransactionFlowIssueServiceImpl extends ServiceImpl<EkpSocialIn
EkpBankGrantDetail detailData;
EkpBankPayTask main;
List<EkpBankGrantDetail> oldDetailList;
List<String> zhongXinSalaryIdList;
Map<String, EkpBankGrantDetail> oldMap;
BigDecimal moneySuccess;
BigDecimal moneyFail;
BigDecimal moneyAll;
int numSuccess;
int numFail;
for (EkpBankResultVo vo : mainList) {
for (int i = 0; i < vo.getNum(); i += 50) {
startNum = i + 1;
endNum = i + 50;
for (int i = 0; i < vo.getNum(); i += 49) {
startNum = i;
endNum = i + 49;
if (endNum > vo.getNum()) {
endNum = vo.getNum();
}
......@@ -754,7 +809,10 @@ public class IcbcTransactionFlowIssueServiceImpl extends ServiceImpl<EkpSocialIn
if ("0".equals(responseV1.getReturn_code())) {
// 处理状态: 00-待提交,01-已提交 02-待授权 03-待银行处理, 04-处理成功,05-处理失败
if ("04".equals(responseV1.getStatus())) {
//
// 生成日志主表
logs = saveNewEkpBankGrantLog(responseV1, vo);
dataList = responseV1.getDatalist();
oldDetailList = ekpBankGrantDetailService.getListByParentId(vo.getFdId());
oldMap = new HashMap<>();
......@@ -763,30 +821,77 @@ public class IcbcTransactionFlowIssueServiceImpl extends ServiceImpl<EkpSocialIn
oldMap.put(temp.getFdSerialNumber(), temp);
}
}
moneyAll = BigDecimal.ZERO;
moneySuccess = BigDecimal.ZERO;
moneyFail = BigDecimal.ZERO;
numSuccess = 0;
numFail = 0;
if (dataList != null && !dataList.isEmpty()) {
detailDataList = new ArrayList<>();
zhongXinSalaryIdList = new ArrayList<>();
for (JftApiPayrollQueryDetailResponseV1.JftApiPayrollDetail data : dataList) {
// 交易时间
if (Common.isNotNull(data.getCompanyHandleTime())) {
logs.setFdTransactionTime(DateUtil.stringToDate(data.getCompanyHandleTime(), DateUtil.DATETIME_PATTERN_SECOND));
}
money = BigDecimalUtils.safeDivide(new BigDecimal(data.getPayamt()), new BigDecimal("100"), 2);
moneyAll = BigDecimalUtils.safeAdd(moneyAll, money);
// 初始化日志明细
logDetail = setLogDetailBaseInfo(logs, money, vo, data);
detailData = oldMap.get(data.getPlatDetailId());
if (detailData != null) {
// 收款人名称
logDetail.setFdPayee(detailData.getFdPayeeName());
if ("02".equals(data.getResult())) {
moneySuccess = BigDecimalUtils.safeAdd(moneySuccess, money);
numSuccess++;
detailData.setFdGrantStatus("发放成功");
detailData.setFdHandleStatus("已处理");
} else {
moneyFail = BigDecimalUtils.safeAdd(moneyFail, money);
numFail++;
detailData.setFdGrantStatus("发放失败");
detailData.setFdHandleStatus("");
detailData.setFdFailureFeedback(data.getCompanyHandlerResult());
// todo-生成发放失败待处理表数据-也可以 批量 生成
// 批量更新中信银行表数据,使发放失败处理有数据出现
zhongXinSalaryIdList.add(detailData.getFdSalaryId());
}
detailDataList.add(detailData);
}
logDetailList.add(logDetail);
}
ekpBankGrantLogDetailService.saveBatch(logDetailList);
main = new EkpBankPayTask();
main.setFdId(vo.getFdId());
main.setFdGrantStatus("已发放");
main.setFdGrantNum(vo.getFdGrantNum()+1);
ekpBankPayTaskService.updateById(main);
// 更新明细状态为成功或失败
ekpBankGrantDetailService.updateBatchById(detailDataList);
// 生成发放失败待处理表数据-也可以 批量 生成
if (!zhongXinSalaryIdList.isEmpty()) {
ekpBankGrantDetailService.updateZhongXinStatus(zhongXinSalaryIdList);
ekpBankGrantDetailService.updateZhongXinMainStatus(zhongXinSalaryIdList);
}
}
if (numSuccess > 0) {
moneyFail = BigDecimalUtils.safeSubtract(moneyAll, moneySuccess);
numFail = vo.getNum() - numSuccess;
}
// 失败总金额
logs.setFdFailFee(moneyFail);
// 成功总金额
logs.setFdSuccessFee(moneySuccess);
// 总金额
logs.setFdSumFee(moneyAll);
// 失败总笔数
logs.setFdTransactionFailTotal(numFail);
// 成功总笔数
logs.setFdTransactionSuccessTotal(numSuccess);
ekpBankGrantLogService.updateById(logs);
} else if ("05".equals(responseV1.getStatus())) {
main = new EkpBankPayTask();
main.setFdId(vo.getFdId());
......@@ -795,7 +900,6 @@ public class IcbcTransactionFlowIssueServiceImpl extends ServiceImpl<EkpSocialIn
// 更新明细状态为 发放失败,原因为拒绝授权
ekpBankGrantDetailService.updateStatusByGrantFail(vo.getFdId());
}
}
return R.ok();
}
......@@ -803,42 +907,129 @@ public class IcbcTransactionFlowIssueServiceImpl extends ServiceImpl<EkpSocialIn
}
}
// 2:获取主表已发放且明细表发放中的明细表数据,查询工行接口
List<EkpBankResultVo> detailList = ekpBankPayTaskService.getEkpBankMainByNeedResultDetail();
// 明细表
if (detailList != null && !detailList.isEmpty()) {
List<JftApiPayrollQueryDetailResponseV1.JftApiPayrollDetail> dataList;
List<EkpBankGrantDetail> detailDataList = new ArrayList<>();
EkpBankGrantDetail detailData;
List<String> zhongXinSalaryIdList = new ArrayList<>();
JftApiPayrollQueryDetailResponseV1.JftApiPayrollDetail data;
for (EkpBankResultVo vo : detailList) {
responseV1 = selectIcbcTransactionFlowInfo(vo.getFdWxNo(), "1", "10");
responseV1 = selectIcbcTransactionFlowInfo(vo.getFdWxNo(), "0", "1");
if (Common.isNotNull(responseV1)) {
// Return_code返回码,交易成功返回0,正表示业务报错,负表示系统报错
// Status处理状态: 00-待提交,01-已提交 02-待授权 03-待银行处理, 04-处理成功,05-处理失败
if ("0".equals(responseV1.getReturn_code()) && "04".equals(responseV1.getStatus())) {
if ("0".equals(responseV1.getReturn_code()) && "04".equals(responseV1.getStatus())
&& responseV1.getDatalist() != null && !responseV1.getDatalist().isEmpty()) {
dataList = responseV1.getDatalist();
if (dataList != null && !dataList.isEmpty()) {
for (JftApiPayrollQueryDetailResponseV1.JftApiPayrollDetail data : dataList) {
// 明细只有一条
data = dataList.get(0);
money = BigDecimalUtils.safeDivide(new BigDecimal(data.getPayamt()), new BigDecimal("100"), 2);
// 生成日志主表
logs = saveNewEkpBankGrantLog(responseV1, vo);
// 失败总金额
logs.setFdFailFee(BigDecimal.ZERO);
// 成功总金额
logs.setFdSuccessFee(BigDecimal.ZERO);
// 总金额
logs.setFdSumFee(money);
// 失败总笔数
logs.setFdTransactionFailTotal(0);
// 成功总笔数
logs.setFdTransactionSuccessTotal(0);
// 初始化日志明细
logDetail = setLogDetailBaseInfo(logs, money, vo, data);
// 收款人名称
logDetail.setFdPayee(vo.getFdPayeeName());
ekpBankGrantLogDetailService.save(logDetail);
detailData = new EkpBankGrantDetail();
detailData.setFdParentId(vo.getFdId());
detailData.setFdSerialNumber(data.getPlatDetailId());
if ("02".equals(data.getResult())) {
// 失败总笔数
logs.setFdTransactionSuccessTotal(1);
logs.setFdSuccessFee(money);
detailData.setFdGrantStatus("发放成功");
detailData.setFdHandleStatus("已处理");
detailData.setFdGrantNum(vo.getFdGrantNum() + 1);
} else {
// 失败总笔数
logs.setFdTransactionFailTotal(1);
// 失败总金额
logs.setFdFailFee(money);
detailData.setFdGrantStatus("发放失败");
detailData.setFdHandleStatus("");
detailData.setFdFailureFeedback(data.getCompanyHandlerResult());
// todo-生成发放失败待处理表数据-也可以 批量 生成
detailData.setFdFailNum(vo.getFdFailNum() + 1);
// 批量更新中信银行表数据,使发放失败处理有数据出现
zhongXinSalaryIdList.add(vo.getFdSalaryId());
}
ekpBankGrantLogService.updateById(logs);
detailDataList.add(detailData);
}
}
}
// 更新明细状态为成功或失败
ekpBankGrantDetailService.updateBatchById(detailDataList);
// 生成发放失败待处理表数据-也可以 批量 生成
if (!zhongXinSalaryIdList.isEmpty()) {
ekpBankGrantDetailService.updateZhongXinStatusAndBankInfo(zhongXinSalaryIdList);
ekpBankGrantDetailService.updateZhongXinMainStatusAndBankInfo(zhongXinSalaryIdList);
}
}
// todo-生成发放失败待处理表数据-也可以 批量 生成
// todo-更新明细状态为成功或失败
//ekpBankGrantDetailService.updateStatusByGrant(detailDataList);
}
return R.ok();
}
/**
* @Description: 初始化日志明细
* @Author: hgw
* @Date: 2024/11/26 20:08
* @return: com.yifu.cloud.plus.v1.ekp.entity.EkpBankGrantLogDetail
**/
private EkpBankGrantLogDetail setLogDetailBaseInfo(EkpBankGrantLog logs, BigDecimal money, EkpBankResultVo vo, JftApiPayrollQueryDetailResponseV1.JftApiPayrollDetail data) {
EkpBankGrantLogDetail logDetail;
logDetail = new EkpBankGrantLogDetail();
// 指令状态
logDetail.setFdCommandStatus(STATUS_MAP.get(data.getResult()));
logDetail.setFdParentId(logs.getFdId());
// 收款银行
logDetail.setFdRecipientBank(vo.getFdBankName());
logDetail.setFdMoney(money);
// 收款账号
logDetail.setFdPayeeAccount(data.getRecDepAcc());
logDetail.setFdRemark(data.getRemark());
// 汇款用途
logDetail.setFdRemittancePurpose("工资");
return logDetail;
}
/**
* @Description: 初始化生成日志主表
* @Author: hgw
* @Date: 2024/11/26 20:09
* @return: com.yifu.cloud.plus.v1.ekp.entity.EkpBankGrantLog
**/
private EkpBankGrantLog saveNewEkpBankGrantLog(JftApiPayrollQueryDetailResponseV1 responseV1, EkpBankResultVo vo) {
EkpBankGrantLog logs;
logs = new EkpBankGrantLog();
logs.setFdBatchNumber(vo.getFdWxNo());
logs.setFdParentId(vo.getFdId());
logs.setFdBatchPackage(responseV1.getRemark());
logs.setFdBusinessType("代发工资");
logs.setFdCurrency("人民币");
logs.setFdDrawee(vo.getFdBankName());
logs.setFdPaymentAccount(vo.getFdBankAccount());
logs.setFdSubmitTime(LocalDateTime.now());
// 总笔数
logs.setFdTransactionTotal(vo.getNum());
ekpBankGrantLogService.save(logs);
return logs;
}
}
......@@ -49,6 +49,7 @@
<result property="fdEmpPhone" column="fd_emp_phone"/>
<result property="fdWxNo" column="fd_wx_no"/>
<result property="fdMdCode" column="fd_md_dcode"/>
<result property="fdSalaryId" column="fd_salary_id"/>
</resultMap>
<sql id="Base_Excel_Sql">
......@@ -118,8 +119,72 @@
<select id="getListByParentId" resultMap="ekpBankGrantDetailMap">
select
a.fd_id,fd_serial_number
a.fd_id,a.fd_salary_id,a.fd_serial_number,a.fd_payee_name
from ekp_bank_grant_detail a where a.fd_parent_id = #{fdParentId}
</select>
<!-- 发放失败,批量更新中信银行交易流水表fd_3b148bc0c28e48为失败,根据 工资明细fdId:fd_3b1fe00b0f5dde -->
<update id="updateZhongXinStatus">
update ekp_db4ed54e25543f4b7a9a a
set a.fd_3b148bc0c28e48='失败',a.fd_3c754f2a7125a0 = '1183b0b84ee4f581bba001c47a78b2d9',fd_3c754a976ddde2=now()
where
<if test="salaryIdList != null and salaryIdList.size() > 0">
a.fd_3b1fe00b0f5dde in
<foreach collection="salaryIdList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</update>
<!-- 发放失败,批量更新中信银行交易流水Model表fd_3b148bc0c28e48为失败,根据 工资明细fdId:fd_3b1fe00b0f5dde -->
<update id="updateZhongXinMainStatus">
UPDATE modeling_simple_main a
JOIN ekp_db4ed54e25543f4b7a9a b on a.fd_id=b.fd_id
SET a.extend_data_xml=JSON_SET(a.extend_data_xml,'$[1].fd_3b148bc0c28e48', '失败', '$[1].fd_3c754f2a7125a0', '1183b0b84ee4f581bba001c47a78b2d9','$[1].fd_3c754a976ddde2', now())
where
<if test="salaryIdList != null and salaryIdList.size() > 0">
b.fd_3b56782982b8b2 in
<foreach collection="salaryIdList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</update>
<!-- 明细再次-发放失败,批量更新中信银行交易流水表fd_3b148bc0c28e48为失败,根据 工资明细fdId:fd_3b1fe00b0f5dde -->
<update id="updateZhongXinStatusAndBankInfo">
update ekp_db4ed54e25543f4b7a9a a
left join ekp_bank_grant_detail d on a.fd_3b1fe00b0f5dde=d.fd_salary_id
set a.fd_3b148bc0c28e48='失败',a.fd_3c754f2a7125a0 = '1183b0b84ee4f581bba001c47a78b2d9',a.fd_3c754a976ddde2=now(),
a.fd_3afd45029541be=d.fd_payee_name,a.fd_3afd4500f91ae6=d.fd_payee_account,a.fd_3afd4502e34bc0=d.fd_recipient_bank
where
<if test="salaryIdList != null and salaryIdList.size() > 0">
a.fd_3b1fe00b0f5dde in
<foreach collection="salaryIdList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</update>
<!-- 明细再次-发放失败,批量更新中信银行交易流水Model表fd_3b148bc0c28e48为失败,根据 工资明细fdId:fd_3b1fe00b0f5dde -->
<update id="updateZhongXinMainStatusAndBankInfo">
UPDATE modeling_simple_main a
JOIN ekp_db4ed54e25543f4b7a9a b on a.fd_id=b.fd_id
left join ekp_bank_grant_detail d on b.fd_3b1fe00b0f5dde=d.fd_salary_id
SET a.extend_data_xml=JSON_SET(a.extend_data_xml,'$[1].fd_3b148bc0c28e48', '失败'
, '$[1].fd_3c754f2a7125a0', '1183b0b84ee4f581bba001c47a78b2d9'
,'$[1].fd_3c754a976ddde2', now()
,'$[1].fd_3afd45029541be', d.fd_payee_name
,'$[1].fd_3afd4500f91ae6', d.fd_payee_account
,'$[1].fd_3afd4502e34bc0', d.fd_recipient_bank
)
where
<if test="salaryIdList != null and salaryIdList.size() > 0">
b.fd_3b56782982b8b2 in
<foreach collection="salaryIdList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</update>
</mapper>
......@@ -26,7 +26,6 @@
<resultMap id="ekpBankGrantLogMap" type="com.yifu.cloud.plus.v1.ekp.entity.EkpBankGrantLog">
<id property="fdId" column="fd_id"/>
<result property="fdBatchNumber" column="fd_batch_number"/>
<result property="fdBatchNumberId" column="fd_batch_number_id"/>
<result property="fdBatchPackage" column="fd_batch_package"/>
<result property="fdPaymentAccount" column="fd_payment_account"/>
<result property="fdDrawee" column="fd_drawee"/>
......@@ -39,12 +38,11 @@
<result property="fdSumFee" column="fd_sum_fee"/>
<result property="fdTransactionTotal" column="fd_transaction_total"/>
<result property="fdTransactionSuccessTotal" column="fd_transaction_success_total"/>
<result property="fdTransactionFailToal" column="fd_transaction_fail_toal"/>
<result property="fdTransactionFailTotal" column="fd_transaction_fail_total"/>
</resultMap>
<sql id="Base_Column_List">
a.fd_id,
a.fd_batch_number,
a.fd_batch_number_id,
a.fd_batch_package,
a.fd_payment_account,
a.fd_drawee,
......@@ -57,7 +55,7 @@
a.fd_sum_fee,
a.fd_transaction_total,
a.fd_transaction_success_total,
a.fd_transaction_fail_toal
a.fd_transaction_fail_total
</sql>
</mapper>
......@@ -87,7 +87,9 @@
<!-- 获取发放中的主表,查询结果 -->
<select id="getEkpBankMainByNeedResultMain" resultType="com.yifu.cloud.plus.v1.ekp.vo.EkpBankResultVo">
select a.fd_id fdId,a.fd_wx_no fdWxNo,count(d.fd_id) num
select a.fd_id fdId,a.fd_wx_no fdWxNo
,count(d.fd_id) num,a.fd_bank_name fdBankName,a.fd_bank_no fdBankNo,a.fd_bank_account fdBankAccount
,a.fd_grant_num fdGrantNum
from ekp_bank_pay_task a left join ekp_bank_grant_detail d on a.fd_id = d.fd_parent_id
where a.fd_grant_status = '发放中'
GROUP BY a.fd_id
......@@ -95,7 +97,9 @@
<!-- 获取发放中的明细表,查询结果 -->
<select id="getEkpBankMainByNeedResultDetail" resultType="com.yifu.cloud.plus.v1.ekp.vo.EkpBankResultVo">
select d.fd_id fdId,d.fd_wx_no fdWxNo,d.fd_parent_id fdParentId,'1' num
select d.fd_id fdId,d.fd_wx_no fdWxNo,d.fd_parent_id fdParentId,d.fd_fail_num fdFailNum,d.fd_salary_id fdSalaryId
,'1' num,a.fd_bank_name fdBankName,a.fd_bank_no fdBankNo,a.fd_bank_account fdBankAccount,d.fd_payee_name fdPayeeName
,d.fd_grant_num fdGrantNum
from ekp_bank_grant_detail d left join ekp_bank_pay_task a on a.fd_id = d.fd_parent_id
where a.fd_grant_status = '已发放' and d.fd_grant_status = '发放失败' and d.fd_handle_status = '发放中'
</select>
......
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