Commit 3defdec6 authored by hongguangwu's avatar hongguangwu

1.7.20-非扣税银企

parent 92bb4f0f
......@@ -695,6 +695,9 @@ public interface CommonConstants {
String GU_DING = "gu_ding";
// 税友、关键字里的户:
String HU_CORE = "_户户_";
// 币种:ISO币种,仅支持人民币
String CNY = "CNY";
String ICBC_NAME = "工商";
// 前端客服角色ID(全服管理者)
long CS_ROLE_ID = 1839501715787390978L;
......
......@@ -226,7 +226,7 @@ public class EkpBankPayTask {
@Schema(description = "附件资源路径")
private String fdAttaSrc;
/**
* 附件下载次数
* 附件下载次数(非扣税10对公11对私)
*/
@ExcelAttribute(name = "附件下载次数")
@ExcelProperty("附件下载次数")
......
......@@ -4,8 +4,11 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.icbc.api.IcbcApiException;
import com.yifu.cloud.plus.v1.ekp.entity.EkpBankCodeSet;
import com.yifu.cloud.plus.v1.ekp.entity.EkpSocialInfo;
import com.yifu.cloud.plus.v1.ekp.vo.EkpBankExcelVo;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import java.util.List;
/**
* 聚富通到账通知交易流水查询
*
......@@ -48,6 +51,11 @@ public interface IcbcTransactionFlowQueryService extends IService<EkpSocialInfo>
R executePayment();
// 工行非税支付
// type 0 对公; 1 对私.
R<String> submitIcbcToNoTax(String totalAmt, String totalCount, String wxNo
, List<EkpBankExcelVo> detailList, int type, String fdId);
R submitSearch();
}
......@@ -542,12 +542,24 @@ public class IcbcTransactionFlowIssueServiceImpl extends ServiceImpl<EkpSocialIn
private EkpBankAtta getNewFileCore(String fdId, String type, EkpBankAttaReturnVo vo, List<EkpBankExcelVo> list
, Map<String, EkpBankCodeConfiglVo> bankMap) {
EkpBankCodeSet codeSet;
R<EkpBankCodeSet> bankInfoQuery;
EkpBankCodeConfiglVo bankVo;
// 组装
initFdRecipientBankCodeAndName(list, bankMap);
String batchNo = "WX" + new Date().getTime();
String cur = ekpBankGrantDetailService.getWxNoByWxNo(batchNo);
if (Common.isNotNull(cur)) {
batchNo = "WX" + new Date().getTime();
}
// 组装、上传文件
return getEkpBankAttaVo(batchNo, vo, fdId, Integer.parseInt(type), list);
}
// 初始化收款银行行号和行名
private void initFdRecipientBankCodeAndName(List<EkpBankExcelVo> list, Map<String, EkpBankCodeConfiglVo> bankMap) {
//工行的卡号bin list
List<String> binList = baseMapper.getAllIcbcCardBinInfo();
EkpBankCodeSet codeSet;
EkpBankCodeConfiglVo bankVo;
R<EkpBankCodeSet> bankInfoQuery;
for (EkpBankExcelVo excelVo : list) {
if (Common.isEmpty(excelVo.getFdRecipientBankCode())) {
//工行的卡号通过bin来判断,如果是工行的卡号,则不需要行名行号
......@@ -582,13 +594,6 @@ public class IcbcTransactionFlowIssueServiceImpl extends ServiceImpl<EkpSocialIn
}
}
}
String batchNo = "WX" + new Date().getTime();
String cur = ekpBankGrantDetailService.getWxNoByWxNo(batchNo);
if (Common.isNotNull(cur)) {
batchNo = "WX" + new Date().getTime();
}
// 组装、上传文件
return getEkpBankAttaVo(batchNo, vo, fdId, Integer.parseInt(type), list);
}
......@@ -838,6 +843,8 @@ public class IcbcTransactionFlowIssueServiceImpl extends ServiceImpl<EkpSocialIn
redisUtil.set(redisKey, 600L);
}
try {
// 获取配置的行号
Map<String, EkpBankCodeConfiglVo> bankMap = ekpBankGrantDetailService.getEkpBankCodeConfiglVo();
// 1主表
if (CommonConstants.ONE_STRING.equals(type)) {
EkpBankPayTask main = ekpBankPayTaskService.getById(fdId);
......@@ -857,10 +864,25 @@ public class IcbcTransactionFlowIssueServiceImpl extends ServiceImpl<EkpSocialIn
String totalAmt = String.valueOf(BigDecimalUtils.safeMultiply(main.getFdMoney(), new BigDecimal("100"), 0));
String totalCount = String.valueOf(count);
String wxNo = main.getFdWxNo();
String url = main.getFdAttaName();
String mdCode = main.getFdMdCode();
// TODO -真正的发放接口需要改造
R<String> returnR = submitIcbcTransactionFlow(totalAmt, totalCount, wxNo, url, mdCode);
if (Common.isEmpty(wxNo)) {
wxNo = "FKS" + new Date().getTime();
String cur = ekpBankGrantDetailService.getWxNoByWxNo(wxNo);
if (Common.isNotNull(cur)) {
wxNo = "FKS" + new Date().getTime();
}
main.setFdWxNo(wxNo);
// 更新wxno
ekpBankPayTaskService.updateById(main);
}
List<EkpBankExcelVo> detailList = ekpBankGrantDetailService.getEkpBankExcelVoByIdAndMain(fdId);
// 初始化收款银行行号和行名
initFdRecipientBankCodeAndName(detailList, bankMap);
// 0对公1对私
int noTaxPayType = CommonConstants.ZERO_INT;
if (Common.isNotNull(main.getFdDownloadNum()) && 11 == main.getFdDownloadNum()) {
noTaxPayType = CommonConstants.ONE_INT;
}
R<String> returnR = icbcTransactionFlowQueryService.submitIcbcToNoTax(totalAmt, totalCount, wxNo, detailList, noTaxPayType, fdId);
if (returnR.getCode() == CommonConstants.SUCCESS) {
// 存储日志
saveIcbcLogBaseInfoBySumbit(returnR.getData(), wxNo + "_main", fdId);
......@@ -895,9 +917,22 @@ public class IcbcTransactionFlowIssueServiceImpl extends ServiceImpl<EkpSocialIn
String totalAmt = String.valueOf(BigDecimalUtils.safeMultiply(detail.getFdMoney(), new BigDecimal("100"), 0));
String totalCount = "1";
String wxNo = detail.getFdWxNo();
String url = detail.getFdAttaName();
String mdCode = detail.getFdMdCode();
R<String> returnR = submitIcbcTransactionFlow(totalAmt, totalCount, wxNo, url, mdCode);
if (Common.isEmpty(wxNo)) {
wxNo = "FKSMX" + new Date().getTime();
String cur = ekpBankGrantDetailService.getWxNoByWxNo(wxNo);
if (Common.isNotNull(cur)) {
wxNo = "FKSMX" + new Date().getTime();
}
detail.setFdWxNo(wxNo);
ekpBankGrantDetailService.updateById(detail);
}
// 0对公1对私
int noTaxPayType = CommonConstants.ZERO_INT;
if (Common.isNotNull(detail.getFdDownloadNum()) && 11 == detail.getFdDownloadNum()) {
noTaxPayType = CommonConstants.ONE_INT;
}
List<EkpBankExcelVo> detailList = ekpBankGrantDetailService.getEkpBankExcelVoByIdAndDetail(fdId);
R<String> returnR = icbcTransactionFlowQueryService.submitIcbcToNoTax(totalAmt, totalCount, wxNo, detailList, noTaxPayType, fdId);
if (returnR.getCode() == CommonConstants.SUCCESS) {
// 存储日志
saveIcbcLogBaseInfoBySumbit(returnR.getData(), wxNo, fdId);
......
......@@ -12,11 +12,15 @@ import com.icbc.api.response.*;
import com.yifu.cloud.plus.v1.ekp.config.EkpEntryProperties;
import com.yifu.cloud.plus.v1.ekp.config.IcbcConfigProperties;
import com.yifu.cloud.plus.v1.ekp.entity.EkpBankCodeSet;
import com.yifu.cloud.plus.v1.ekp.entity.EkpBankIcbcLog;
import com.yifu.cloud.plus.v1.ekp.entity.EkpSocialInfo;
import com.yifu.cloud.plus.v1.ekp.mapper.EkpSocialInfoMapper;
import com.yifu.cloud.plus.v1.ekp.service.EkpBankCodeSetService;
import com.yifu.cloud.plus.v1.ekp.service.EkpBankIcbcLogService;
import com.yifu.cloud.plus.v1.ekp.service.IcbcTransactionFlowQueryService;
import com.yifu.cloud.plus.v1.ekp.vo.EKPEntryPushParam;
import com.yifu.cloud.plus.v1.ekp.vo.EkpBankExcelVo;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.DateUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
......@@ -60,6 +64,8 @@ public class IcbcTransactionFlowQueryServiceImpl extends ServiceImpl<EkpSocialIn
private EkpEntryProperties ekpEntryProperties;
@Autowired
private EkpBankCodeSetService ekpBankCodeSetService;
@Autowired
private EkpBankIcbcLogService ekpBankIcbcLogService;
@Override
public R getIcbcTransactionFlow() {
......@@ -670,6 +676,99 @@ public class IcbcTransactionFlowQueryServiceImpl extends ServiceImpl<EkpSocialIn
}
}
// 工行非税支付
// 改造自上面的demo接口:executePayment
// type 0 对公; 1 对私.
public R<String> submitIcbcToNoTax(String totalAmt, String totalCount, String wxNo
, List<EkpBankExcelVo> detailList, int type, String fdId) {
// 获取当前时间
LocalTime currentTime = LocalTime.now();
// 使用DateTimeFormatter格式化
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HHmmssSSS");
String formattedTime = currentTime.format(formatter);
DefaultIcbcClient client = new DefaultIcbcClient(icbcConfigProperties.getAppId(), IcbcConstants.SIGN_TYPE_CA_SM_ICBC,
icbcConfigProperties.getAppPrivateKey(), IcbcConstants.CHARSET_UTF8, IcbcConstants.FORMAT_JSON, null,
null, null, icbcConfigProperties.getCaSm(), null);
client.setIcbc_ca(icbcConfigProperties.getCaSmIcbc());
try {
MybankEnterprisePayPayentRequestV2.MybankEnterprisePayPayentRequestBizV2 bizContent =
new MybankEnterprisePayPayentRequestV2.MybankEnterprisePayPayentRequestBizV2();
MybankEnterprisePayPayentRequestV2 request = new MybankEnterprisePayPayentRequestV2();
// 数据进行赋值
//String seqNo = "AHWX" + System.currentTimeMillis();
//交易代码
bizContent.setTransCode("QHISD");
bizContent.setTranDate(DateUtil.getThisDay());
bizContent.setTranTime(formattedTime);
bizContent.setLanguage("zh_CN");
//指令包序列号:系统产生,一个集团永远不能重复
bizContent.setfSeqNo(wxNo);
//报文压缩标识:1:压缩rd区;空/0:不压缩 不压缩的话单次最多200笔;压缩的话单词最多5000笔
bizContent.setZipFlag(CommonConstants.ZERO_STRING);
//入账方式:0:逐笔记账;2:并笔记账
bizContent.setSettleMode(CommonConstants.ZERO_STRING);
//总笔数
bizContent.setInstrCount(Integer.valueOf(totalCount));
//总金额:以分为单位
bizContent.setTotalAmount(Long.valueOf(totalAmt));
//报文压缩内容:zip算法压缩rd区后再BASE64编码,约定取第一个文件
bizContent.setZip("");
//批量包名称,使用非扣税单号
bizContent.setPackageName(wxNo);
List<MybankEnterprisePayPayentRequestV2.MybankEnterprisePayPayentRequestRdV2> rd = new ArrayList<>();
MybankEnterprisePayPayentRequestV2.MybankEnterprisePayPayentRequestRdV2 rdDetail;
for (EkpBankExcelVo detail : detailList) {
// 0 对公
if (CommonConstants.ZERO_INT == type) {
rdDetail = buildPayRecordDuiGong(detail);
} else {
rdDetail = buildPayRecordDuiSi(detail);
}
rd.add(rdDetail);
}
bizContent.setRd(rd);
request.setServiceUrl("https://gw.open.icbc.com.cn/api/mybank/enterprise/pay/payent/V2");
request.setBizContent(bizContent);
String json = JSON.toJSONString(bizContent);
// 保存日志
EkpBankIcbcLog icbcLog = new EkpBankIcbcLog();
icbcLog.setFdCreateTime(LocalDateTime.now());
icbcLog.setFdWxNo(wxNo);
icbcLog.setFdParentId(fdId);
icbcLog.setFdType(3);
icbcLog.setFdLog(json);
ekpBankIcbcLogService.save(icbcLog);
MybankEnterprisePayPayentResponseV2 response = client.execute(request);
icbcLog = new EkpBankIcbcLog();
icbcLog.setFdCreateTime(LocalDateTime.now());
icbcLog.setFdWxNo(wxNo);
icbcLog.setFdParentId(fdId);
icbcLog.setFdType(4);
icbcLog.setFdLog(JSON.toJSONString(response));
ekpBankIcbcLogService.save(icbcLog);
//huych-注意response中有发送成功的指令号。需保存
//result 指令状态:0:提交成功,等待银行处理 1:授权成功,等待银行处理 2:等待授权 3:等待二次授权 4:等待银行答复 5:主机返回待处理
// 6:被银行拒绝 7:处理成功 8:指令被拒绝授权 9:银行正在处理 10:预约指令 11:预约取消 12:等待监管审批
// 13:监管审批成功,等待银行处理 14:指令被监管审批拒绝 40:待确认 41:客户取消 42:等待华商审批 43:华商审批成功
if (response.isSuccess()) {
// 业务成功处理
return R.ok(response.getSerialNo());
} else {
// 失败
return R.failed("工行【非扣税】支付指令提交失败");
}
} catch (Exception e) {
log.error("工行【非扣税】支付指令提交失败", e);
throw new RuntimeException("【非扣税】支付指令提交失败", e);
}
}
@Override
public R submitSearch() {
// 获取当前时间
......@@ -710,6 +809,7 @@ public class IcbcTransactionFlowQueryServiceImpl extends ServiceImpl<EkpSocialIn
}
}
// 对公
private MybankEnterprisePayPayentRequestV2.MybankEnterprisePayPayentRequestRdV2 buildPayRecord() {
MybankEnterprisePayPayentRequestV2.MybankEnterprisePayPayentRequestRdV2 payRecord =
new MybankEnterprisePayPayentRequestV2.MybankEnterprisePayPayentRequestRdV2();
......@@ -723,7 +823,7 @@ public class IcbcTransactionFlowQueryServiceImpl extends ServiceImpl<EkpSocialIn
//对公对私标志:0:对公;1:个人
payRecord.setPayeeType("0");
//币种:ISO币种,仅支持人民币
payRecord.setCurrency("CNY");
payRecord.setCurrency(CommonConstants.CNY);
//记账处理方式:1:加急;2:普通;3:跨行快汇
payRecord.setPayType("1");
//付款方账户名称
......@@ -794,7 +894,7 @@ public class IcbcTransactionFlowQueryServiceImpl extends ServiceImpl<EkpSocialIn
//对公对私标志:0:对公;1:个人
payRecord.setPayeeType("1");
//币种:ISO币种,仅支持人民币
payRecord.setCurrency("CNY");
payRecord.setCurrency(CommonConstants.CNY);
//记账处理方式:1:加急;2:普通;3:跨行快汇
payRecord.setPayType("1");
//付款方账户名称
......@@ -823,6 +923,151 @@ public class IcbcTransactionFlowQueryServiceImpl extends ServiceImpl<EkpSocialIn
return payRecord;
}
// 对公
private MybankEnterprisePayPayentRequestV2.MybankEnterprisePayPayentRequestRdV2 buildPayRecordDuiGong(EkpBankExcelVo detail) {
MybankEnterprisePayPayentRequestV2.MybankEnterprisePayPayentRequestRdV2 payRecord =
new MybankEnterprisePayPayentRequestV2.MybankEnterprisePayPayentRequestRdV2();
//业务唯一编号:相同指令不重复
payRecord.setUniBusiId(generateUniBusiId());
//指令顺序号:每笔指令的序号,本包内不重复
payRecord.setiSeqNo(generateSeqNo());
//预约日期
// payRecord.setScheduleDate("20251126");
//对公对私标志:0:对公;1:个人
payRecord.setPayeeType(CommonConstants.ZERO_STRING);
//币种:ISO币种,仅支持人民币
payRecord.setCurrency(CommonConstants.CNY);
//记账处理方式:1:加急;2:普通;3:跨行快汇
payRecord.setPayType(CommonConstants.ONE_STRING);
//付款方账户名称"安徽皖信人力资源管理有限公司"
payRecord.setPayerCnname(detail.getFdBankName());
// "1302010109024596014"
payRecord.setPayerAccount(detail.getFdBankAccount());
//付款方账户英文名称:账号付款时,中文名称、英文名称至少输入一项
payRecord.setPayerEnname("");
//收款方账号:收方不支持NRA账号"1302015209250019444"
payRecord.setPayeeAccount(detail.getFdPayeeAccount());
//收款方账户名称"安徽易服智享信息科技有限公司"
payRecord.setPayeeCnname(detail.getFdPayeeName());
//收款方账户英文名称
// payRecord.setPayeeEnname("");
//收款方系统内外标志:1:工行;2:他行 必填
if (Common.isEmpty(detail.getFdRecipientBank())
|| detail.getFdRecipientBank().contains(CommonConstants.ICBC_NAME)) {
payRecord.setIoFlag(CommonConstants.ONE_STRING);
} else {
payRecord.setIoFlag(CommonConstants.TWO_STRING);
//收款方行号:跨行指令要求对方行行号和行名上送正确
payRecord.setPayeeBankNo(detail.getFdRecipientBankCode());
//收款方行名
payRecord.setPayeeBankName(detail.getFdRecipientBank());
}
//同城异地标志:1:同城;2:异地 非必填
//payRecord.setSameCityFlag("1");
//收款方所在城市名称
// payRecord.setPayeeCity("合肥市");
//金额:以分为单位
payRecord.setAmount(Long.valueOf(detail.getFdMoney()));
//用途代码
// payRecord.setPurposeCode(record.getPurposeCode());
//用途中文描述:用途代码和用途中文描述二选一上送
if (Common.isNotNull(detail.getFdRemittancePurpose())) {
if (detail.getFdRemittancePurpose().length()>20) {
detail.setFdRemittancePurpose(detail.getFdRemittancePurpose().substring(0,20));
}
payRecord.setPurpose(detail.getFdRemittancePurpose());
} else {
payRecord.setPurpose("转账");
}
//摘要
//payRecord.setSummary("11");
//英文备注
// payRecord.setSummaryEn(record.getSummaryEn());
//附言:不得有非法字符,包括 ' " : %
// payRecord.setPostscript(record.getPostscript());
//业务编号(业务参考号)
// payRecord.setRefNo(record.getRefNo());
//相关业务编号
// payRecord.setRelatedRefNo(record.getRelatedRefNo());
//ERP流水号
// payRecord.setErpSerialNo(record.getErpSerialNo());
//ERP支票号
// payRecord.setErpCheckNo(record.getErpCheckNo());
//业务代码
// payRecord.setBusiCode(record.getBusiCode());
//原始凭证种类
// payRecord.setOriVoucherType(record.getOriVoucherType());
//原始凭证号
// payRecord.setOriVoucherNo(record.getOriVoucherNo());
//原始凭证名称
// payRecord.setOriVoucherName(record.getOriVoucherName());
//预先审批编号
// payRecord.setPreApprovalNo(record.getPreApprovalNo());
//监管用途代码:0:无用途 1:工资及退休金 2:贷款 3:采购款 4:借款 5:拨款 6:还款 7:交款 8:差旅费 9:运费 10:保证金 11:投资 99:其他
// payRecord.setRegulationPurposeCode(record.getRegulationPurposeCode());
return payRecord;
}
private MybankEnterprisePayPayentRequestV2.MybankEnterprisePayPayentRequestRdV2 buildPayRecordDuiSi(EkpBankExcelVo detail) {
MybankEnterprisePayPayentRequestV2.MybankEnterprisePayPayentRequestRdV2 payRecord =
new MybankEnterprisePayPayentRequestV2.MybankEnterprisePayPayentRequestRdV2();
//业务唯一编号:相同指令不重复
payRecord.setUniBusiId(generateUniBusiId());
//指令顺序号:每笔指令的序号,本包内不重复
payRecord.setiSeqNo(generateSeqNo());
//预约日期
// payRecord.setScheduleDate("20251126");
//对公对私标志:0:对公;1:个人
payRecord.setPayeeType(CommonConstants.ONE_STRING);
//币种:ISO币种,仅支持人民币
payRecord.setCurrency(CommonConstants.CNY);
//记账处理方式:1:加急;2:普通;3:跨行快汇
payRecord.setPayType(CommonConstants.ONE_STRING);
//付款方账户名称"安徽皖信人力资源管理有限公司"
payRecord.setPayerCnname(detail.getFdBankName());
// "1302010109024596014"
payRecord.setPayerAccount(detail.getFdBankAccount());
//付款方账户英文名称:账号付款时,中文名称、英文名称至少输入一项
payRecord.setPayerEnname("");
//收款方账号:收方不支持NRA账号"6222620250010165293"
payRecord.setPayeeAccount(detail.getFdPayeeAccount());
//收款方账户名称"李连琴"
payRecord.setPayeeCnname(detail.getFdPayeeName());
//收款方账户英文名称
// payRecord.setPayeeEnname("");
//收款方系统内外标志:1:工行;2:他行 必填
payRecord.setIoFlag("2");
if (Common.isEmpty(detail.getFdRecipientBank())
|| detail.getFdRecipientBank().contains(CommonConstants.ICBC_NAME)) {
payRecord.setIoFlag(CommonConstants.ONE_STRING);
} else {
payRecord.setIoFlag(CommonConstants.TWO_STRING);
//收款方行号:跨行指令要求对方行行号和行名上送正确"301290000007"
payRecord.setPayeeBankNo(detail.getFdRecipientBankCode());
//收款方行名"交通银行股份有限公司"
payRecord.setPayeeBankName(detail.getFdRecipientBank());
}
//同城异地标志:1:同城;2:异地 非必填
payRecord.setSameCityFlag("");
payRecord.setAmount(Long.valueOf(detail.getFdMoney()));
if (Common.isNotNull(detail.getFdRemittancePurpose())) {
if (detail.getFdRemittancePurpose().length()>20) {
detail.setFdRemittancePurpose(detail.getFdRemittancePurpose().substring(0,20));
}
payRecord.setPurpose(detail.getFdRemittancePurpose());
} else {
payRecord.setPurpose("转账");
}
//摘要
//payRecord.setSummary("12");
return payRecord;
}
private String generateUniBusiId() {
return "UNI" + System.currentTimeMillis() + ThreadLocalRandom.current().nextInt(1000, 9999);
}
......
......@@ -156,8 +156,9 @@ public class TEmployeeInsurancePre extends BaseEntity {
@JsonIgnore
private LocalDateTime errorTime;
// TEmployeeInsurancePre.processStatus = "状态,0待确认,1待派单,2派单失败,3待投保,4投保中,5投保退回,6已完成,7待缴费"
@TableField(exist = false)
@Schema(description = "修改类型:1新增;2修改;3删除;4状态346为不可编辑")
@Schema(description = "修改类型:1新增;2修改;3删除;4状态3467为不可编辑")
private String modelType;
/**
* 是否拒绝入职: 0 是 1 否
......
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