cbs8接口
This commit is contained in:
parent
5723dc440d
commit
c89370ac0c
|
@ -0,0 +1,115 @@
|
||||||
|
package com.hzya.frame.plugin.cbs8.plugin;
|
||||||
|
|
||||||
|
import cn.hutool.core.map.MapBuilder;
|
||||||
|
import cn.hutool.http.HttpRequest;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.hzya.frame.base.PluginBaseEntity;
|
||||||
|
import com.hzya.frame.cbs8.service.ICbs8Service;
|
||||||
|
import com.hzya.frame.plugin.cbs8.service.ICbsPluginService;
|
||||||
|
import com.hzya.frame.seeyon.cbs8.entity.CbsLogEntity;
|
||||||
|
import com.hzya.frame.seeyon.cbs8.entity.PaymentEntity;
|
||||||
|
import com.hzya.frame.seeyon.cbs8.service.ICbsLogService;
|
||||||
|
import com.hzya.frame.seeyon.cbs8.service.IPaymentService;
|
||||||
|
import com.hzya.frame.web.entity.JsonResultEntity;
|
||||||
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description 经办支付申请
|
||||||
|
* @Author xiangerlin
|
||||||
|
* @Date 2024/6/7 13:42
|
||||||
|
**/
|
||||||
|
public class PayApplyPluginInitializer extends PluginBaseEntity {
|
||||||
|
Logger logger = LoggerFactory.getLogger(PayApplyPluginInitializer.class);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ICbsPluginService cbsPluginService;
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 插件初始化方法
|
||||||
|
* @Author 👻👻👻👻👻👻👻👻 gjh
|
||||||
|
* @Date 2023-08-02 10:48
|
||||||
|
* @Param []
|
||||||
|
* @return void
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
public void initialize() {
|
||||||
|
logger.info(getPluginLabel() + "執行初始化方法initialize()");
|
||||||
|
}
|
||||||
|
|
||||||
|
/****
|
||||||
|
* 插件销毁方法
|
||||||
|
* @author 👻👻👻👻👻👻👻👻 gjh
|
||||||
|
* @date 2023-08-02 10:48
|
||||||
|
* @return void
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
public void destroy() {
|
||||||
|
logger.info(getPluginLabel() + "執行銷毀方法destroy()");
|
||||||
|
}
|
||||||
|
|
||||||
|
/****
|
||||||
|
* 插件的ID
|
||||||
|
* @author 👻👻👻👻👻👻👻👻 gjh
|
||||||
|
* @date 2023-08-02 10:48
|
||||||
|
* @return void
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
public String getPluginId() {
|
||||||
|
return "CBS8PayApplyPlugin";
|
||||||
|
}
|
||||||
|
|
||||||
|
/****
|
||||||
|
* 插件的名称
|
||||||
|
* @author 👻👻👻👻👻👻👻👻 gjh
|
||||||
|
* @date 2023-08-02 10:48
|
||||||
|
* @return void
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
public String getPluginName() {
|
||||||
|
return "cbs8支付申请插件";
|
||||||
|
}
|
||||||
|
|
||||||
|
/****
|
||||||
|
* 插件的显示值
|
||||||
|
* @author 👻👻👻👻👻👻👻👻 gjh
|
||||||
|
* @date 2023-08-02 10:48
|
||||||
|
* @return void
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
public String getPluginLabel() {
|
||||||
|
return "cbs8支付申请插件";
|
||||||
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 插件类型 1、场景插件
|
||||||
|
* @Author 👻👻👻👻👻👻👻👻 gjh
|
||||||
|
* @Date 2023-08-02 14:01
|
||||||
|
* @Param []
|
||||||
|
* @return java.lang.String
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
public String getPluginType() {
|
||||||
|
return "1";
|
||||||
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 执行业务代码
|
||||||
|
* @Author 👻👻👻👻👻👻👻👻 gjh
|
||||||
|
* @Date 2023-08-07 11:20
|
||||||
|
* @param requestJson 执行业务代码的参数
|
||||||
|
* @return void
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
public JsonResultEntity executeBusiness(JSONObject requestJson) throws Exception {
|
||||||
|
//支付申请
|
||||||
|
// cbsPluginService.applyPay(requestJson);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,101 @@
|
||||||
|
package com.hzya.frame.plugin.cbs8.plugin;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.hzya.frame.base.PluginBaseEntity;
|
||||||
|
import com.hzya.frame.plugin.cbs8.service.ICbsPluginService;
|
||||||
|
import com.hzya.frame.web.entity.JsonResultEntity;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description 查询支付结果
|
||||||
|
* @Author xiangerlin
|
||||||
|
* @Date 2024/6/14 16:24
|
||||||
|
**/
|
||||||
|
public class PayResultPluginInitializer extends PluginBaseEntity {
|
||||||
|
Logger logger = LoggerFactory.getLogger(PayResultPluginInitializer.class);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ICbsPluginService cbsPluginService;
|
||||||
|
/***
|
||||||
|
* 插件初始化方法
|
||||||
|
* @Author 👻👻👻👻👻👻👻👻 gjh
|
||||||
|
* @Date 2023-08-02 10:48
|
||||||
|
* @Param []
|
||||||
|
* @return void
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
public void initialize() {
|
||||||
|
logger.info(getPluginLabel() + "執行初始化方法initialize()");
|
||||||
|
}
|
||||||
|
|
||||||
|
/****
|
||||||
|
* 插件销毁方法
|
||||||
|
* @author 👻👻👻👻👻👻👻👻 gjh
|
||||||
|
* @date 2023-08-02 10:48
|
||||||
|
* @return void
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
public void destroy() {
|
||||||
|
logger.info(getPluginLabel() + "執行銷毀方法destroy()");
|
||||||
|
}
|
||||||
|
|
||||||
|
/****
|
||||||
|
* 插件的ID
|
||||||
|
* @author 👻👻👻👻👻👻👻👻 gjh
|
||||||
|
* @date 2023-08-02 10:48
|
||||||
|
* @return void
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
public String getPluginId() {
|
||||||
|
return "CBS8PayResultPlugin";
|
||||||
|
}
|
||||||
|
|
||||||
|
/****
|
||||||
|
* 插件的名称
|
||||||
|
* @author 👻👻👻👻👻👻👻👻 gjh
|
||||||
|
* @date 2023-08-02 10:48
|
||||||
|
* @return void
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
public String getPluginName() {
|
||||||
|
return "cbs8支付结果查询插件";
|
||||||
|
}
|
||||||
|
|
||||||
|
/****
|
||||||
|
* 插件的显示值
|
||||||
|
* @author 👻👻👻👻👻👻👻👻 gjh
|
||||||
|
* @date 2023-08-02 10:48
|
||||||
|
* @return void
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
public String getPluginLabel() {
|
||||||
|
return "cbs8支付结果查询插件";
|
||||||
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 插件类型 1、场景插件
|
||||||
|
* @Author 👻👻👻👻👻👻👻👻 gjh
|
||||||
|
* @Date 2023-08-02 14:01
|
||||||
|
* @Param []
|
||||||
|
* @return java.lang.String
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
public String getPluginType() {
|
||||||
|
return "1";
|
||||||
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 执行业务代码
|
||||||
|
* @Author 👻👻👻👻👻👻👻👻 gjh
|
||||||
|
* @Date 2023-08-07 11:20
|
||||||
|
* @param requestJson 执行业务代码的参数
|
||||||
|
* @return void
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
public JsonResultEntity executeBusiness(JSONObject requestJson) throws Exception {
|
||||||
|
cbsPluginService.queryResult(requestJson);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.hzya.frame.plugin.cbs8.service;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description
|
||||||
|
* @Author xiangerlin
|
||||||
|
* @Date 2024/6/17 08:46
|
||||||
|
**/
|
||||||
|
public interface ICbsPluginService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付申请
|
||||||
|
* @param requestJson
|
||||||
|
*/
|
||||||
|
void applyPay(JSONObject requestJson)throws Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询支付申请的交易结果
|
||||||
|
* @param requestJson
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
void queryResult(JSONObject requestJson)throws Exception;
|
||||||
|
}
|
|
@ -0,0 +1,134 @@
|
||||||
|
package com.hzya.frame.plugin.cbs8.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.hzya.frame.cbs8.dto.req.PayResultRequestDTO;
|
||||||
|
import com.hzya.frame.cbs8.dto.res.PayResponseDTO;
|
||||||
|
import com.hzya.frame.cbs8.dto.res.PayResultResDTO;
|
||||||
|
import com.hzya.frame.cbs8.service.ICbs8Service;
|
||||||
|
import com.hzya.frame.cbs8.util.CBSUtil;
|
||||||
|
import com.hzya.frame.cbs8.util.PayState;
|
||||||
|
import com.hzya.frame.plugin.cbs8.plugin.PayApplyPluginInitializer;
|
||||||
|
import com.hzya.frame.plugin.cbs8.service.ICbsPluginService;
|
||||||
|
import com.hzya.frame.seeyon.cbs8.entity.CbsLogEntity;
|
||||||
|
import com.hzya.frame.seeyon.cbs8.entity.PaymentEntity;
|
||||||
|
import com.hzya.frame.seeyon.cbs8.service.ICbsLogService;
|
||||||
|
import com.hzya.frame.seeyon.cbs8.service.IPaymentService;
|
||||||
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description
|
||||||
|
* @Author xiangerlin
|
||||||
|
* @Date 2024/6/17 08:46
|
||||||
|
**/
|
||||||
|
public class CbsPluginServiceImpl implements ICbsPluginService {
|
||||||
|
|
||||||
|
Logger logger = LoggerFactory.getLogger(CbsPluginServiceImpl.class);
|
||||||
|
@Autowired
|
||||||
|
private ICbs8Service cbs8Service;
|
||||||
|
@Autowired
|
||||||
|
private IPaymentService paymentService;
|
||||||
|
@Autowired
|
||||||
|
private ICbsLogService cbsLogService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付申请
|
||||||
|
*
|
||||||
|
* @param requestJson
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void applyPay(JSONObject requestJson) throws Exception{
|
||||||
|
//查询待支付的列表
|
||||||
|
PaymentEntity paymentEntity = new PaymentEntity();
|
||||||
|
paymentEntity.setDataSourceCode("");
|
||||||
|
//List<PaymentEntity> paymentList = paymentService.queryUnpaid(paymentEntity);
|
||||||
|
List<PaymentEntity> paymentList = new ArrayList<>();
|
||||||
|
paymentEntity.setReferenceNum("CL202406140001");
|
||||||
|
paymentEntity.setPayAccount("655905707410000");
|
||||||
|
paymentEntity.setPayBankName("");
|
||||||
|
paymentEntity.setAmount("99");
|
||||||
|
paymentEntity.setRevAccount("123456778");
|
||||||
|
paymentEntity.setRevBankName("中国工商银行总行清算中心");
|
||||||
|
paymentEntity.setRevBankType("ICB");
|
||||||
|
paymentEntity.setRevAccountName("测试账户");
|
||||||
|
paymentEntity.setCnapsCode("102100099996");
|
||||||
|
paymentEntity.setPurpose("测试用途");
|
||||||
|
paymentEntity.setBusType("202");
|
||||||
|
paymentEntity.setCurrency("10");
|
||||||
|
paymentEntity.setPurpose("测试用途");
|
||||||
|
paymentList.add(paymentEntity);
|
||||||
|
if (CollectionUtils.isNotEmpty(paymentList)){
|
||||||
|
for (PaymentEntity pay : paymentList) {
|
||||||
|
//调用支付申请接口
|
||||||
|
PayResponseDTO payResponseDTO = cbs8Service.payApply(pay);
|
||||||
|
//4、更新OA表单
|
||||||
|
paymentService.updatePayState(pay);
|
||||||
|
//5、记录操作日志
|
||||||
|
cbsLogService.saveLog(new CbsLogEntity());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询支付申请的交易结果
|
||||||
|
*
|
||||||
|
* @param requestJson
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void queryResult(JSONObject requestJson) throws Exception {
|
||||||
|
CbsLogEntity cbsLogEntity = new CbsLogEntity();
|
||||||
|
// 1、查询支付中的日志
|
||||||
|
List<CbsLogEntity> inPayList = cbsLogService.queryInPayment(cbsLogEntity);
|
||||||
|
if (CollectionUtils.isNotEmpty(inPayList)){
|
||||||
|
for (CbsLogEntity entity : inPayList) {
|
||||||
|
try {
|
||||||
|
List<PayResultResDTO> payResultResList = cbs8Service.queryPayResult(new PayResultRequestDTO(entity.getBill_code()));
|
||||||
|
if (CollectionUtils.isNotEmpty(payResultResList)){
|
||||||
|
PayResultResDTO payResultResDTO = payResultResList.get(0);
|
||||||
|
//支付申请状态
|
||||||
|
String status = payResultResDTO.getStatus();
|
||||||
|
//支付状态
|
||||||
|
String pay_status = payResultResDTO.getPayStatus();
|
||||||
|
//不等于支付中的时候 更新支付状态
|
||||||
|
if (!PayState.p.getType().equals(pay_status)){
|
||||||
|
//如果支付状态为空,保存支付申请状态,如果支付状态不为空,则保存支付状态
|
||||||
|
PaymentEntity paymentEntity = new PaymentEntity();
|
||||||
|
paymentEntity.setOaId(entity.getOa_id());
|
||||||
|
List<PaymentEntity> paymentList = paymentService.query(paymentEntity);
|
||||||
|
if (CollectionUtils.isNotEmpty(paymentList)){
|
||||||
|
paymentEntity = paymentList.get(0);
|
||||||
|
if (StrUtil.isEmpty(pay_status)) {
|
||||||
|
//支付申请状态 支付状态和支付申请状态用一个
|
||||||
|
paymentEntity.setPayResult(PayState.payStateGetValue(status));
|
||||||
|
} else {
|
||||||
|
//支付状态 支付状态和支付申请状态用一个
|
||||||
|
paymentEntity.setPayResult(PayState.payStateGetValue(pay_status));
|
||||||
|
}
|
||||||
|
if (StrUtil.isNotEmpty(pay_status) && pay_status.equals(PayState.g.getType())) {
|
||||||
|
//支付时间
|
||||||
|
paymentEntity.setPayDate(CBSUtil.convertTimestampToString(payResultResDTO.getPayDate()));
|
||||||
|
}
|
||||||
|
//更新视图单据状态
|
||||||
|
paymentService.updatePayState(paymentEntity);
|
||||||
|
//更新日志表状态
|
||||||
|
entity.setPay_state(paymentEntity.getPayResult());
|
||||||
|
entity.setApply_state(PayState.payStateGetValue(status));
|
||||||
|
cbsLogService.update(entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
logger.error("查询交易结果出错",e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue