cbs支付 代发

This commit is contained in:
xiang2lin 2024-06-26 17:02:32 +08:00
parent cd8dba9b1d
commit 3b772bf43b
5 changed files with 136 additions and 44 deletions

View File

@ -1,8 +1,10 @@
package com.hzya.frame.plugin.cbs8.plugin;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.hzya.frame.base.PluginBaseEntity;
import com.hzya.frame.cbs8.dto.req.AgentPayResultRequestDTO;
import com.hzya.frame.cbs8.dto.res.AgentPayQueryDTO;
import com.hzya.frame.cbs8.dto.res.AgentPayResultResDTO;
import com.hzya.frame.plugin.cbs8.service.ICbsPluginService;
import com.hzya.frame.web.entity.JsonResultEntity;
@ -11,6 +13,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
/**
* @Description
* @Author xiangerlin
@ -102,9 +106,8 @@ public class AgentPayResultPluginInitializer extends PluginBaseEntity {
//1查询代发代扣交易未完成代
//2调用cbs接口
AgentPayResultRequestDTO agentPayResultRequestDTO = new AgentPayResultRequestDTO();
agentPayResultRequestDTO.setBusNum("");
agentPayResultRequestDTO.setBusNum("PA00034224062600011");
AgentPayResultResDTO agentPayResultResDTO = cbsPluginService.agentPayResult(agentPayResultRequestDTO);
//更新OA表单
//记录日志
return null;
}

View File

@ -109,20 +109,8 @@ public class PayApplyAgentPluginInitializer extends PluginBaseEntity {
public JsonResultEntity executeBusiness(JSONObject requestJson) throws Exception {
//1查询代支付的
AgentPaymentEntity agentPaymentEntity = new AgentPaymentEntity();
List<AgentPaymentEntity> agentPaymentList = agentPaymentService.queryUnpaid(agentPaymentEntity);
if (CollectionUtils.isNotEmpty(agentPaymentList)){
for (AgentPaymentEntity paymentEntity : agentPaymentList) {
AgentPaymentDetailEntity detailEntity = new AgentPaymentDetailEntity();
detailEntity.setFormmainId(paymentEntity.getId());
List<AgentPaymentDetailEntity> agentPaymentDetailList = agentPaymentService.queryDetails(detailEntity);
if (CollectionUtils.isNotEmpty(agentPaymentDetailList)){
//调用代发代扣接口
PayResponseDTO payResponseDTO = cbsPluginService.applyAgentPay(paymentEntity, agentPaymentDetailList);
//更新OA表单
//记录日志
}
}
}
agentPaymentEntity.setOaId("4442823497745714629");
cbsPluginService.applyAgentPay(agentPaymentEntity);
return null;
}
}

View File

@ -105,7 +105,7 @@ public class PayApplyPluginInitializer extends PluginBaseEntity {
if (null == paymentEntity)
paymentEntity = new PaymentEntity();
//支付申请
paymentEntity.setOaId("5490849762671477371");
paymentEntity.setOaId("8475071606892874568");
cbsPluginService.applyPay(paymentEntity);
return null;
}

View File

@ -57,9 +57,8 @@ public interface ICbsPluginService {
/**
* 代发代扣 支付申请
* @param paymentEntity
* @param agentPaymentDetailList
*/
PayResponseDTO applyAgentPay(AgentPaymentEntity paymentEntity, List<AgentPaymentDetailEntity> agentPaymentDetailList);
void applyAgentPay(AgentPaymentEntity paymentEntity);
/**
* 代发代扣 结果详情查询

View File

@ -5,22 +5,23 @@ import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.map.MapBuilder;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.hzya.frame.cbs8.dto.req.*;
import com.hzya.frame.cbs8.dto.res.*;
import com.hzya.frame.cbs8.service.ICbs8Service;
import com.hzya.frame.cbs8.util.CBSUtil;
import com.hzya.frame.cbs8.util.CurrencyEnum;
import com.hzya.frame.cbs8.util.PayState;
import com.hzya.frame.plugin.cbs8.service.ICbsPluginService;
import com.hzya.frame.seeyon.cap4.form.dto.*;
import com.hzya.frame.seeyon.cbs8.entity.*;
import com.hzya.frame.seeyon.cbs8.service.ICbsLogService;
import com.hzya.frame.seeyon.cbs8.service.IPaymentService;
import com.hzya.frame.seeyon.cbs8.service.ITransactionDetailService;
import com.hzya.frame.seeyon.cbs8.service.*;
import com.hzya.frame.seeyon.entity.CtpAttachmentEntity;
import com.hzya.frame.seeyon.entity.CtpFileEntity;
import com.hzya.frame.seeyon.service.ICtpAttachmentService;
@ -38,6 +39,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @Description
@ -57,6 +59,10 @@ public class CbsPluginServiceImpl implements ICbsPluginService {
private ICtpAttachmentService ctpAttachmentService;
@Autowired
private ITransactionDetailService transactionDetailService;
@Autowired
private IAgentPaymentService agentPaymentService;
@Autowired
private IAgentPaymentDetailService agentPaymentDetailService;
@Autowired
private RestUtil restUtil;
@ -104,6 +110,7 @@ public class CbsPluginServiceImpl implements ICbsPluginService {
}
//4更新OA表单
pay.setDataSourceCode(oa_data_source_code);
pay.setApplyCode(payResponseDTO.getBusNum());
paymentService.updatePayState(pay);
//5记录操作日志
savePayLog(pay,payResponseDTO);
@ -174,6 +181,7 @@ public class CbsPluginServiceImpl implements ICbsPluginService {
//如果支付状态为空保存支付申请状态如果支付状态不为空则保存支付状态
PaymentEntity paymentEntity = new PaymentEntity();
paymentEntity.setOaId(entity.getOa_id());
paymentEntity.setApplyCode(entity.getCbs_apply_code());
paymentEntity.setDataSourceCode(oa_data_source_code);
List<PaymentEntity> paymentList = paymentService.query(paymentEntity);
if (CollectionUtils.isNotEmpty(paymentList)){
@ -300,22 +308,54 @@ public class CbsPluginServiceImpl implements ICbsPluginService {
* 代发代扣 支付申请
*
* @param paymentEntity
* @param agentPaymentDetailList
*/
@Override
public PayResponseDTO applyAgentPay(AgentPaymentEntity paymentEntity, List<AgentPaymentDetailEntity> agentPaymentDetailList) {
if (null != paymentEntity && CollectionUtils.isNotEmpty(agentPaymentDetailList)){
PaymentApplySubmitReqDTO paymentApplySubmitReqDTO = BeanUtil.copyProperties(paymentEntity,PaymentApplySubmitReqDTO.class);
public void applyAgentPay(AgentPaymentEntity paymentEntity) {
try {
if (null != paymentEntity ){
paymentEntity.setDataSourceCode(oa_data_source_code);
List<AgentPaymentEntity> agentPaymentList = agentPaymentService.queryUnpaid(paymentEntity);
if (CollectionUtils.isNotEmpty(agentPaymentList)){
for (AgentPaymentEntity agentPay : agentPaymentList) {
AgentPaymentDetailEntity detailEntity = new AgentPaymentDetailEntity();
detailEntity.setFormmainId(agentPay.getOaId());
detailEntity.setDataSourceCode(oa_data_source_code);
List<AgentPaymentDetailEntity> agentPaymentDetailList = agentPaymentService.queryDetails(detailEntity);
if (CollectionUtils.isNotEmpty(agentPaymentDetailList)){
PaymentApplySubmitReqDTO paymentApplySubmitReqDTO = BeanUtil.copyProperties(agentPay,PaymentApplySubmitReqDTO.class);
List<PaymentApplyAgentDTO> paymentApplyAgentList = new ArrayList<>();
for (AgentPaymentDetailEntity detailEntity : agentPaymentDetailList) {
PaymentApplyAgentDTO detailDTO = BeanUtil.copyProperties(detailEntity,PaymentApplyAgentDTO.class);
for (AgentPaymentDetailEntity detail : agentPaymentDetailList) {
PaymentApplyAgentDTO detailDTO = BeanUtil.copyProperties(detail,PaymentApplyAgentDTO.class);
paymentApplyAgentList.add(detailDTO);
}
//招行这里要传203
paymentApplySubmitReqDTO.setBankExtend5("203");
PayResponseDTO payResponseDTO = cbs8Service.agentPayApply(paymentApplySubmitReqDTO,paymentApplyAgentList);
return payResponseDTO;
if (null != payResponseDTO){
Boolean successed = payResponseDTO.getSuccessed();
AgentPaymentEntity pay = new AgentPaymentEntity();
pay.setOaId(paymentEntity.getOaId());
pay.setDataSourceCode(oa_data_source_code);
if (successed){
//更新申请单号到OA
pay.setApplyCode(payResponseDTO.getBusNum());
pay.setPayResult("审批中");
}else {
pay.setPayResult(payResponseDTO.getErrorMsg());
}
agentPaymentService.updateResult(pay);
System.out.println(JSONObject.toJSONString(payResponseDTO));
}
}
}
}
}else {
throw new BaseSystemException("参数不能为空");
}
}catch (Exception e){
logger.error("代发代扣出错:{}",e);
}
}
/**
@ -326,29 +366,91 @@ public class CbsPluginServiceImpl implements ICbsPluginService {
*/
@Override
public AgentPayResultResDTO agentPayResult(AgentPayResultRequestDTO agentPayResultRequestDTO) {
try {
if (null != agentPayResultRequestDTO && StrUtil.isNotEmpty(agentPayResultRequestDTO.getBusNum())){
AgentPayResultResDTO agentPayResultResDTO = cbs8Service.agentPayResult(agentPayResultRequestDTO);
//更新OA表单
String busNum = agentPayResultResDTO.getBusNum();
if (StringUtils.isNotEmpty(busNum)){
AgentPaymentEntity agentPaymentEntity = new AgentPaymentEntity();
agentPaymentEntity.setApplyCode(busNum);
agentPaymentEntity.setDataSourceCode(oa_data_source_code);
AgentPaymentEntity entity = agentPaymentService.queryByApplyCode(agentPaymentEntity);
String pay_status = agentPayResultResDTO.getPayStatus();
String status = agentPayResultResDTO.getStatus();
if (null != entity){
AgentPaymentEntity result = new AgentPaymentEntity();
result.setOaId(entity.getOaId());
result.setDataSourceCode(oa_data_source_code);
//更新主表
if (StrUtil.isEmpty(pay_status)) {
result.setPayResult(PayState.payStateGetValue(status));//支付申请状态 支付状态和支付申请状态用一个
} else {
result.setPayResult(PayState.payStateGetValue(pay_status));//支付状态 支付状态和支付申请状态用一个
}
agentPaymentService.updateResult(result);
//更新明细表
List<AgentPayQueryDTO> agentDetails = agentPayResultResDTO.getAgentDetails();
for (AgentPayQueryDTO d : agentDetails) {
AgentPaymentDetailEntity detail = new AgentPaymentDetailEntity();
detail.setFormmainId(entity.getOaId());
detail.setDtlAmount(d.getDtlAmount());
detail.setDtlCnapsCode(d.getDtlCnapsCode());
detail.setDtlRevName(d.getDtlRevName());
detail.setDtlSeqNum(Integer.valueOf(d.getDtlSeqNum()));
detail.setPayResult(PayState.payStateGetValue(d.getDtlStatus()));
detail.setPayDate(CBSUtil.convertTimestampToString(d.getDtlPayTime()));
detail.setDataSourceCode(oa_data_source_code);
agentPaymentDetailService.updatePayResult(detail);
}
}
}
return agentPayResultResDTO;
}
}catch (Exception e){
logger.error("代发代扣详情结果查询出错{}",e);
}
return null;
}
/**
* 保存交易明细到OA底表
*
* @param transactionDetailList
* @param transactionlList
*/
@Override
public void saveTransactionDetail(List<TransactionDetailDTO> transactionDetailList) {
if (CollectionUtils.isNotEmpty(transactionDetailList)){
public void saveTransactionDetail(List<TransactionDetailDTO> transactionlList) {
if (CollectionUtils.isNotEmpty(transactionlList)){
//过滤已经保存过的数据
for (TransactionDetailDTO dto : transactionDetailList) {
//收款档案表的数据
TransactionDetailEntity transactionDetailEntity = new TransactionDetailEntity();
transactionDetailEntity.setBankTransactionDate(DateUtil.lastWeek().toDateStr());
transactionDetailEntity.setDataSourceCode(oa_data_source_code);
List<TransactionDetailEntity> transactionDetailList = transactionDetailService.querySerialNumber(transactionDetailEntity);
//过滤已经保存的数据
if (CollectionUtils.isNotEmpty(transactionDetailList)){
//过滤transactionlList 去除已经存在transactionDetailList中的数据条件为transactionSerialNumber相等
if (CollectionUtils.isNotEmpty(transactionlList)){
transactionlList = transactionlList.stream()
.filter(item -> transactionDetailList.stream()
.noneMatch(detailItem -> item.getTransactionSerialNumber().equals(detailItem.getTransactionSerialNumber())))
.collect(Collectors.toList());
}
}
if (CollectionUtils.isNotEmpty(transactionlList)){
//保存到OA底表
for (TransactionDetailDTO dto : transactionlList) {
TransactionDetailEntity transactionDetail = new TransactionDetailEntity();
BeanUtil.copyProperties(dto,transactionDetail);
transactionDetail.setCurrency(CurrencyEnum.getChineseNameByCode(dto.getCurrency()));
if (NumberUtil.isNumber(dto.getBankTransactionDate())){//如果是时间戳 转换成日期字符串
transactionDetail.setBankTransactionDate(CBSUtil.convertTimestampToString(dto.getBankTransactionDate()));
}
transactionDetailService.restSave(transactionDetail);
}
}
}
}
//这个方法没用用的是8.0批量保存方式我没有测试
private void saveTransactionDetailTemp(List<TransactionDetailDTO> transactionDetailList) {