Merge branches 'dev' and 'yuecheng-project' of http://192.168.2.237:3000/root/kangarooDataCenterV3 into yuecheng-project

This commit is contained in:
yuqh 2024-06-17 14:17:18 +08:00
commit 71c69c4c9c
36 changed files with 3223 additions and 0 deletions

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}

View File

@ -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);
}
}
}
}
}

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin>
<id>CBS8PayApplyPlugin</id>
<name>cbs8插件</name>
<category>202406070001</category>
</plugin>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans default-autowire="byName">
<bean name="payApplyPluginInitializer" class="com.hzya.frame.plugin.cbs8.plugin.PayApplyPluginInitializer" />
<bean name="payResultPluginInitializer" class="com.hzya.frame.plugin.cbs8.plugin.PayResultPluginInitializer" />
</beans>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans default-autowire="byName">
<bean name="cbsPluginService" class="com.hzya.frame.plugin.cbs8.service.impl.CbsPluginServiceImpl" />
</beans>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin>
<id>MdmProjectPlugin</id>
<name>MdmProjectPlugin插件</name>
<category>90000001</category>
</plugin>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans default-autowire="byName">
<bean name="mdmProjectDao" class="com.hzya.frame.plugin.masterData.project.dao.impl.MdmProjectDaoImpl" />
</beans>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans default-autowire="byName">
<bean name="mdmProjectInitializer" class="com.hzya.frame.plugin.masterData.project.plugin.MdmProjectPluginInitializer" />
</beans>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans default-autowire="byName">
<bean name="mdmProjectService" class="com.hzya.frame.plugin.masterData.project.service.impl.MdmProjectServiceImpl" />
</beans>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin>
<id>MdmOrgPlugin</id>
<name>MdmOrgPlugin插件</name>
<category>90000001</category>
</plugin>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans default-autowire="byName">
<bean name="mdmOrgDao" class="com.hzya.frame.plugin.masterData.org.dao.impl.MdmOrgDaoImpl" />
</beans>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans default-autowire="byName">
<bean name="mdmOrgInitializer" class="com.hzya.frame.plugin.masterData.org.plugin.MdmOrgPluginInitializer" />
</beans>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans default-autowire="byName">
<bean name="mdmOrgService" class="com.hzya.frame.plugin.masterData.org.service.impl.MdmOrgServiceImpl" />
</beans>

View File

@ -0,0 +1,272 @@
package com.hzya.frame.cbs8.dto.req;
/**
* @Description 经办支付请求DTO
* @Author xiangerlin
* @Date 2024/1/3 09:02
**/
public class PayRequestDTO {
private String referenceNum;//业务参考号必填
private String busType;//业务类型 必填
private String amount;//金额 必填
private String currency;//币种编码必填
private String payAccount;//付款账号非集中支付模式必填
private String revAccount;//收款账号 必填
private String revAccountName;//收款方户名 必填
private String revBankType;//收款银行类型编码必填
private String revBankName;//收款开户行名称
private String cnapsCode;//联行号 必填
private String purpose;//支付用途 必填
private String innerAccount;//内部账号
private String revBankArea;//收款银行地区名称
private String revProvince;//收款人省
private String revCity;//收款人市
private String bankNum;//收款地区码银行号
private String summary;//该笔支付备注
private String expectTime;//期望支付时间
private String personalFlag;//公私标记 1对私 0对公
private String urgentTag;//加急1加急0不加2特急
private String realTimeTag;//是否实时 1实时0落地
private String cityFlag;//同城标志 0同城1异地
private String payChannel;//支付渠道
private String busiStep;//业务步数 集中支付需要传1其他不用传
private String applyUnitCode;//申请人单位号集中支付必传
private String displayApplyUnitCode;//申请人单位号前端显示集中支付如果传了会将其转化为applyUnitCode
private String erpExtend1;//客户备用字段1
private String erpExtend2;//客户备用字段2
private String erpExtend3;//客户备用字段3
public String getReferenceNum() {
return referenceNum;
}
public void setReferenceNum(String referenceNum) {
this.referenceNum = referenceNum;
}
public String getBusType() {
return busType;
}
public void setBusType(String busType) {
this.busType = busType;
}
public String getAmount() {
return amount;
}
public void setAmount(String amount) {
this.amount = amount;
}
public String getCurrency() {
return currency;
}
public void setCurrency(String currency) {
this.currency = currency;
}
public String getPayAccount() {
return payAccount;
}
public void setPayAccount(String payAccount) {
this.payAccount = payAccount;
}
public String getRevAccount() {
return revAccount;
}
public void setRevAccount(String revAccount) {
this.revAccount = revAccount;
}
public String getRevAccountName() {
return revAccountName;
}
public void setRevAccountName(String revAccountName) {
this.revAccountName = revAccountName;
}
public String getRevBankType() {
return revBankType;
}
public void setRevBankType(String revBankType) {
this.revBankType = revBankType;
}
public String getRevBankName() {
return revBankName;
}
public void setRevBankName(String revBankName) {
this.revBankName = revBankName;
}
public String getCnapsCode() {
return cnapsCode;
}
public void setCnapsCode(String cnapsCode) {
this.cnapsCode = cnapsCode;
}
public String getPurpose() {
return purpose;
}
public void setPurpose(String purpose) {
this.purpose = purpose;
}
public String getInnerAccount() {
return innerAccount;
}
public void setInnerAccount(String innerAccount) {
this.innerAccount = innerAccount;
}
public String getRevBankArea() {
return revBankArea;
}
public void setRevBankArea(String revBankArea) {
this.revBankArea = revBankArea;
}
public String getRevProvince() {
return revProvince;
}
public void setRevProvince(String revProvince) {
this.revProvince = revProvince;
}
public String getRevCity() {
return revCity;
}
public void setRevCity(String revCity) {
this.revCity = revCity;
}
public String getBankNum() {
return bankNum;
}
public void setBankNum(String bankNum) {
this.bankNum = bankNum;
}
public String getSummary() {
return summary;
}
public void setSummary(String summary) {
this.summary = summary;
}
public String getExpectTime() {
return expectTime;
}
public void setExpectTime(String expectTime) {
this.expectTime = expectTime;
}
public String getPersonalFlag() {
return personalFlag;
}
public void setPersonalFlag(String personalFlag) {
this.personalFlag = personalFlag;
}
public String getUrgentTag() {
return urgentTag;
}
public void setUrgentTag(String urgentTag) {
this.urgentTag = urgentTag;
}
public String getRealTimeTag() {
return realTimeTag;
}
public void setRealTimeTag(String realTimeTag) {
this.realTimeTag = realTimeTag;
}
public String getCityFlag() {
return cityFlag;
}
public void setCityFlag(String cityFlag) {
this.cityFlag = cityFlag;
}
public String getPayChannel() {
return payChannel;
}
public void setPayChannel(String payChannel) {
this.payChannel = payChannel;
}
public String getBusiStep() {
return busiStep;
}
public void setBusiStep(String busiStep) {
this.busiStep = busiStep;
}
public String getApplyUnitCode() {
return applyUnitCode;
}
public void setApplyUnitCode(String applyUnitCode) {
this.applyUnitCode = applyUnitCode;
}
public String getDisplayApplyUnitCode() {
return displayApplyUnitCode;
}
public void setDisplayApplyUnitCode(String displayApplyUnitCode) {
this.displayApplyUnitCode = displayApplyUnitCode;
}
public String getErpExtend1() {
return erpExtend1;
}
public void setErpExtend1(String erpExtend1) {
this.erpExtend1 = erpExtend1;
}
public String getErpExtend2() {
return erpExtend2;
}
public void setErpExtend2(String erpExtend2) {
this.erpExtend2 = erpExtend2;
}
public String getErpExtend3() {
return erpExtend3;
}
public void setErpExtend3(String erpExtend3) {
this.erpExtend3 = erpExtend3;
}
}

View File

@ -0,0 +1,44 @@
package com.hzya.frame.cbs8.dto.req;
import java.util.List;
/**
* @Description 查询交易结果请求参数
* @Author xiangerlin
* @Date 2024/1/3 09:46
**/
public class PayResultRequestDTO {
public PayResultRequestDTO() {
}
public PayResultRequestDTO(String referenceNum) {
this.referenceNum = referenceNum;
}
private String referenceNum;//业务参考号必填
private List<String> statusList;//状态
private List<String> payStatusList;//支付状态
public String getReferenceNum() {
return referenceNum;
}
public void setReferenceNum(String referenceNum) {
this.referenceNum = referenceNum;
}
public List<String> getStatusList() {
return statusList;
}
public void setStatusList(List<String> statusList) {
this.statusList = statusList;
}
public List<String> getPayStatusList() {
return payStatusList;
}
public void setPayStatusList(List<String> payStatusList) {
this.payStatusList = payStatusList;
}
}

View File

@ -0,0 +1,44 @@
package com.hzya.frame.cbs8.dto.res;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
import java.util.List;
/**
* @Description cbs响应DTO
* @Author xiangerlin
* @Date 2024/1/2 09:25
**/
public class CbsResponseDTO {
//private List<CbsResDataDTO> data;//数据
private List<JSONObject> data;//数据
private String code;//0表示成功
private String msg;//消息
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public List<JSONObject> getData() {
return data;
}
public void setData(List<JSONObject> data) {
this.data = data;
}
}

View File

@ -0,0 +1,73 @@
package com.hzya.frame.cbs8.dto.res;
/**
* @Description 经办支付接口返回参数中的data节点
* @Author xiangerlin
* @Date 2024/1/3 14:35
**/
public class PayResponseDTO {
private String busNum;//申请单编号
private String errorCode;//错误编码
private String errorMsg;//错误信息
private String freezeFlowNum;//内部户冻结流水号
private String recordNum;//批量经办序号
private String referenceNum;//业务参考号
private Boolean successed;//是否成功
public String getBusNum() {
return busNum;
}
public void setBusNum(String busNum) {
this.busNum = busNum;
}
public String getErrorCode() {
return errorCode;
}
public void setErrorCode(String errorCode) {
this.errorCode = errorCode;
}
public String getErrorMsg() {
return errorMsg;
}
public void setErrorMsg(String errorMsg) {
this.errorMsg = errorMsg;
}
public String getFreezeFlowNum() {
return freezeFlowNum;
}
public void setFreezeFlowNum(String freezeFlowNum) {
this.freezeFlowNum = freezeFlowNum;
}
public String getRecordNum() {
return recordNum;
}
public void setRecordNum(String recordNum) {
this.recordNum = recordNum;
}
public String getReferenceNum() {
return referenceNum;
}
public void setReferenceNum(String referenceNum) {
this.referenceNum = referenceNum;
}
public Boolean getSuccessed() {
return successed;
}
public void setSuccessed(Boolean successed) {
this.successed = successed;
}
}

View File

@ -0,0 +1,890 @@
package com.hzya.frame.cbs8.dto.res;
/**
* @Description 交易结果查询data节点响应的参数
* @Author xiangerlin
* @Date 2024/1/3 15:45
**/
public class PayResultResDTO {
private String payDate;//支付日期
private String accountFlag;
private String agentDetails;
private String amount;
private String bankExtend1;
private String bankExtend10;
private String bankExtend11;
private String bankExtend2;
private String bankExtend3;
private String bankExtend4;
private String bankExtend5;
private String bankExtend6;
private String bankExtend7;
private String bankExtend8;
private String bankExtend9;
private String bankInterfaceType;
private String bankNum;
private String bankVersion;
private String batchNum;
private String busNum;
private String busType;
private String checkCodeList;
private String cityFlag;
private String cnapsCode;
private String createBy;
private String createByName;
private String createTime;
private String currency;
private String dealPeopleList;
private String detailNum;
private String erpExtend1;
private String erpExtend2;
private String erpExtend3;
private String errorMsg;
private String expectTime;
private String extend1;
private String extend2;
private String extend3;
private String extend4;
private String extend5;
private String freezeFlowNum;
private String freezeStatus;
private String id;
private String innerAccount;
private String innerAccountName;
private String inputType;
private String isDeleted;
private String isSaveRev;
private String lastPrintTime;
private String lastPrintUser;
private String operaterOrgCode;
private String operaterOrgCodeList;
private String operaterOrgName;
private String payAccount;
private String payAccountName;
private String payAccountSeq;
private String payBankName;
private String payBankType;
private String payChannel;
private String payOrgCode;
private String payOrgName;
private String payStatus;// 支付状态
private String paymentApplyUnionDTO;
private String personalFlag;
private String printTimes;
private String procInstId;
private String procStatus;
private String projectCode;
private String purpose;
private String realName;
private String realRevAccount;
private String realTimeTag;
private String referenceNum;
private String revAccount;
private String revAccountName;
private String revAccountSeq;
private String revBankArea;
private String revBankName;
private String revBankType;
private String revCity;
private String revProvince;
private String status;//支付申请状态
private String summary;
private String unitCode;
private String unitName;
private String updateBy;
private String updateTime;
private String urgentTag;
public String getAccountFlag() {
return accountFlag;
}
public void setAccountFlag(String accountFlag) {
this.accountFlag = accountFlag;
}
public String getAgentDetails() {
return agentDetails;
}
public void setAgentDetails(String agentDetails) {
this.agentDetails = agentDetails;
}
public String getAmount() {
return amount;
}
public void setAmount(String amount) {
this.amount = amount;
}
public String getBankExtend1() {
return bankExtend1;
}
public void setBankExtend1(String bankExtend1) {
this.bankExtend1 = bankExtend1;
}
public String getBankExtend10() {
return bankExtend10;
}
public void setBankExtend10(String bankExtend10) {
this.bankExtend10 = bankExtend10;
}
public String getBankExtend11() {
return bankExtend11;
}
public void setBankExtend11(String bankExtend11) {
this.bankExtend11 = bankExtend11;
}
public String getBankExtend2() {
return bankExtend2;
}
public void setBankExtend2(String bankExtend2) {
this.bankExtend2 = bankExtend2;
}
public String getBankExtend3() {
return bankExtend3;
}
public void setBankExtend3(String bankExtend3) {
this.bankExtend3 = bankExtend3;
}
public String getBankExtend4() {
return bankExtend4;
}
public void setBankExtend4(String bankExtend4) {
this.bankExtend4 = bankExtend4;
}
public String getBankExtend5() {
return bankExtend5;
}
public void setBankExtend5(String bankExtend5) {
this.bankExtend5 = bankExtend5;
}
public String getBankExtend6() {
return bankExtend6;
}
public void setBankExtend6(String bankExtend6) {
this.bankExtend6 = bankExtend6;
}
public String getBankExtend7() {
return bankExtend7;
}
public void setBankExtend7(String bankExtend7) {
this.bankExtend7 = bankExtend7;
}
public String getBankExtend8() {
return bankExtend8;
}
public void setBankExtend8(String bankExtend8) {
this.bankExtend8 = bankExtend8;
}
public String getBankExtend9() {
return bankExtend9;
}
public void setBankExtend9(String bankExtend9) {
this.bankExtend9 = bankExtend9;
}
public String getBankInterfaceType() {
return bankInterfaceType;
}
public void setBankInterfaceType(String bankInterfaceType) {
this.bankInterfaceType = bankInterfaceType;
}
public String getBankNum() {
return bankNum;
}
public void setBankNum(String bankNum) {
this.bankNum = bankNum;
}
public String getBankVersion() {
return bankVersion;
}
public void setBankVersion(String bankVersion) {
this.bankVersion = bankVersion;
}
public String getBatchNum() {
return batchNum;
}
public void setBatchNum(String batchNum) {
this.batchNum = batchNum;
}
public String getBusNum() {
return busNum;
}
public void setBusNum(String busNum) {
this.busNum = busNum;
}
public String getBusType() {
return busType;
}
public void setBusType(String busType) {
this.busType = busType;
}
public String getCheckCodeList() {
return checkCodeList;
}
public void setCheckCodeList(String checkCodeList) {
this.checkCodeList = checkCodeList;
}
public String getCityFlag() {
return cityFlag;
}
public void setCityFlag(String cityFlag) {
this.cityFlag = cityFlag;
}
public String getCnapsCode() {
return cnapsCode;
}
public void setCnapsCode(String cnapsCode) {
this.cnapsCode = cnapsCode;
}
public String getCreateBy() {
return createBy;
}
public void setCreateBy(String createBy) {
this.createBy = createBy;
}
public String getCreateByName() {
return createByName;
}
public void setCreateByName(String createByName) {
this.createByName = createByName;
}
public String getCreateTime() {
return createTime;
}
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
public String getCurrency() {
return currency;
}
public void setCurrency(String currency) {
this.currency = currency;
}
public String getDealPeopleList() {
return dealPeopleList;
}
public void setDealPeopleList(String dealPeopleList) {
this.dealPeopleList = dealPeopleList;
}
public String getDetailNum() {
return detailNum;
}
public void setDetailNum(String detailNum) {
this.detailNum = detailNum;
}
public String getErpExtend1() {
return erpExtend1;
}
public void setErpExtend1(String erpExtend1) {
this.erpExtend1 = erpExtend1;
}
public String getErpExtend2() {
return erpExtend2;
}
public void setErpExtend2(String erpExtend2) {
this.erpExtend2 = erpExtend2;
}
public String getErpExtend3() {
return erpExtend3;
}
public void setErpExtend3(String erpExtend3) {
this.erpExtend3 = erpExtend3;
}
public String getErrorMsg() {
return errorMsg;
}
public void setErrorMsg(String errorMsg) {
this.errorMsg = errorMsg;
}
public String getExpectTime() {
return expectTime;
}
public void setExpectTime(String expectTime) {
this.expectTime = expectTime;
}
public String getExtend1() {
return extend1;
}
public void setExtend1(String extend1) {
this.extend1 = extend1;
}
public String getExtend2() {
return extend2;
}
public void setExtend2(String extend2) {
this.extend2 = extend2;
}
public String getExtend3() {
return extend3;
}
public void setExtend3(String extend3) {
this.extend3 = extend3;
}
public String getExtend4() {
return extend4;
}
public void setExtend4(String extend4) {
this.extend4 = extend4;
}
public String getExtend5() {
return extend5;
}
public void setExtend5(String extend5) {
this.extend5 = extend5;
}
public String getFreezeFlowNum() {
return freezeFlowNum;
}
public void setFreezeFlowNum(String freezeFlowNum) {
this.freezeFlowNum = freezeFlowNum;
}
public String getFreezeStatus() {
return freezeStatus;
}
public void setFreezeStatus(String freezeStatus) {
this.freezeStatus = freezeStatus;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getInnerAccount() {
return innerAccount;
}
public void setInnerAccount(String innerAccount) {
this.innerAccount = innerAccount;
}
public String getInnerAccountName() {
return innerAccountName;
}
public void setInnerAccountName(String innerAccountName) {
this.innerAccountName = innerAccountName;
}
public String getInputType() {
return inputType;
}
public void setInputType(String inputType) {
this.inputType = inputType;
}
public String getIsDeleted() {
return isDeleted;
}
public void setIsDeleted(String isDeleted) {
this.isDeleted = isDeleted;
}
public String getIsSaveRev() {
return isSaveRev;
}
public void setIsSaveRev(String isSaveRev) {
this.isSaveRev = isSaveRev;
}
public String getLastPrintTime() {
return lastPrintTime;
}
public void setLastPrintTime(String lastPrintTime) {
this.lastPrintTime = lastPrintTime;
}
public String getLastPrintUser() {
return lastPrintUser;
}
public void setLastPrintUser(String lastPrintUser) {
this.lastPrintUser = lastPrintUser;
}
public String getOperaterOrgCode() {
return operaterOrgCode;
}
public void setOperaterOrgCode(String operaterOrgCode) {
this.operaterOrgCode = operaterOrgCode;
}
public String getOperaterOrgCodeList() {
return operaterOrgCodeList;
}
public void setOperaterOrgCodeList(String operaterOrgCodeList) {
this.operaterOrgCodeList = operaterOrgCodeList;
}
public String getOperaterOrgName() {
return operaterOrgName;
}
public void setOperaterOrgName(String operaterOrgName) {
this.operaterOrgName = operaterOrgName;
}
public String getPayAccount() {
return payAccount;
}
public void setPayAccount(String payAccount) {
this.payAccount = payAccount;
}
public String getPayAccountName() {
return payAccountName;
}
public void setPayAccountName(String payAccountName) {
this.payAccountName = payAccountName;
}
public String getPayAccountSeq() {
return payAccountSeq;
}
public void setPayAccountSeq(String payAccountSeq) {
this.payAccountSeq = payAccountSeq;
}
public String getPayBankName() {
return payBankName;
}
public void setPayBankName(String payBankName) {
this.payBankName = payBankName;
}
public String getPayBankType() {
return payBankType;
}
public void setPayBankType(String payBankType) {
this.payBankType = payBankType;
}
public String getPayChannel() {
return payChannel;
}
public void setPayChannel(String payChannel) {
this.payChannel = payChannel;
}
public String getPayOrgCode() {
return payOrgCode;
}
public void setPayOrgCode(String payOrgCode) {
this.payOrgCode = payOrgCode;
}
public String getPayOrgName() {
return payOrgName;
}
public void setPayOrgName(String payOrgName) {
this.payOrgName = payOrgName;
}
public String getPayStatus() {
return payStatus;
}
public void setPayStatus(String payStatus) {
this.payStatus = payStatus;
}
public String getPaymentApplyUnionDTO() {
return paymentApplyUnionDTO;
}
public void setPaymentApplyUnionDTO(String paymentApplyUnionDTO) {
this.paymentApplyUnionDTO = paymentApplyUnionDTO;
}
public String getPersonalFlag() {
return personalFlag;
}
public void setPersonalFlag(String personalFlag) {
this.personalFlag = personalFlag;
}
public String getPrintTimes() {
return printTimes;
}
public void setPrintTimes(String printTimes) {
this.printTimes = printTimes;
}
public String getProcInstId() {
return procInstId;
}
public void setProcInstId(String procInstId) {
this.procInstId = procInstId;
}
public String getProcStatus() {
return procStatus;
}
public void setProcStatus(String procStatus) {
this.procStatus = procStatus;
}
public String getProjectCode() {
return projectCode;
}
public void setProjectCode(String projectCode) {
this.projectCode = projectCode;
}
public String getPurpose() {
return purpose;
}
public void setPurpose(String purpose) {
this.purpose = purpose;
}
public String getRealName() {
return realName;
}
public void setRealName(String realName) {
this.realName = realName;
}
public String getRealRevAccount() {
return realRevAccount;
}
public void setRealRevAccount(String realRevAccount) {
this.realRevAccount = realRevAccount;
}
public String getRealTimeTag() {
return realTimeTag;
}
public void setRealTimeTag(String realTimeTag) {
this.realTimeTag = realTimeTag;
}
public String getReferenceNum() {
return referenceNum;
}
public void setReferenceNum(String referenceNum) {
this.referenceNum = referenceNum;
}
public String getRevAccount() {
return revAccount;
}
public void setRevAccount(String revAccount) {
this.revAccount = revAccount;
}
public String getRevAccountName() {
return revAccountName;
}
public void setRevAccountName(String revAccountName) {
this.revAccountName = revAccountName;
}
public String getRevAccountSeq() {
return revAccountSeq;
}
public void setRevAccountSeq(String revAccountSeq) {
this.revAccountSeq = revAccountSeq;
}
public String getRevBankArea() {
return revBankArea;
}
public void setRevBankArea(String revBankArea) {
this.revBankArea = revBankArea;
}
public String getRevBankName() {
return revBankName;
}
public void setRevBankName(String revBankName) {
this.revBankName = revBankName;
}
public String getRevBankType() {
return revBankType;
}
public void setRevBankType(String revBankType) {
this.revBankType = revBankType;
}
public String getRevCity() {
return revCity;
}
public void setRevCity(String revCity) {
this.revCity = revCity;
}
public String getRevProvince() {
return revProvince;
}
public void setRevProvince(String revProvince) {
this.revProvince = revProvince;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getSummary() {
return summary;
}
public void setSummary(String summary) {
this.summary = summary;
}
public String getUnitCode() {
return unitCode;
}
public void setUnitCode(String unitCode) {
this.unitCode = unitCode;
}
public String getUnitName() {
return unitName;
}
public void setUnitName(String unitName) {
this.unitName = unitName;
}
public String getUpdateBy() {
return updateBy;
}
public void setUpdateBy(String updateBy) {
this.updateBy = updateBy;
}
public String getUpdateTime() {
return updateTime;
}
public void setUpdateTime(String updateTime) {
this.updateTime = updateTime;
}
public String getUrgentTag() {
return urgentTag;
}
public void setUrgentTag(String urgentTag) {
this.urgentTag = urgentTag;
}
public String getPayDate() {
return payDate;
}
public void setPayDate(String payDate) {
this.payDate = payDate;
}
}

View File

@ -0,0 +1,46 @@
package com.hzya.frame.cbs8.service;
import com.hzya.frame.sysnew.application.entity.SysExtensionApiEntity;
/**
* @Description
* @Author xiangerlin
* @Date 2024/6/7 14:20
**/
public interface ICbs8ExtService {
/**
* 支付经办
* @param entity
* @return
*/
SysExtensionApiEntity payApply(SysExtensionApiEntity entity);
/**
* 交易结果查询
* @param entity
* @return
*/
SysExtensionApiEntity payResult(SysExtensionApiEntity entity);
/**
* 代发代扣
* @param entity
* @return
*/
String payApplyAgent(SysExtensionApiEntity entity);
/**
* 代发代扣结果查询
* @param entity
* @return
*/
String payApplyAgentResult(SysExtensionApiEntity entity);
/**
* 电子回单查询
* @param entity
* @return
*/
String elecQuery(SysExtensionApiEntity entity);
}

View File

@ -0,0 +1,31 @@
package com.hzya.frame.cbs8.service;
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.seeyon.cbs8.entity.PaymentEntity;
import java.util.List;
/**
* @Description cbs8接口
* @Author xiangerlin
* @Date 2024/6/6 15:30
**/
public interface ICbs8Service {
/**
* 支付申请
* @param paymentEntity
*/
PayResponseDTO payApply(PaymentEntity paymentEntity);
/**
* 通过业务参考号查询交易结果 3.2.6
* @param resultRequestDTO
* @return
* @throws Exception
*/
List<PayResultResDTO> queryPayResult(PayResultRequestDTO resultRequestDTO);
}

View File

@ -0,0 +1,154 @@
package com.hzya.frame.cbs8.service.impl;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.cbs8.dto.req.PayRequestDTO;
import com.hzya.frame.cbs8.dto.req.PayResultRequestDTO;
import com.hzya.frame.cbs8.service.ICbs8ExtService;
import com.hzya.frame.cbs8.util.CBSUtil;
import com.hzya.frame.cbs8.util.CbsAccessToken;
import com.hzya.frame.cbs8.util.SM2Util;
import com.hzya.frame.seeyon.cbs8.entity.PaymentEntity;
import com.hzya.frame.stringutil.StringUtil;
import com.hzya.frame.sysnew.application.entity.SysExtensionApiEntity;
import com.hzya.frame.web.exception.BaseSystemException;
import org.apache.http.protocol.HTTP;
import org.springframework.stereotype.Service;
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;
/**
* @Description
* @Author xiangerlin
* @Date 2024/6/7 14:20
**/
@Service(value = "cbs8Ext")
public class Cbs8ExtServiceImpl implements ICbs8ExtService {
/**
* 支付经办
*
* @param entity
* @return
*/
@Override
public SysExtensionApiEntity payApply(SysExtensionApiEntity entity) {
String bodys = entity.getBodys();
if (StrUtil.isNotEmpty(bodys)){
PaymentEntity paymentEntity = JSONObject.parseObject(bodys,PaymentEntity.class);
if (null != paymentEntity){
PayRequestDTO payRequestDTO = new PayRequestDTO();
String ferenceNum = Convert.toStr(paymentEntity.getReferenceNumNew(),paymentEntity.getReferenceNum());
payRequestDTO.setReferenceNum(ferenceNum);
payRequestDTO.setBusType(paymentEntity.getBusType());
payRequestDTO.setAmount(paymentEntity.getAmount());
payRequestDTO.setCurrency(paymentEntity.getCurrency());
payRequestDTO.setPayAccount(StringUtil.replaceBlank(paymentEntity.getPayAccount()));
payRequestDTO.setRevAccount(StringUtil.replaceBlank(paymentEntity.getRevAccount()));
payRequestDTO.setRevAccountName(StringUtil.replaceBlank(paymentEntity.getRevAccountName()));
payRequestDTO.setRevBankType(StringUtil.replaceBlank((paymentEntity.getRevBankType())));
payRequestDTO.setRevBankName(StringUtil.replaceBlank(paymentEntity.getRevBankName()));
payRequestDTO.setCnapsCode(StringUtil.replaceBlank((paymentEntity.getCnapsCode())));
payRequestDTO.setPurpose(paymentEntity.getPurpose());
payRequestDTO.setErpExtend1(paymentEntity.getPayType());
//集中支付模式
if (CBSUtil.CENTRALIZED_PAYMENT_TYPE.equals(payRequestDTO.getBusType())){
payRequestDTO.setBusiStep("1");
payRequestDTO.setApplyUnitCode(paymentEntity.getPayCompanyCode());
payRequestDTO.setPayAccount(null);
}
String requestData = JSONObject.toJSONString(payRequestDTO);
//签名
long timestamp = System.currentTimeMillis();
String sign = CBSUtil.sign(requestData,timestamp);
//加密
byte[] encryptedData = CBSUtil.encrypt(requestData);
Map<String,String> header = new HashMap();
header.put(CBSUtil.SIGN_HEADER_NAME,sign);
header.put(CBSUtil.TIMESTAMP_HEADER,Long.toString(timestamp));
header.put(HTTP.CONTENT_TYPE,CBSUtil.TARGET_CONTENT_TYPE);
header.put(CBSUtil.AUTHORIZATION,CBSUtil.BEARER+ CbsAccessToken.getToken());
entity.setBodys(Base64.getEncoder().encodeToString(encryptedData));
entity.setHeaders(header);
String body = HttpRequest.post("https://cbs8-openapi-reprd.csuat.cmburl.cn/openapi/payment/openapi/v1/payment-apply-common").addHeaders(header).body(encryptedData).execute().body();
System.out.println(body);
}
}
return entity;
}
/**
* 交易结果查询
*
* @param entity
* @return
*/
@Override
public SysExtensionApiEntity payResult(SysExtensionApiEntity entity) {
String bodys = entity.getBodys();
if (StrUtil.isNotEmpty(bodys)){
PayResultRequestDTO payResultRequest = JSONObject.parseObject(bodys,PayResultRequestDTO.class);
if (null != payResultRequest && StrUtil.isNotEmpty(payResultRequest.getReferenceNum())){
String requestData = JSONObject.toJSONString(payResultRequest);
//签名
long timestamp = System.currentTimeMillis();
String sign = CBSUtil.sign(requestData,timestamp);
//加密
byte[] encryptedData = CBSUtil.encrypt(requestData);
Map<String,String> header = new HashMap();
header.put(CBSUtil.SIGN_HEADER_NAME,sign);
header.put(CBSUtil.TIMESTAMP_HEADER,Long.toString(timestamp));
header.put(HTTP.CONTENT_TYPE,CBSUtil.TARGET_CONTENT_TYPE);
header.put(CBSUtil.AUTHORIZATION,CBSUtil.BEARER+ CbsAccessToken.getToken());
entity.setBodys(Base64.getEncoder().encodeToString(encryptedData));
entity.setHeaders(header);
byte[] bodyBytes = HttpRequest.post("https://cbs8-openapi-reprd.csuat.cmburl.cn/openapi/payment/openapi/v2/detail").addHeaders(header).body(encryptedData).execute().bodyBytes();
//解密报文
String decrypt = CBSUtil.decrypt(bodyBytes);
System.out.println(decrypt);
}else {
throw new BaseSystemException("业务参考号不能为空!!!!");
}
}
return entity;
}
/**
* 代发代扣
*
* @param entity
* @return
*/
@Override
public String payApplyAgent(SysExtensionApiEntity entity) {
return null;
}
/**
* 代发代扣结果查询
*
* @param entity
* @return
*/
@Override
public String payApplyAgentResult(SysExtensionApiEntity entity) {
return null;
}
/**
* 电子回单查询
*
* @param entity
* @return
*/
@Override
public String elecQuery(SysExtensionApiEntity entity) {
return null;
}
}

View File

@ -0,0 +1,69 @@
package com.hzya.frame.cbs8.service.impl;
import cn.hutool.core.map.MapBuilder;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.cbs8.dto.req.PayResultRequestDTO;
import com.hzya.frame.cbs8.dto.res.CbsResponseDTO;
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.seeyon.cbs8.entity.PaymentEntity;
import com.hzya.frame.seeyon.cbs8.service.IPaymentService;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
* @Description cbs8接口
* @Author xiangerlin
* @Date 2024/6/7 14:44
**/
@Service
public class Cbs8ServiceImpl implements ICbs8Service {
@Autowired
private IPaymentService paymentService;
@Override
public PayResponseDTO payApply(PaymentEntity paymentEntity) {
Map<String, String> headerMap = MapBuilder.<String, String>create(true)
.put("apiCode", "8000260001")
.put("publicKey","ZJYA1vBeY1ai53iNmbAEsw6DImjkXGBkdMailxcBdliFC85Ce7eDIk+3zDUT+v578prj")
.put("secretKey","7Gp6OjHrIaQ6R3tXGPrI4morjQyWL+qu4JJschQnkBRtv26VDgGFVYKOy5kMZfd/j3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=")
.put("appId","800026")
.build();
String body = HttpRequest.post("http://127.0.0.1:9999/kangarooDataCenterV3/entranceController/externalCallInterface").addHeaders(headerMap).body(JSONObject.toJSONString(paymentEntity)).timeout(60000).execute().body();
PayResponseDTO payResponseDTO = JSONObject.parseObject(body,PayResponseDTO.class);
return payResponseDTO;
}
/**
* 通过业务参考号查询交易结果 3.2.6
*
* @param resultRequestDTO
* @return
* @throws Exception
*/
@Override
public List<PayResultResDTO> queryPayResult(PayResultRequestDTO resultRequestDTO) {
Map<String, String> headerMap = MapBuilder.<String, String>create(true)
.put("apiCode", "8000260002")
.put("publicKey","ZJYA1vBeY1ai53iNmbAEsw6DImjkXGBkdMailxcBdliFC85Ce7eDIk+3zDUT+v578prj")
.put("secretKey","7Gp6OjHrIaQ6R3tXGPrI4morjQyWL+qu4JJschQnkBRtv26VDgGFVYKOy5kMZfd/j3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=")
.put("appId","800026")
.build();
String body = HttpRequest.post("http://127.0.0.1:9999/kangarooDataCenterV3/entranceController/externalCallInterface").addHeaders(headerMap).body(JSONObject.toJSONString(resultRequestDTO)).timeout(60000).execute().body();
if (StrUtil.isEmpty(body)){
CbsResponseDTO cbsResponseDTO = JSONObject.parseObject(body, CbsResponseDTO.class);
if (CollectionUtils.isNotEmpty(cbsResponseDTO.getData())){
List<JSONObject> dataList = cbsResponseDTO.getData();
List<PayResultResDTO> payResultList = CBSUtil.convertJsonArrayToList(dataList, PayResultResDTO.class);
return payResultList;
}
}
return null;
}
}

View File

@ -0,0 +1,187 @@
package com.hzya.frame.cbs8.util;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import org.apache.commons.codec.binary.Base64;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
/**
* @Description
* @Author xiangerlin
* @Date 2024/6/7 15:38
**/
@Component
public class CBSUtil {
/**
* 集中支付模式
*/
public static final String CENTRALIZED_PAYMENT_TYPE = "401";
/**
* 分页查询 最大条数
*/
public static final int MAX_PAGE_SIZE = 1000;
/**
* 默认分页查询条数
*/
public static final int DEFAULT_PAGE_SIZE = 100;
/**
* 默认页码
*/
public static final int DEFAULT_CURRENT_PAGE = 1;
static Logger logger = LogManager.getLogger(CBSUtil.class);
/**
* 请求参数格式
*/
public static String TARGET_CONTENT_TYPE = "application/json";
/**
* 签名请求头参数名
*/
public static String SIGN_HEADER_NAME = "X-MBCLOUD-API-SIGN";
/**
* 时间戳请求头参数名
*/
public static String TIMESTAMP_HEADER = "X-MBCLOUD-TIMESTAMP";
public static String ENCRYPTION_ENABLED_HEADER_NAME = "X-MBCLOUD-ENCRYPTION-ENABLED";
public static String X_MBCLOUD_COMPRESS = "X-Mbcloud-Compress";
/**
* 请求头token参数名
*/
public static String AUTHORIZATION = "Authorization";
/**
*token前缀
*/
public static String BEARER = "Bearer ";
/**
* 财资管理云公钥(平台公钥)
*/
public static String bodyEncryptionKey;
/**
* 企业私钥加密
*/
public static String signEncryptionPrivateKey;
/**
* 企业私钥解密
*/
public static String bodyDecryptionKey;
/**
* 财资管理云公钥(平台公钥)
*/
@Value("${cbs8.cbs_public_key}")
public void setBodyEncryptionKey(String bodyEncryptionKey) {
CBSUtil.bodyEncryptionKey = bodyEncryptionKey;
}
/**
* 企业私钥解密
*/
@Value("${cbs8.ya_private_key}")
public void setSignEncryptionPrivateKey(String signEncryptionPrivateKey) {
CBSUtil.signEncryptionPrivateKey = signEncryptionPrivateKey;
}
/**
* 企业私钥解密
*/
@Value("${cbs8.ya_private_key}")
public void setBodyDecryptionKey(String bodyDecryptionKey) {
CBSUtil.bodyDecryptionKey = bodyDecryptionKey;
}
//将json数组转为list
public static <T> List<T> convertJsonArrayToList(List<JSONObject> list, Class<T> clazz) {
String jsonArray = JSON.toJSONString(list);
List<T> result = JSON.parseObject(jsonArray, new TypeReference<List<T>>(clazz) {});
return result;
}
/**
* 将时间戳转换成日期字符串
* @param timestamp
* @return
*/
public static String convertTimestampToString(String timestamp) {
if (StrUtil.isNotEmpty(timestamp) && NumberUtil.isNumber(timestamp)){
// 创建SimpleDateFormat对象指定日期时间格式
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// 将时间戳转换为Date对象
Date date = new Date(Long.valueOf(timestamp));
// 使用SimpleDateFormat格式化Date对象得到字符串表示
return sdf.format(date);
}
return null;
}
/**
* 签名
* @param requestData
* @return
*/
public static String sign(String requestData){
long timestamp = System.currentTimeMillis();
return sign(requestData,timestamp);
}
/**
* 签名
* @param requestData
* @param timestamp
* @return
*/
public static String sign(String requestData,long timestamp){
// 请求数据拼接 报文体+时间戳
byte[] requestDataBytes = requestData.getBytes(StandardCharsets.UTF_8);
byte[] timestampBytes = ("&timestamp=" + timestamp).getBytes(StandardCharsets.UTF_8);
byte[] newBytes = new byte[requestDataBytes.length + timestampBytes.length];
System.arraycopy(requestDataBytes, 0, newBytes, 0, requestDataBytes.length);
System.arraycopy(timestampBytes, 0, newBytes, requestDataBytes.length, timestampBytes.length);
// 生成签名
byte[] signature = SM2Util.sign(signEncryptionPrivateKey, newBytes);
String sign = Base64.encodeBase64String(SM2Util.encodeDERSignature(signature));
logger.info("签名:{}", sign);
return sign;
}
/**
* 加密
* @param requestData
* @return
*/
public static byte[] encrypt(String requestData){
byte[] encrypt = SM2Util.encrypt(bodyEncryptionKey, requestData.getBytes(StandardCharsets.UTF_8));
return encrypt;
}
public static String decrypt(byte[] cipherData){
try {
byte[] decrypt = SM2Util.decrypt(bodyDecryptionKey, cipherData);
String text = new String(decrypt);
return text;
}catch (Exception e){
logger.error("解密失败",e);
e.printStackTrace();
}
return null;
}
}

View File

@ -0,0 +1,140 @@
package com.hzya.frame.cbs8.util;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.web.action.ApplicationContextUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.relational.core.sql.In;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;
/**
* @Description cbs token
* @Author xiangerlin
* @Date 2024/6/7 15:56
**/
@Component
public class CbsAccessToken {
private static final Logger logger = LoggerFactory.getLogger(CbsAccessToken.class);
@Value("${cbs8.appId}")
private String app_id;
@Value("${cbs8.appSecret}")
private String app_secret;
@Value("${cbs8.url}")
private String app_url;
private static String appId;
private static String appSecret;
private static String url;
@PostConstruct
public void init() {
appId = app_id;
appSecret = app_secret;
url = app_url;
}
//刷新token用
private static final String BEARER = "Bearer ";
/**
* 过期时间
*/
private Long expiryTime ;
private String token;
private CbsAccessToken(){
}
private static CbsAccessToken cbsAccessToken = new CbsAccessToken();
public static CbsAccessToken getInstance() {
if (null == cbsAccessToken.token){
initToken();
}else {
//判断token有没有过期
if (System.currentTimeMillis() >= cbsAccessToken.expiryTime){
initToken();
}else {
refreshToken();
}
}
return cbsAccessToken;
}
public static String getToken(){
return getInstance().token;
}
/**
* 获取token
*/
private static void initToken(){
CbsAccessToken ct = (CbsAccessToken) ApplicationContextUtil.getBeanByName("cbsAccessToken");
logger.info("开始获取cbstoken");
Map<String,String> param = new HashMap<>();
param.put("app_id",ct.appId);
param.put("app_secret",ct.appSecret);
param.put("grant_type","client_credentials");
String res = HttpRequest.post(ct.url+"/openapi/app/v1/app/token").body(JSONObject.toJSONString(param)).execute().body();
logger.info("获取cbstoken结果",res);
if (StrUtil.isNotEmpty(res) && JSONUtil.isTypeJSON(res)){
JSONObject tokenObject = JSONObject.parseObject(res);
String code = tokenObject.getString("code");//0表示成功
if ("0".equals(code)){
JSONObject dataObj = tokenObject.getJSONObject("data");
if (null != dataObj){
String token = dataObj.getString("token");
//过期时间 单位是秒 30分钟有效
Integer expires = dataObj.getInteger("expires");
cbsAccessToken.token = token;
//提前5分钟让token失效 所以这里设置成过期时间为当前时间+25分钟
cbsAccessToken.expiryTime = System.currentTimeMillis()+1000*60*25L;
}
}
}
}
/**
* 刷新token
*/
private static void refreshToken(){
CbsAccessToken ct = (CbsAccessToken) ApplicationContextUtil.getBeanByName("cbsAccessToken");
//token不为空并且没过期 刷新token
if (null != cbsAccessToken.token && System.currentTimeMillis() < cbsAccessToken.expiryTime ){
String res = HttpRequest.get(ct.url + "/openapi/app/v1/app/refresh-token").header("Authorization", BEARER + cbsAccessToken.token).execute().body();
logger.info("刷新cbstoken结果",res);
if (StrUtil.isNotEmpty(res) && JSONUtil.isTypeJSON(res)){
JSONObject tokenObject = JSONObject.parseObject(res);
String code = tokenObject.getString("code");//0表示成功
if ("0".equals(code)){
JSONObject dataObj = tokenObject.getJSONObject("data");
if (null != dataObj){
//续期的token
String token = dataObj.getString("token");
//新token过期时间 单位是秒 30分钟有效
Integer expires = dataObj.getInteger("expires");
cbsAccessToken.token = token;
//提前5分钟让token失效 所以这里设置成过期时间为当前时间+25分钟
cbsAccessToken.expiryTime = System.currentTimeMillis()+1000*60*25L;
}
}else {
initToken();
}
}
}else {
initToken();
}
}
public static void main(String[] args) {
System.out.println("第1次取token"+getToken());
System.out.println("第2次取token"+getToken());
System.out.println("第3次取token"+getToken());
}
}

View File

@ -0,0 +1,71 @@
package com.hzya.frame.cbs8.util;
/**
* @Author:hecan
* @Description:支付类型(支付状态)
* @params:
* @return:
* @Date: 2023/3/14 15:05
*/
public enum PayState {
a("a","待提交直联"),
b("b","已提交直联"),
c("c","银行已受理"),
d("d","银行未受理"),
e("e","可疑"),
f("f","待人工确认"),
g("g","支付成功"),
h("h","支付失败"),
i("i","部分成功"),
j("j","退票"),
k("k","取消支付"),
n("n","其他"),
p("p","支付中"),
q("q","待支付"),
one("1","待处理"),
two("2","审批中"),
three("3","处理失败"),
four("4","审批通过"),
five("5","审批撤销"),
six("6","审批拒绝"),
seven("7","待发送审批"),
eight("8","集中受理中"),
nine("9","审批退回"),
ten("10","未处理");
//类型
private String type;
//
private String value;
PayState(String type, String value){
this.type=type;
this.value=value;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public static String payStateGetValue(String type){
for (PayState payState : PayState.values()){
if(payState.getType()==type||payState.getType().equals(type)){
return payState.getValue().toString();
}
}
return null;
}
}

View File

@ -0,0 +1,231 @@
package com.hzya.frame.cbs8.util;
import org.bouncycastle.asn1.*;
import org.bouncycastle.crypto.engines.SM2Engine;
import org.bouncycastle.crypto.params.*;
import org.bouncycastle.crypto.signers.SM2Signer;
import org.bouncycastle.jce.ECNamedCurveTable;
import org.bouncycastle.jce.spec.ECParameterSpec;
import org.bouncycastle.math.ec.ECCurve;
import org.bouncycastle.math.ec.ECPoint;
import org.bouncycastle.util.encoders.Hex;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.ByteArrayInputStream;
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import java.security.SecureRandom;
import java.util.Base64;
import java.util.Enumeration;
/**
* @author: xiang2lin
* @time: 2024/6/14
* @description: SM2加解密工具类
*/
public class SM2Util {
static Logger logger = LoggerFactory.getLogger(SM2Util.class);
private SM2Util() {
throw new IllegalStateException("Utility class");
}
private static final String STD_NAME = "sm2p256v1";
/**
* SM2加密算法
*
* @param publicKey 公钥
* @param data 明文数据
* @return
*/
public static byte[] encrypt(String publicKey, byte[] data) {
ECPublicKeyParameters ecPublicKeyParameters = encodePublicKey(Hex.decode(publicKey));
SM2Engine engine = new SM2Engine();
engine.init(true, new ParametersWithRandom(ecPublicKeyParameters, new SecureRandom()));
byte[] bytes = null;
try {
byte[] cipherText = engine.processBlock(data, 0, data.length);
bytes = C1C2C3ToC1C3C2(cipherText);
} catch (Exception e) {
logger.warn("SM2加密时出现异常:" + e.getMessage());
}
return bytes;
}
/**
* SM2解密算法
*
* @param privateKey 私钥
* @param cipherData 密文数据
* @return
*/
public static byte[] decrypt(String privateKey, byte[] cipherData) {
ECPrivateKeyParameters ecPrivateKeyParameters = encodePrivateKey(Hex.decode(privateKey));
SM2Engine engine = new SM2Engine();
engine.init(false, ecPrivateKeyParameters);
byte[] bytes = null;
try {
cipherData = C1C3C2ToC1C2C3(cipherData);
bytes = engine.processBlock(cipherData, 0, cipherData.length);
} catch (Exception e) {
logger.warn("SM2解密时出现异常:" + e.getMessage());
}
return bytes;
}
/**
* 签名算法
*
* @param privateKey 私钥
* @param data 明文数据
* @return
*/
public static byte[] sign(String privateKey, byte[] data) {
ECPrivateKeyParameters ecPrivateKeyParameters = encodePrivateKey(hexToByte(privateKey));
SM2Signer signer = new SM2Signer();
ParametersWithID parameters = new ParametersWithID(ecPrivateKeyParameters, "1234567812345678".getBytes());
signer.init(true, parameters);
signer.update(data, 0, data.length);
byte[] signature = null;
try {
signature = decodeDERSignature(signer.generateSignature());
} catch (Exception e) {
logger.warn("SM2签名时出现异常:" + e.getMessage());
}
return signature;
}
private static byte[] hexToByte(String hex)
throws IllegalArgumentException {
if (hex.length() % 2 != 0) {
throw new IllegalArgumentException();
}
char[] arr = hex.toCharArray();
byte[] b = new byte[hex.length() / 2];
for (int i = 0, j = 0, l = hex.length(); i < l; i++, j++) {
String swap = "" + arr[i++] + arr[i];
int byteInt = Integer.parseInt(swap, 16) & 0xFF;
b[j] = BigInteger.valueOf(byteInt).byteValue();
}
return b;
}
private static byte[] C1C2C3ToC1C3C2(byte[] cipherText) throws Exception {
if (cipherText != null && cipherText.length >= 97) {
byte[] bytes = new byte[cipherText.length];
System.arraycopy(cipherText, 0, bytes, 0, 65);
System.arraycopy(cipherText, cipherText.length - 32, bytes, 65, 32);
System.arraycopy(cipherText, 65, bytes, 97, cipherText.length - 97);
return bytes;
} else {
throw new Exception("SM2 cipher text error, must be more than 96 bytes and in the format C1||C3||C2.");
}
}
private static byte[] C1C3C2ToC1C2C3(byte[] cipherText) throws Exception {
if (cipherText != null && cipherText.length >= 97) {
byte[] bytes = new byte[cipherText.length];
System.arraycopy(cipherText, 0, bytes, 0, 65);
System.arraycopy(cipherText, 97, bytes, 65, cipherText.length - 97);
System.arraycopy(cipherText, 65, bytes, cipherText.length - 32, 32);
return bytes;
} else {
throw new Exception("SM2 cipher text error, must be more than 96 bytes and in the format C1||C3||C2.");
}
}
private static ECPublicKeyParameters encodePublicKey(byte[] value) {
byte[] x = new byte[32];
byte[] y = new byte[32];
System.arraycopy(value, 1, x, 0, 32);
System.arraycopy(value, 33, y, 0, 32);
BigInteger X = new BigInteger(1, x);
BigInteger Y = new BigInteger(1, y);
ECPoint Q = getSM2Curve().createPoint(X, Y);
return new ECPublicKeyParameters(Q, getECDomainParameters());
}
private static ECCurve getSM2Curve() {
ECParameterSpec spec = ECNamedCurveTable.getParameterSpec(STD_NAME);
return spec.getCurve();
}
private static ECPrivateKeyParameters encodePrivateKey(byte[] value) {
BigInteger d = new BigInteger(1, value);
return new ECPrivateKeyParameters(d, getECDomainParameters());
}
private static ECDomainParameters getECDomainParameters() {
ECParameterSpec spec = ECNamedCurveTable.getParameterSpec(STD_NAME);
return new ECDomainParameters(spec.getCurve(), spec.getG(), spec.getN(), spec.getH(), spec.getSeed());
}
private static byte[] decodeDERSignature(byte[] signature) {
ASN1InputStream stream = new ASN1InputStream(new ByteArrayInputStream(signature));
byte[] bytes = new byte[64];
try {
ASN1Sequence primitive = (ASN1Sequence) stream.readObject();
Enumeration enumeration = primitive.getObjects();
BigInteger R = ((ASN1Integer) enumeration.nextElement()).getValue();
BigInteger S = ((ASN1Integer) enumeration.nextElement()).getValue();
byte[] r = format(R.toByteArray());
byte[] s = format(S.toByteArray());
System.arraycopy(r, 0, bytes, 0, 32);
System.arraycopy(s, 0, bytes, 32, 32);
} catch (Exception e) {
logger.warn("decodeDERSignature时出现异常:" + e.getMessage());
}
return bytes;
}
public static byte[] encodeDERSignature(byte[] signature) {
byte[] r = new byte[32];
byte[] s = new byte[32];
System.arraycopy(signature, 0, r, 0, 32);
System.arraycopy(signature, 32, s, 0, 32);
ASN1EncodableVector vector = new ASN1EncodableVector();
vector.add(new ASN1Integer(new BigInteger(1, r)));
vector.add(new ASN1Integer(new BigInteger(1, s)));
byte[] encoded = null;
try {
encoded = (new DERSequence(vector)).getEncoded();
} catch (Exception e) {
logger.warn("encodeDERSignature时出现异常:" + e.getMessage());
}
return encoded;
}
private static byte[] format(byte[] value) {
if (value.length == 32) {
return value;
} else {
byte[] bytes = new byte[32];
if (value.length > 32) {
System.arraycopy(value, value.length - 32, bytes, 0, 32);
} else {
System.arraycopy(value, 0, bytes, 32 - value.length, value.length);
}
return bytes;
}
}
public static void main(String[] args) {
String requestData = "hello啊";
byte[] encrypt = encrypt("0452d60e72f6a3050d2f8e8f4505f874ef345e15da38fda8dd64b9e756b7231c056dff1674c4826ada424cc78ea36fd58afc50bcefb5d721bf25b179efac2ebb17", requestData.getBytes(StandardCharsets.UTF_8));
String temp = new String(encrypt);
byte[] decrypt = decrypt("c3509b6df8bdaf84c464daa1b6fa11a8fca77b0e4a6f076ee68487f288278a85", encrypt);
System.out.println("解密完成"+new String(decrypt));
String encodeToString = Base64.getEncoder().encodeToString(encrypt);
byte[] decode = Base64.getDecoder().decode(encodeToString);
byte[] decrypt1 = decrypt("c3509b6df8bdaf84c464daa1b6fa11a8fca77b0e4a6f076ee68487f288278a85", decode);
System.out.println("解密完成1"+new String(decrypt1));
}
}

View File

@ -0,0 +1,12 @@
package com.hzya.frame.seeyon.cbs8.dao;
import com.hzya.frame.basedao.dao.IBaseDao;
import com.hzya.frame.seeyon.cbs8.entity.CbsLogEntity;
/**
* @Description cbs8支付日志
* @Author xiangerlin
* @Date 2024/6/14 17:30
**/
public interface ICbsLogDao extends IBaseDao<CbsLogEntity,String> {
}

View File

@ -0,0 +1,15 @@
package com.hzya.frame.seeyon.cbs8.dao.impl;
import com.hzya.frame.basedao.dao.MybatisGenericDao;
import com.hzya.frame.seeyon.cbs8.dao.ICbsLogDao;
import com.hzya.frame.seeyon.cbs8.entity.CbsLogEntity;
import org.springframework.stereotype.Repository;
/**
* @Description
* @Author xiangerlin
* @Date 2024/6/14 17:31
**/
@Repository()
public class CbsLogDaoImpl extends MybatisGenericDao<CbsLogEntity,String> implements ICbsLogDao {
}

View File

@ -0,0 +1,151 @@
package com.hzya.frame.seeyon.cbs8.entity;
import com.hzya.frame.web.entity.BaseEntity;
/**
* @Description cbs支付日志
* @Author xiangerlin
* @Date 2024/6/14 17:16
**/
public class CbsLogEntity extends BaseEntity {
//流程标题
private String title;
//请款主体
private String pay_company;
//收款人
private String payee;
//金额
private String amount;
//cbs申请单号
private String cbs_apply_code;
//日志表id
private String id;
//oa单据id
private String oa_id;
//oa单据号
private String bill_code;
//英文表名
private String tab_name_en;
//中文表名
private String tab_name_ch;
//支付状态
private String pay_state;
//支付信息
private String message;
//支付申请状态
private String apply_state;
//成功标记
private String successed;
public String getOa_id() {
return oa_id;
}
public void setOa_id(String oa_id) {
this.oa_id = oa_id;
}
public String getBill_code() {
return bill_code;
}
public void setBill_code(String bill_code) {
this.bill_code = bill_code;
}
public String getTab_name_en() {
return tab_name_en;
}
public void setTab_name_en(String tab_name_en) {
this.tab_name_en = tab_name_en;
}
public String getTab_name_ch() {
return tab_name_ch;
}
public void setTab_name_ch(String tab_name_ch) {
this.tab_name_ch = tab_name_ch;
}
public String getPay_state() {
return pay_state;
}
public void setPay_state(String pay_state) {
this.pay_state = pay_state;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getApply_state() {
return apply_state;
}
public void setApply_state(String apply_state) {
this.apply_state = apply_state;
}
public String getSuccessed() {
return successed;
}
public void setSuccessed(String successed) {
this.successed = successed;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getPay_company() {
return pay_company;
}
public void setPay_company(String pay_company) {
this.pay_company = pay_company;
}
public String getPayee() {
return payee;
}
public void setPayee(String payee) {
this.payee = payee;
}
public String getAmount() {
return amount;
}
public void setAmount(String amount) {
this.amount = amount;
}
public String getCbs_apply_code() {
return cbs_apply_code;
}
public void setCbs_apply_code(String cbs_apply_code) {
this.cbs_apply_code = cbs_apply_code;
}
}

View File

@ -0,0 +1,115 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hzya.frame.seeyon.cbs8.entity.CbsLogEntity">
<resultMap id="get-CbsLogEntity-result" type="com.hzya.frame.seeyon.cbs8.entity.CbsLogEntity">
<result property="id" column="id" />
<result property="oa_id" column="oa_id" />
<result property="bill_code" column="bill_code" />
<result property="tab_name_en" column="tab_name_en" />
<result property="tab_name_ch" column="tab_name_ch" />
<result property="pay_state" column="pay_state" />
<result property="message" column="message" />
<result property="apply_state" column="apply_state" />
<result property="successed" column="successed" />
<result property="title" column="title" />
<result property="pay_company" column="pay_company" />
<result property="payee" column="payee" />
<result property="amount" column="amount" />
<result property="cbs_apply_code" column="cbs_apply_code" />
</resultMap>
<sql id="CbsLogEntity_Base_Column_List">
id,
field0001 as oa_id,
field0002 as bill_code,
field0003 as tab_name_en,
field0004 as tab_name_ch,
field0005 as pay_state,
field0006 as message,
field0007 as apply_state,
field0008 as successed,
field0009 as title,
field0010 as pay_company,
field0011 as payee,
field0012 as amount,
field0013 as cbs_apply_code
</sql>
<!-- 查询推送失败,用户手动发起请求 采用==查询 -->
<select id="CbsLogEntity_list_base" resultMap="get-CbsLogEntity-result" parameterType="com.hzya.frame.seeyon.cbs8.entity.CbsLogEntity">
select
<include refid="CbsLogEntity_Base_Column_List"/>
from
formmain_1283
<trim prefix="where" prefixOverrides="and">
<if test="oa_id != null and oa_id !='' "> field0001 = #{oa_id} </if>
<if test="id != null and id !='' "> and id = #{id} </if>
<if test="bill_code != null and bill_code !='' "> and field0002 = #{bill_code} </if>
<if test="tab_name_en != null and tab_name_en !='' "> and field0003 = #{tab_name_en} </if>
<if test="tab_name_ch != null and tab_name_ch !='' "> and field0004 = #{tab_name_ch} </if>
<if test="pay_state != null and pay_state !='' "> and field0005 = #{pay_state} </if>
<if test="message != null and message !='' "> and field0006 = #{message} </if>
<if test="apply_state != null and apply_state !='' "> and field0007 = #{apply_state} </if>
<if test="successed != null and successed !='' "> and field0008 = #{successed} </if>
</trim>
</select>
<select id="CbsLogEntity_list_like" resultMap="get-CbsLogEntity-result" parameterType="com.hzya.frame.seeyon.cbs8.entity.CbsLogEntity">
select
<include refid="CbsLogEntity_Base_Column_List"/>
from
formmain_1283
<trim prefix="where" prefixOverrides="and">
<if test="oa_id != null and oa_id !='' "> field0001 = #{oa_id} </if>
<if test="id != null and id !='' "> and id = #{id} </if>
<if test="bill_code != null and bill_code !='' "> and field0002 like '${bill_code}%' </if>
<if test="tab_name_en != null and tab_name_en !='' "> and field0003 like '${tab_name_en}%' </if>
<if test="tab_name_ch != null and tab_name_ch !='' "> and field0004 like '${tab_name_ch}%' </if>
<if test="pay_state != null and pay_state !='' "> and field0005 like '${pay_state}%' </if>
<if test="message != null and message !='' "> and field0006 like '${message}%' </if>
<if test="apply_state != null and apply_state !='' "> and field0007 like '${apply_state}%' </if>
<if test="successed != null and successed !='' "> and field0008 = #{successed} </if>
<if test="title != null and title !='' "> and field0009 like '${title}%' </if>
<if test="pay_company != null and pay_company !='' "> and field0010 like '${pay_company}%' </if>
<if test="payee != null and payee !='' "> and field0011 like '${payee}%' </if>
<if test="amount != null and amount !='' "> and field0012 like '${amount}%' </if>
<if test="cbs_apply_code != null and cbs_apply_code !='' "> and field0013 like '${cbs_apply_code}%' </if>
</trim>
</select>
<select id="CbsLogEntity_list_base_in_payment" resultMap="get-CbsLogEntity-result" parameterType="com.hzya.frame.seeyon.cbs8.entity.CbsLogEntity">
select
<include refid="CbsLogEntity_Base_Column_List"/>
from
formmain_1283
<trim prefix="where" prefixOverrides="and">
<if test="oa_id != null and oa_id !='' "> field0001 = #{oa_id} </if>
<if test="id != null and id !='' "> and id = #{id} </if>
<if test="bill_code != null and bill_code !='' "> and field0002 = #{bill_code} </if>
<if test="tab_name_en != null and tab_name_en !='' "> and field0003 = #{tab_name_en} </if>
<if test="tab_name_ch != null and tab_name_ch !='' "> and field0004 = #{tab_name_ch} </if>
<if test="pay_state != null and pay_state !='' "> and field0005 = #{pay_state} </if>
<if test="message != null and message !='' "> and field0006 = #{message} </if>
<if test="apply_state != null and apply_state !='' "> and field0007 = #{apply_state} </if>
<if test="successed != null and successed !='' "> and field0008 = #{successed} </if>
and (field0005='支付中'
or field0005 not in ('审批撤销','审批拒绝','处理失败','退票','支付成功','取消支付','修改支付','支付失败','推送失败','网银支付',''))
</trim>
</select>
<!--修改视图支付状态-->
<update id="CbsLogEntity_update" parameterType="com.hzya.frame.seeyon.cbs8.entity.CbsLogEntity">
update formmain_1283 set
<trim suffix="" suffixOverrides=",">
<if test="pay_state != null and pay_state !='' ">field0005 =#{pay_state},</if>
field0006 =#{message},
<if test="apply_state != null and apply_state !='' ">field0007 =#{apply_state},</if>
<if test="successed != null and successed !='' ">field0008 =#{successed}</if>
</trim>
where id = #{id}
</update>
</mapper>

View File

@ -0,0 +1,39 @@
package com.hzya.frame.seeyon.cbs8.service;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.basedao.service.IBaseService;
import com.hzya.frame.seeyon.cbs8.entity.CbsLogEntity;
import java.util.List;
/**
* @Description cbs8支付日志
* @Author xiangerlin
* @Date 2024/6/14 17:22
**/
public interface ICbsLogService extends IBaseService<CbsLogEntity,String> {
/**
* 查询支付中的数据
* @param logEntity
* @return
*/
List<CbsLogEntity> queryInPayment(CbsLogEntity logEntity);
/**
* 保存日志通过rest接口的形式
* @param logEntity
*/
void saveLog(CbsLogEntity logEntity);
/**
* 补推从自己开发的页面或者APIpost
* 需要传oa表单id和表单编号
* @param entity
*/
void retry(CbsLogEntity entity);
/**
* 补推从OA页面
* 只需要传日志表id就行
* @param jsonObject
*/
void resend(JSONObject jsonObject);
}

View File

@ -20,4 +20,44 @@ public interface IPaymentService extends IBaseService<PaymentEntity,String> {
* @throws Exception
*/
List<PaymentEntity> queryUnpaid(PaymentEntity entity)throws Exception;
/**
* 查询交易成功的数据
* 内置了查询条件payResult = PayState.payStateGetValue("g"); 支付成功
* @param entity
* @return
* @throws Exception
*/
List<PaymentEntity> querySuccess(PaymentEntity entity)throws Exception;
/**
* 查询交易成功且电子回单为空的
* @param entity
* @return
* @throws Exception
*/
List<PaymentEntity> queryElecIsNull(PaymentEntity entity)throws Exception;
/**
* 查询支付中的数据
* 内置了查询条件 payResult = '支付中' or payResult not in ('审批撤销','审批拒绝','处理失败','退票','支付成功','取消支付','修改支付','支付失败')
* @param entity
* @return
* @throws Exception
*/
List<PaymentEntity> queryInPayment(PaymentEntity entity)throws Exception;
/**
* 更新支付状态
* @param entity
* @throws Exception
*/
void updatePayState(PaymentEntity entity)throws Exception;
/**
* 更新电子回单字段
* @param entity
* @throws Exception
*/
void updateElec(PaymentEntity entity)throws Exception;
}

View File

@ -0,0 +1,102 @@
package com.hzya.frame.seeyon.cbs8.service.impl;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.basedao.service.impl.BaseService;
import com.hzya.frame.cbs8.util.PayState;
import com.hzya.frame.seeyon.cbs8.dao.ICbsLogDao;
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.web.exception.BaseSystemException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @Description cbs8支付日志
* @Author xiangerlin
* @Date 2024/6/14 17:22
**/
@Service()
public class CbsLogServiceImpl extends BaseService<CbsLogEntity,String> implements ICbsLogService {
Logger log = LoggerFactory.getLogger(getClass());
private ICbsLogDao cbsLogDao;
@Autowired
public void setCbsLogDao(ICbsLogDao cbsLogDao) {
this.cbsLogDao = cbsLogDao;
this.dao = cbsLogDao;
}
/**
* 查询支付中的数据
*
* @param logEntity
* @return
*/
@Override
public List<CbsLogEntity> queryInPayment(CbsLogEntity logEntity) {
List<CbsLogEntity> logList = cbsLogDao.queryList(logEntity, "CbsLogEntity_list_base_in_payment");
return logList;
}
/**
* 保存日志通过rest接口的形式
*
* @param logEntity
*/
@Override
public void saveLog(CbsLogEntity logEntity) {
}
/**
* 补推从自己开发的页面或者APIpost
* 需要传oa表单id和表单编号
*
* @param entity
*/
@Override
public void retry(CbsLogEntity entity) {
PaymentEntity paymentEntity = new PaymentEntity();
paymentEntity.setOaId(entity.getOa_id());
paymentEntity.setReferenceNum(entity.getBill_code());
CbsLogEntity logEntity = new CbsLogEntity();
logEntity.setId(entity.getId());
logEntity = cbsLogDao.queryOne(logEntity);
String pay_state = logEntity.getPay_state();
if (PayState.h.getValue().equals(pay_state)
|| PayState.three.getValue().equals(pay_state)
|| PayState.k.getValue().equals(pay_state)
|| "推送失败".equals(pay_state)){
//todo 调用重试方法
}else {
throw new BaseSystemException("只允许补推支付失败的记录");
}
}
/**
* 补推从OA页面
* 只需要传日志表id就行
*
* @param jsonObject
*/
@Override
public void resend(JSONObject jsonObject) {
if (null != jsonObject && StrUtil.isNotEmpty(jsonObject.getString("id"))){
String id = jsonObject.getString("id");
CbsLogEntity cbsLogEntity = new CbsLogEntity();
cbsLogEntity.setId(id);
cbsLogEntity =cbsLogDao.queryOne(cbsLogEntity);
if (null != cbsLogEntity && StrUtil.isNotEmpty(cbsLogEntity.getOa_id()) && StrUtil.isNotEmpty(cbsLogEntity.getBill_code())){
retry(cbsLogEntity);
}
}
}
}

View File

@ -1,5 +1,6 @@
package com.hzya.frame.seeyon.cbs8.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.hzya.frame.basedao.service.impl.BaseService;
import com.hzya.frame.seeyon.cbs8.dao.IPaymentDao;
import com.hzya.frame.seeyon.cbs8.entity.PaymentEntity;
@ -17,6 +18,8 @@ import java.util.List;
@Service("OAPaymentServiceImpl")
public class PaymentServiceImpl extends BaseService<PaymentEntity,String> implements IPaymentService {
public static final String oa_datasource_code = "123";
private IPaymentDao paymentDao;
@Autowired
@ -33,8 +36,69 @@ public class PaymentServiceImpl extends BaseService<PaymentEntity,String> implem
* @return
* @throws Exception
*/
@Override
public List<PaymentEntity> queryUnpaid(PaymentEntity entity) throws Exception {
return null;
}
/**
* 查询交易成功的数据
* 内置了查询条件payResult = PayState.payStateGetValue("g"); 支付成功
*
* @param entity
* @return
* @throws Exception
*/
@Override
public List<PaymentEntity> querySuccess(PaymentEntity entity) throws Exception {
return null;
}
/**
* 查询交易成功且电子回单为空的
*
* @param entity
* @return
* @throws Exception
*/
@Override
public List<PaymentEntity> queryElecIsNull(PaymentEntity entity) throws Exception {
return null;
}
/**
* 查询支付中的数据
* 内置了查询条件 payResult = '支付中' or payResult not in ('审批撤销','审批拒绝','处理失败','退票','支付成功','取消支付','修改支付','支付失败')
*
* @param entity
* @return
* @throws Exception
*/
@Override
public List<PaymentEntity> queryInPayment(PaymentEntity entity) throws Exception {
return null;
}
/**
* 更新支付状态
*
* @param entity
* @throws Exception
*/
@Override
public void updatePayState(PaymentEntity entity) throws Exception {
}
/**
* 更新电子回单字段
*
* @param entity
* @throws Exception
*/
@Override
public void updateElec(PaymentEntity entity) throws Exception {
}
}