1、删除何灿之前的代码(NCC发起单据要去NCC开发,不用写到插件里)

2、重写CBS支付申请、查询交易结果插件
This commit is contained in:
xiang2lin 2025-05-29 19:02:37 +08:00
parent 972f8189bb
commit 4fe3292240
17 changed files with 414 additions and 3459 deletions

View File

@ -1,39 +0,0 @@
package com.hzya.frame.plugin.oa.payment.dao;
import com.hzya.frame.basedao.dao.IBaseDao;
import com.hzya.frame.plugin.oa.payment.entity.PaymentEntity;
import java.util.List;
public interface IPaymentDao extends IBaseDao<PaymentEntity, String> {
/**
* 查询OA审批完成的单据传递CBS
* @content
* @Param
* @Return
* @Author hecan
* @Date 2025-05-22 10:03
* **/
List<PaymentEntity> queryPaymentOAToCbs(PaymentEntity entity);
/**
*
* @content 查询OA需要查询支付状态的数据
* @Param
* @Return
* @Author hecan
* @Date 2025-05-22 11:33
* **/
List<PaymentEntity> queryPaymentOAResult(PaymentEntity entity);
/**
*
* @content 更新OA支付结果
* @Param
* @Return
* @Author hecan
* @Date 2025-05-23 11:44
* **/
Integer updatePaymentOAResult(PaymentEntity entity);
}

View File

@ -1,18 +0,0 @@
package com.hzya.frame.plugin.oa.payment.dao;
import com.hzya.frame.basedao.dao.IBaseDao;
import com.hzya.frame.plugin.oa.payment.entity.PaymentDetailsEntity;
import java.util.List;
public interface IPaymentDetailsDao extends IBaseDao<PaymentDetailsEntity, String> {
/**
*
* @content 查询OA付款单明细数据
* @Param
* @Return
* @Author hecan
* @Date 2025-05-23 10:37
* **/
List<PaymentDetailsEntity> queryPaymentDetails(PaymentDetailsEntity entity);
}

View File

@ -1,28 +0,0 @@
package com.hzya.frame.plugin.oa.payment.dao.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.hzya.frame.basedao.dao.MybatisGenericDao;
import com.hzya.frame.plugin.oa.payment.dao.IPaymentDao;
import com.hzya.frame.plugin.oa.payment.entity.PaymentEntity;
import java.util.List;
public class PaymentDaoImpl extends MybatisGenericDao<PaymentEntity, String> implements IPaymentDao {
@DS("#entity.dataSourceCode")
@Override
public List<PaymentEntity> queryPaymentOAToCbs(PaymentEntity entity) {
return (List<PaymentEntity>) super.selectList("queryPaymentOAToCbs",entity);
}
@DS("#entity.dataSourceCode")
@Override
public List<PaymentEntity> queryPaymentOAResult(PaymentEntity entity) {
return (List<PaymentEntity>) super.selectList("queryPaymentOAResult",entity);
}
@DS("#entity.dataSourceCode")
@Override
public Integer updatePaymentOAResult(PaymentEntity entity) {
return super.update("updatePaymentOAResult",entity);
}
}

View File

@ -1,16 +0,0 @@
package com.hzya.frame.plugin.oa.payment.dao.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.hzya.frame.basedao.dao.MybatisGenericDao;
import com.hzya.frame.plugin.oa.payment.dao.IPaymentDetailsDao;
import com.hzya.frame.plugin.oa.payment.entity.PaymentDetailsEntity;
import java.util.List;
public class PaymentDetailsDaoImpl extends MybatisGenericDao<PaymentDetailsEntity, String> implements IPaymentDetailsDao {
@DS("#entity.dataSourceCode")
@Override
public List<PaymentDetailsEntity> queryPaymentDetails(PaymentDetailsEntity entity) {
return (List<PaymentDetailsEntity>) super.selectList("queryPaymentDetails",entity);
}
}

View File

@ -1,168 +0,0 @@
<?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.plugin.oa.payment.dao.impl.PaymentDetailsDaoImpl">
<resultMap id="get-PaymentDetailsEntity-result" type="com.hzya.frame.plugin.oa.payment.entity.PaymentDetailsEntity" >
<result property="id" column="id" jdbcType="VARCHAR"/>
<result property="sorts" column="sorts" jdbcType="INTEGER"/>
<result property="create_user_id" column="create_user_id" jdbcType="VARCHAR"/>
<result property="create_time" column="create_time" jdbcType="TIMESTAMP"/>
<result property="modify_user_id" column="modify_user_id" jdbcType="VARCHAR"/>
<result property="modify_time" column="modify_time" jdbcType="TIMESTAMP"/>
<result property="sts" column="sts" jdbcType="VARCHAR"/>
<result property="org_id" column="org_id" jdbcType="VARCHAR"/>
<result property="companyId" column="company_id" jdbcType="VARCHAR"/>
</resultMap>
<!-- 查询的字段-->
<sql id = "PaymentDetailsEntity_Base_Column_List">
,pk_payitem as pkPayitem
,sett_org as settOrg
,pk_org as pkOrg
,pk_fiorg as pkFiorg
,pu_org as puOrg
,pu_psndoc as puPsndoc
,pu_deptid as puDeptid
,prepay as prepay
,material as material
,supplier as supplier
,checkdirection as checkdirection
,payflag as payflag
,pausetransact as pausetransact
,billdate as billdate
,payman as payman
,paydate as paydate
,pk_billtype as pkBilltype
,billclass as billclass
,pk_tradetype as pkTradetype
,billno as billno
,objtype as objtype
,rowno as rowno
,rowtype as rowtype
,direction as direction
,checktype as checktype
,scomment as scomment
,pk_currtype as pkcurrtype
,rate as rate
,pk_deptid as pkDeptid
,pk_psndoc as pkPsndoc
,money_de as moneyDe
,local_money_de as localMoneyDe
,quantity_bal as quantityBal
,local_tax_de as localTaxDe
,price as price
,taxprice as taxprice
,taxrate as taxrate
,taxnum as taxnum
,pk_balatype as pkBalatype
,top_billid as topBillid
,top_itemid as topItemid
,checkno as checkno
,payaccount as payaccount
,recaccount as recaccount
,cashaccount as cashaccount
,contractno as contractno
,purchaseorder as purchaseorder
,invoiceno as invoiceno
,outstoreno as outstoreno
,project as project
,groupnotax_de as groupnotaxDe
,globalnotax_de as globalnotaxDe
,commpaytype as commpaytype
,commpaystatus as commpaystatus
,customer as customer
,payreason as payreason
,pk_paybill as pkPaybill
,comment as comment
,pk_recpaytype as pkRecpaytype
,taxcodeid as taxcodeid
,taxtype as taxtype
,buysellflag as buysellflag
,direct_checkno as directCheckno
,direct_checkno as directCheckno
</sql>
<!-- 查询 采用==查询 -->
<select id="entity_list_base" resultMap="get-PaymentDetailsEntity-result" parameterType = "com.hzya.frame.plugin.oa.payment.entity.PaymentDetailsEntity">
select
<include refid="PaymentDetailsEntity_Base_Column_List" />
from ap_payitem
<trim prefix="where" prefixOverrides="and">
<if test="pkPayitem != null and pkPayitem != ''"> and pk_payitem = #{pkPayitem} </if>
<if test="settOrg != null and settOrg != ''"> and sett_org = #{settOrg} </if>
<if test="pkOrg != null and pkOrg != ''"> and pk_org = #{pkOrg} </if>
<if test="pkFiorg != null and pkFiorg != ''"> and pk_fiorg = #{pkFiorg} </if>
<if test="puOrg != null and puOrg != ''"> and pu_org = #{puOrg} </if>
<if test="pupsndoc != null and pupsndoc != ''"> and pupsndoc = #{pupsndoc} </if>
<if test="puDeptid != null and puDeptid != ''"> and pu_deptid = #{puDeptid} </if>
<if test="prepay != null and prepay != ''"> and prepay = #{prepay} </if>
<if test="material != null and material != ''"> and material = #{material} </if>
<if test="supplier != null and supplier != ''"> and supplier = #{supplier} </if>
<if test="payflag != null and payflag != ''"> and payflag = #{payflag} </if>
<if test="billdate != null and billdate != ''"> and billdate = #{billdate} </if>
<if test="paydate != null and paydate != ''"> and paydate = #{paydate} </if>
<if test="payman != null and payman != ''"> and payman = #{payman} </if>
<if test="pkBilltype != null and pkBilltype != ''"> and pkBilltype = #{pkBilltype} </if>
<if test="billclass != null and billclass != ''"> and billclass = #{billclass} </if>
<if test="pkTradetype != null and pkTradetype != ''"> and pk_tradetype = #{pkTradetype} </if>
<if test="billno != null and billno != ''"> and billno = #{billno} </if>
<if test="rowno != null and rowno != ''"> and rowno = #{rowno} </if>
<if test="scomment != null and scomment != ''"> and scomment = #{scomment} </if>
<if test="pkCurrtype != null and pkCurrtype != ''"> and pk_currtype = #{pkCurrtype} </if>
<if test="rate != null and rate != ''"> and rate = #{rate} </if>
<if test="pkDeptid != null and pkDeptid != ''"> and pk_deptid = #{pkDeptid} </if>
<if test="pkPsndoc != null and pkPsndoc != ''"> and pk_psndoc = #{pkPsndoc} </if>
<if test="price != null and price != ''"> and price = #{price} </if>
<if test="taxnum != null and taxnum != ''"> and taxnum = #{taxnum} </if>
<if test="topBillid != null and topBillid != ''"> and top_billid = #{topBillid} </if>
<if test="checkno != null and checkno != ''"> and checkno = #{checkno} </if>
<if test="payaccount != null and payaccount != ''"> and payaccount = #{payaccount} </if>
<if test="recaccount != null and recaccount != ''"> and recaccount = #{recaccount} </if>
<if test="cashaccount != null and cashaccount != ''"> and cashaccount = #{cashaccount} </if>
<if test="contractno != null and contractno != ''"> and contractno = #{contractno} </if>
<if test="purchaseorder != null and purchaseorder != ''"> and purchaseorder = #{purchaseorder} </if>
<if test="invoiceno != null and invoiceno != ''"> and invoiceno = #{invoiceno} </if>
<if test="project != null and project != ''"> and project = #{project} </if>
<if test="customer != null and customer != ''"> and customer = #{customer} </if>
<if test="payreason != null and payreason != ''"> and payreason = #{payreason} </if>
<if test="comment != null and comment != ''"> and comment = #{comment} </if>
and dr='0'
</trim>
</select>
<!-- 查询 采用==查询 -->
<select id="queryPaymentDetails" resultMap="get-PaymentDetailsEntity-result" parameterType = "com.hzya.frame.plugin.oa.payment.entity.PaymentDetailsEntity">
select
field0036 as prepay
,field0033 as material
,field0058 as supplier
,field0051 as pausetransact
,field0056 as objtype
,field0046 as checktype
,field0032 as scomment
,field0061 as pkCurrtype
,field0062 as rate
,field0059 as pkDeptid
,field0060 as pkPsndoc
,field0039 as moneyDe
,field0040 as localMoneyDe
,field0052 as notaxDe
,field0042 as taxrate
,field0063 as pkBalatype
,field0047 as checkno
,field0064 as payaccount
,field0065 as recaccount
,field0066 as cashaccount
,field0054 as groupnotaxDe
,field0055 as globalnotaxDe
,field0057 as customer
,field0035 as pkRecpaytype
,field0041 as taxcodeid
,field0050 as directCheckno
from formson_0261
where formmain_id=#{formmainId}
</select>
</mapper>

View File

@ -1,153 +0,0 @@
<?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.plugin.oa.payment.dao.impl.PaymentDaoImpl">
<resultMap id="get-PaymentEntity-result" type="com.hzya.frame.plugin.oa.payment.entity.PaymentEntity" >
<result property="id" column="id" jdbcType="VARCHAR"/>
<result property="sorts" column="sorts" jdbcType="INTEGER"/>
<result property="create_user_id" column="create_user_id" jdbcType="VARCHAR"/>
<result property="create_time" column="create_time" jdbcType="TIMESTAMP"/>
<result property="modify_user_id" column="modify_user_id" jdbcType="VARCHAR"/>
<result property="modify_time" column="modify_time" jdbcType="TIMESTAMP"/>
<result property="sts" column="sts" jdbcType="VARCHAR"/>
<result property="org_id" column="org_id" jdbcType="VARCHAR"/>
<result property="companyId" column="company_id" jdbcType="VARCHAR"/>
</resultMap>
<!-- 查询的字段-->
<sql id = "PaymentEntity_Base_Column_List">
pk_org as pkOrg
,isreded as isreded
,pk_paybill as pkPaybill
,pk_fiorg as pkFiorg
,pu_org as puOrg
,pk_group as pkGroup
,pk_billtype as pkBilltype
,pk_corp as pkCorp
,pk_tradetype as pkTradetype
,billclass as billclass
,pk_tradetypeid as pkTradetypeid
,billno as billno
,billdate as billdate
,syscode as syscode
,src_syscode as srcSyscode
,billstatus as billstatus
,billmaker as billmaker
,approver as approver
,approvedate as approvedate
,pk_busitype as pkBusitype
,money as money
,local_money as localMoney
,scomment as scomment
,settleflag as settleflag
,settletype as settletype
,effectstatus as effectstatus
,pu_deptid as puDeptid
,pu_psndoc as puPsndoc
,pk_deptid as pkDeptid
,pk_psndoc as pkPsndoc
,supplier as supplier
,pk_currtype as pkCurrtype
,pk_subjcode as pkSubjcode
,pk_balatype as pkBalatype
,objtype as objtype
,payaccount as payaccount
,recaccount as recaccount
,cashaccount as cashaccount
,approvestatus as approvestatus
,customer as customer
,invoiceno as invoiceno
,reversalreason as reversalreason
,failurereason as failurereason
,payreason as payreason
,modifiedtime as modifiedtime
,creationtime as creationtime
,creator as creator
,modifier as modifier
</sql>
<!-- 查询 采用==查询 -->
<select id="entity_list_base" resultMap="get-PaymentEntity-result" parameterType = "com.hzya.frame.plugin.oa.payment.entity.PaymentEntity">
select
<include refid="PaymentEntity_Base_Column_List" />
from ap_paybill
<trim prefix="where" prefixOverrides="and">
<if test="pkPaybill != null and pkPaybill != ''"> and pk_paybill = #{pkPaybill} </if>
<if test="pkFiorg != null and pkFiorg != ''"> and pk_fiorg = #{pkFiorg} </if>
<if test="pkOrg != null and pkOrg != ''"> and pk_org = #{pkOrg} </if>
<if test="settOrg != null and settOrg != ''"> and sett_org = #{settOrg} </if>
<if test="puOrg != null and puOrg != ''"> and pu_org = #{puOrg} </if>
<if test="payman != null and payman != ''"> and payman = #{payman} </if>
<if test="paydate != null and paydate != ''"> and paydate = #{paydate} </if>
<if test="settlenum != null and settlenum != ''"> and settlenum = #{settlenum} </if>
<if test="pkBilltype != null and pkBilltype != ''"> and pk_billtype = #{pkBilltype} </if>
<if test="pkCorp != null and pkCorp != ''"> and pk_corp = #{pkCorp} </if>
<if test="pkTradetypeid != null and pkTradetypeid != ''"> and pk_tradetypeid = #{pkTradetypeid} </if>
<if test="billclass != null and billclass != ''"> and billclass = #{billclass} </if>
<if test="billno != null and billno != ''"> and billno = #{billno} </if>
<if test="billdate != null and billdate != ''"> and billdate = #{billdate} </if>
<if test="money != null and money != ''"> and money = #{money} </if>
<if test="scomment != null and scomment != ''"> and scomment = #{scomment} </if>
<if test="rate != null and rate != ''"> and rate = #{rate} </if>
<if test="puDeptid != null and puDeptid != ''"> and pu_deptid = #{puDeptid} </if>
<if test="puPsndoc != null and puPsndoc != ''"> and pu_psndoc = #{puPsndoc} </if>
<if test="pkCurrtype != null and pkCurrtype != ''"> and pk_currtype = #{pkCurrtype} </if>
<if test="payaccount != null and payaccount != ''"> and payaccount = #{payaccount} </if>
<if test="recaccount != null and recaccount != ''"> and recaccount = #{recaccount} </if>
<if test="cashaccount != null and cashaccount != ''"> and cashaccount = #{cashaccount} </if>
<if test="invoiceno != null and invoiceno != ''"> and invoiceno = #{invoiceno} </if>
<if test="reversalreason != null and reversalreason != ''"> and reversalreason = #{reversalreason} </if>
<if test="ailurereason != null and ailurereason != ''"> and ailurereason = #{ailurereason} </if>
<if test="payreason != null and payreason != ''"> and payreason = #{payreason} </if>
and billclass='fk' and dr='0' and approvestatus='-1'
</trim>
</select>
<!-- 查询 采用==查询 -->
<select id="queryPaymentOAToCbs" resultMap="get-PaymentEntity-result" parameterType = "com.hzya.frame.plugin.oa.payment.entity.PaymentEntity">
select
id
,field0007 as pkOrg
,field0005 as isreded
,field0014 as pkTradetypeid
,field0001 as billno
,field0004 as billdate
,field0028 as billstatus
,field0002 as billmaker
,field0015 as pkBusitype
,field0018 as money
,field0019 as localMoney
,field0030 as effectstatus
,field0012 as pkDeptid
,field0013 as pkPsndoc
,field0011 as supplier
,field0016 as pkCurrtype
,field0027 as pkSubjcode
,field0020 as pkBalatype
,field0009 as objtype
,field0022 as payaccount
,field0025 as recaccount
,field0023 as cashaccount
,field0029 as approvestatus
,field0010 as customer
from formmain_0260
left join col_summary summary on main.id = summary.form_recordid
where 1=1 and summary.state in ('1','2','3')
</select>
<!-- 查询 采用==查询 -->
<select id="queryPaymentOAResult" resultMap="get-PaymentEntity-result" parameterType = "com.hzya.frame.plugin.oa.payment.entity.PaymentEntity">
select
id
from formmain_0260
where 1=1 and (xxxx is null
or xxx not in ('审批撤销','审批拒绝','处理失败','退票','支付成功','取消支付','修改支付','支付失败'))
</select>
<update id="updatePaymentOAResult" parameterType="com.hzya.frame.plugin.oa.payment.entity.PaymentEntity">
update formmain_0260 set xxx =#{oaResult} where id=#{id}
</update>
</mapper>

View File

@ -1,145 +0,0 @@
package com.hzya.frame.plugin.oa.payment.plugin;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.base.PluginBaseEntity;
import com.hzya.frame.plugin.oa.payment.dao.IPaymentDao;
import com.hzya.frame.plugin.oa.payment.dao.IPaymentDetailsDao;
import com.hzya.frame.plugin.oa.payment.entity.PaymentDetailsEntity;
import com.hzya.frame.plugin.oa.payment.entity.PaymentEntity;
import com.hzya.frame.sysnew.integtationTaskLivingDetails.entity.IntegrationTaskLivingDetailsEntity;
import com.hzya.frame.sysnew.integtationTaskLivingDetails.service.IIntegrationTaskLivingDetailsService;
import com.hzya.frame.uuid.UUIDUtils;
import com.hzya.frame.web.entity.BaseResult;
import com.hzya.frame.web.entity.JsonResultEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import java.util.Date;
import java.util.List;
public class CbsResultToOAPluginInitializer extends PluginBaseEntity {
Logger logger = LoggerFactory.getLogger(CbsResultToOAPluginInitializer.class);
@Autowired
private IPaymentDao paymentDao;
@Autowired
private IPaymentDetailsDao paymentDetailsDao;
@Value("${zt.url}")
private String url;
@Autowired
private IIntegrationTaskLivingDetailsService taskLivingDetailsService;
@Override
public void initialize() {
logger.info(getPluginLabel() + "執行初始化方法initialize()");
}
@Override
public void destroy() {
logger.info(getPluginLabel() + "執行銷毀方法destroy()");
}
@Override
public String getPluginId() {
return "CbsResultToOAPluginInitializer";
}
@Override
public String getPluginName() {
return "CBS支付结果回写OA";
}
@Override
public String getPluginLabel() {
return "CbsResultToOAPluginInitializer";
}
@Override
public String getPluginType() {
return "1";
}
@Override
public JsonResultEntity executeBusiness(JSONObject requestJson) {
try {
logger.info("======开始执行CBS支付结果回写OA========");
//重试方法
if (null != requestJson) {
//如果这个id不为空说明是重试的
String id = requestJson.getString("integration_task_living_details_id");
//执行重新发送
PaymentEntity paymentEntity = new PaymentEntity();
paymentEntity.setDataSourceCode("");
if (StrUtil.isNotEmpty(id)) {
paymentEntity.setId(id);
}
//查询没有支付成功的数据
List<PaymentEntity> paymentEntities = paymentDao.queryPaymentOAResult(paymentEntity);
if(paymentEntities == null || paymentEntities.size() == 0){
logger.info("=====OA中没有需要查询支付状态的数据==========");
return BaseResult.getSuccessMessageEntity("查询成功");
}
for (PaymentEntity payment : paymentEntities) {
payment.setDataSourceCode("");
JSONObject jsonObject=new JSONObject();
String result = HttpRequest.post(url).
header("appId", "").
header("apiCode", "").
header("publicKey", "ZJYAQ/VtQ66PqKXlV0EowrrlKkhBHYgS/Zk39Q5ezIQne51Ce7eDIk+3zDUT+v578prj").
header("secretKey", "iLLk424Bmzknbu+ROeJoiVDMYY5EFXtbZY/aU13HmVYIiQrIw9c0Ag4ipxbfpUqqj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=").
body(jsonObject.toString()).
execute().
body();
logger.info("========CBS支付结果回写OA的返回参数为:{}=========",result);
JSONObject resultJson = JSONObject.parseObject(result);
if(!resultJson.getBoolean("flag")){
JSONObject attribute = resultJson.getJSONObject("attribute");
if("".equals(attribute.getString(""))){
//修改oa付款单支付状态
payment.setOaResult("");
paymentDao.updatePaymentOAResult(payment);
}
}
}
}
}catch(Exception e){
logger.info("======执行CBS支付结果回写OA失败:{}========", e.getMessage());
e.printStackTrace();
}
return BaseResult.getFailureMessageEntity("CBS支付结果回写OA执行失败");
}
private void saveTaskLivingDetails(String rootAppPk,String rootAppBill,String rootAppNewData,String newTransmitInfo,boolean flag) {
try {
IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity();
integrationTaskLivingDetailsEntity.setId(UUIDUtils.getUUID());
integrationTaskLivingDetailsEntity.setSts("Y");
integrationTaskLivingDetailsEntity.setCreate_user_id("1");
integrationTaskLivingDetailsEntity.setModify_user_id("1");
integrationTaskLivingDetailsEntity.setCreate_time(new Date());
integrationTaskLivingDetailsEntity.setModify_time(new Date());
integrationTaskLivingDetailsEntity.setOrg_id("0");
integrationTaskLivingDetailsEntity.setCompanyId("0");
integrationTaskLivingDetailsEntity.setRootAppPk(rootAppPk);
integrationTaskLivingDetailsEntity.setRootAppBill(rootAppBill);
integrationTaskLivingDetailsEntity.setPluginId("CbsResultToOAPluginInitializer");
integrationTaskLivingDetailsEntity.setRootAppNewData(rootAppNewData);
integrationTaskLivingDetailsEntity.setNewTransmitInfo(newTransmitInfo);
if(flag){
taskLivingDetailsService.saveLogToSuccess(integrationTaskLivingDetailsEntity);
}else {
taskLivingDetailsService.saveLogToFail(integrationTaskLivingDetailsEntity);
}
}catch (Exception e){
logger.info("保存日志到集成任务日志明细中失败:{}",e.getMessage());
}
}
}

View File

@ -1,155 +0,0 @@
package com.hzya.frame.plugin.oa.payment.plugin;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.base.PluginBaseEntity;
import com.hzya.frame.plugin.oa.payment.dao.IPaymentDao;
import com.hzya.frame.plugin.oa.payment.dao.IPaymentDetailsDao;
import com.hzya.frame.plugin.oa.payment.entity.PaymentDetailsEntity;
import com.hzya.frame.plugin.oa.payment.entity.PaymentEntity;
import com.hzya.frame.sysnew.integtationTaskLivingDetails.entity.IntegrationTaskLivingDetailsEntity;
import com.hzya.frame.sysnew.integtationTaskLivingDetails.service.IIntegrationTaskLivingDetailsService;
import com.hzya.frame.uuid.UUIDUtils;
import com.hzya.frame.web.entity.BaseResult;
import com.hzya.frame.web.entity.JsonResultEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import java.util.Date;
import java.util.List;
public class OAApprovedToCbsPluginInitializer extends PluginBaseEntity {
Logger logger = LoggerFactory.getLogger(PaymentToOAPluginInitializer.class);
@Autowired
private IPaymentDao paymentDao;
@Autowired
private IPaymentDetailsDao paymentDetailsDao;
@Value("${zt.url}")
private String url;
@Autowired
private IIntegrationTaskLivingDetailsService taskLivingDetailsService;
@Override
public void initialize() {
logger.info(getPluginLabel() + "執行初始化方法initialize()");
}
@Override
public void destroy() {
logger.info(getPluginLabel() + "執行銷毀方法destroy()");
}
@Override
public String getPluginId() {
return "OAApprovedToCbsPluginInitializer";
}
@Override
public String getPluginName() {
return "OA已审批单据传递CBS";
}
@Override
public String getPluginLabel() {
return "OAApprovedToCbsPluginInitializer";
}
@Override
public String getPluginType() {
return "1";
}
@Override
public JsonResultEntity executeBusiness(JSONObject requestJson) {
try {
logger.info("======开始执行OA审批完成单据推送CBS========");
//重试方法
if (null != requestJson) {
//如果这个id不为空说明是重试的
String id = requestJson.getString("integration_task_living_details_id");
//执行重新发送
PaymentEntity paymentEntity = new PaymentEntity();
paymentEntity.setDataSourceCode("");
if (StrUtil.isNotEmpty(id)) {
paymentEntity.setId(id);
}
//查询OA审批完成单据推送CBS的数据
List<PaymentEntity> paymentEntities = paymentDao.queryPaymentOAToCbs(paymentEntity);
if(paymentEntities == null || paymentEntities.size() == 0){
logger.info("=====OA中没有已审批完成需要推送CBS的单据==========");
return BaseResult.getSuccessMessageEntity("查询成功");
}
for (PaymentEntity payment : paymentEntities) {
JSONObject jsonObject=new JSONObject();
//查询OA明细数据
PaymentDetailsEntity paymentDetailsEntity=new PaymentDetailsEntity();
paymentDetailsEntity.setDataSourceCode("");
paymentDetailsEntity.setFormmainId(payment.getId());
List<PaymentDetailsEntity> paymentDetailsEntities = paymentDetailsDao.queryPaymentDetails(paymentDetailsEntity);
if(paymentDetailsEntities == null || paymentDetailsEntities.size() == 0){
logger.info("=====没有需要从OA传递CBS的明细数据==========");
}else{
for (PaymentDetailsEntity detailsEntity : paymentDetailsEntities) {
}
}
String result = HttpRequest.post(url).
header("appId", "").
header("apiCode", "").
header("publicKey", "ZJYAQ/VtQ66PqKXlV0EowrrlKkhBHYgS/Zk39Q5ezIQne51Ce7eDIk+3zDUT+v578prj").
header("secretKey", "iLLk424Bmzknbu+ROeJoiVDMYY5EFXtbZY/aU13HmVYIiQrIw9c0Ag4ipxbfpUqqj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=").
body(jsonObject.toString()).
execute().
body();
logger.info("========OA审批完成单据推送CBS的返回参数为:{}=========",result);
JSONObject resultJson = JSONObject.parseObject(result);
if(!resultJson.getBoolean("flag")){
JSONObject attribute = resultJson.getJSONObject("attribute");
if("".equals(attribute.getString(""))){
//修改oa付款单推送状态
}
}
}
}
}catch(Exception e){
logger.info("======执行OA审批完成单据推送CBS失败:{}========", e.getMessage());
e.printStackTrace();
}
return BaseResult.getFailureMessageEntity("OA审批完成单据推送CBS执行失败");
}
private void saveTaskLivingDetails(String rootAppPk,String rootAppBill,String rootAppNewData,String newTransmitInfo,boolean flag) {
try {
IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity();
integrationTaskLivingDetailsEntity.setId(UUIDUtils.getUUID());
integrationTaskLivingDetailsEntity.setSts("Y");
integrationTaskLivingDetailsEntity.setCreate_user_id("1");
integrationTaskLivingDetailsEntity.setModify_user_id("1");
integrationTaskLivingDetailsEntity.setCreate_time(new Date());
integrationTaskLivingDetailsEntity.setModify_time(new Date());
integrationTaskLivingDetailsEntity.setOrg_id("0");
integrationTaskLivingDetailsEntity.setCompanyId("0");
integrationTaskLivingDetailsEntity.setRootAppPk(rootAppPk);
integrationTaskLivingDetailsEntity.setRootAppBill(rootAppBill);
integrationTaskLivingDetailsEntity.setPluginId("OAApprovedToCbsPluginInitializer");
integrationTaskLivingDetailsEntity.setRootAppNewData(rootAppNewData);
integrationTaskLivingDetailsEntity.setNewTransmitInfo(newTransmitInfo);
if(flag){
taskLivingDetailsService.saveLogToSuccess(integrationTaskLivingDetailsEntity);
}else {
taskLivingDetailsService.saveLogToFail(integrationTaskLivingDetailsEntity);
}
}catch (Exception e){
logger.info("保存日志到集成任务日志明细中失败:{}",e.getMessage());
}
}
}

View File

@ -0,0 +1,102 @@
package com.hzya.frame.plugin.oa.payment.plugin;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.base.PluginBaseEntity;
import com.hzya.frame.plugin.oa.payment.service.IPaymentPluginService;
import com.hzya.frame.web.entity.BaseResult;
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 2025/5/29 17:19
**/
public class PayResultPluginInitializer extends PluginBaseEntity {
Logger logger = LoggerFactory.getLogger(PayResultPluginInitializer.class);
@Autowired
private IPaymentPluginService paymentPluginService;
/***
* 插件初始化方法
* @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 "PayResultPlugin";
}
/****
* 插件的名称
* @author 👻👻👻👻👻👻👻👻 gjh
* @date 2023-08-02 10:48
* @return void
**/
@Override
public String getPluginName() {
return "查询CBS交易结果";
}
/****
* 插件的显示值
* @author 👻👻👻👻👻👻👻👻 gjh
* @date 2023-08-02 10:48
* @return void
**/
@Override
public String getPluginLabel() {
return "查询CBS交易结果";
}
/***
* 插件类型 1场景插件
* @Author 👻👻👻👻👻👻👻👻 gjh
* @Date 2023-08-02 14:01
* @Param []
* @return java.lang.String
**/
@Override
public String getPluginType() {
return "0";
}
/***
* 执行业务代码
* @Author 👻👻👻👻👻👻👻👻 gjh
* @Date 2023-08-07 11:20
* @param requestJson 执行业务代码的参数
* @return void
**/
@Override
public JsonResultEntity executeBusiness(JSONObject requestJson) throws Exception {
logger.info("======开始查询CBS交易结果======");
paymentPluginService.payRequest(requestJson);
return BaseResult.getSuccessMessageEntity("执行成功");
}
}

View File

@ -0,0 +1,107 @@
package com.hzya.frame.plugin.oa.payment.plugin;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.base.PluginBaseEntity;
import com.hzya.frame.plugin.oa.payment.service.IPaymentPluginService;
import com.hzya.frame.web.entity.BaseResult;
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 2025/5/29 15:40
**/
public class PaymentRequestPluginInitializer extends PluginBaseEntity {
Logger logger = LoggerFactory.getLogger(PaymentRequestPluginInitializer.class);
@Autowired
private IPaymentPluginService paymentPluginService;
/***
* 插件初始化方法
* @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 "PaymentRequestPlugin";
}
/****
* 插件的名称
* @author 👻👻👻👻👻👻👻👻 gjh
* @date 2023-08-02 10:48
* @return void
**/
@Override
public String getPluginName() {
return "OA支付申请CBS插件";
}
/****
* 插件的显示值
* @author 👻👻👻👻👻👻👻👻 gjh
* @date 2023-08-02 10:48
* @return void
**/
@Override
public String getPluginLabel() {
return "OA支付申请CBS插件";
}
/***
* 插件类型 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 {
try {
logger.info("======开始执行OA支付申请CBS插件======");
JsonResultEntity jsonResultEntity = paymentPluginService.payRequest(requestJson);
return BaseResult.getSuccessMessageEntity("OA支付申请CBS插件执行成功",jsonResultEntity);
}catch (Exception e){
logger.info("======执行OA支付申请CBS插件出错======{}",e.getMessage());
return BaseResult.getFailureMessageEntity("OA支付申请CBS插件执行失败",e.getMessage());
}
}
}

View File

@ -1,222 +0,0 @@
package com.hzya.frame.plugin.oa.payment.plugin;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.base.PluginBaseEntity;
import com.hzya.frame.plugin.oa.payment.dao.IPaymentDao;
import com.hzya.frame.plugin.oa.payment.dao.IPaymentDetailsDao;
import com.hzya.frame.plugin.oa.payment.entity.PaymentDetailsEntity;
import com.hzya.frame.plugin.oa.payment.entity.PaymentEntity;
import com.hzya.frame.sysnew.integtationTaskLivingDetails.entity.IntegrationTaskLivingDetailsEntity;
import com.hzya.frame.sysnew.integtationTaskLivingDetails.service.IIntegrationTaskLivingDetailsService;
import com.hzya.frame.uuid.UUIDUtils;
import com.hzya.frame.web.entity.BaseResult;
import com.hzya.frame.web.entity.JsonResultEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class PaymentToOAPluginInitializer extends PluginBaseEntity {
Logger logger = LoggerFactory.getLogger(PaymentToOAPluginInitializer.class);
@Autowired
private IPaymentDao paymentDao;
@Autowired
private IPaymentDetailsDao paymentDetailsDao;
@Value("${zt.url}")
private String url;
@Autowired
private IIntegrationTaskLivingDetailsService taskLivingDetailsService;
@Override
public void initialize() {
logger.info(getPluginLabel() + "執行初始化方法initialize()");
}
@Override
public void destroy() {
logger.info(getPluginLabel() + "執行銷毀方法destroy()");
}
@Override
public String getPluginId() {
return "PaymentToOAPluginInitializer";
}
@Override
public String getPluginName() {
return "NCC付款单传递OA";
}
@Override
public String getPluginLabel() {
return "PaymentToOAPluginInitializer";
}
@Override
public String getPluginType() {
return "1";
}
@Override
public JsonResultEntity executeBusiness(JSONObject requestJson) {
try {
logger.info("======开始执行NCC付款单传递OA========");
//重试方法
if (null != requestJson) {
//如果这个id不为空说明是重试的
String id = requestJson.getString("integration_task_living_details_id");
//执行重新发送
PaymentEntity paymentEntity = new PaymentEntity();
paymentEntity.setDataSourceCode("");
if (StrUtil.isNotEmpty(id)) {
paymentEntity.setId(id);
}
//查询ncc需要传递OA的数据
List<PaymentEntity> paymentEntities = paymentDao.query(paymentEntity);
if(paymentEntities == null || paymentEntities.size() == 0){
logger.info("=====没有需要从NCC传递到OA的付款单==========");
return BaseResult.getSuccessMessageEntity("查询成功");
}
for (PaymentEntity payment : paymentEntities) {
JSONObject jsonObject=new JSONObject();
JSONObject jsonMain=new JSONObject();
JSONArray jsonArray=new JSONArray();
jsonObject.put("应付财务组织",payment.getPkOrg());
jsonObject.put("红冲标志",payment.getIsreded());
jsonObject.put("付款类型",payment.getPkTradetypeid());
jsonObject.put("单据编号",payment.getBillno());
jsonObject.put("单据日期",payment.getBilldate());
jsonObject.put("单据状态",payment.getBillstatus());
jsonObject.put("发起人",payment.getBillmaker());
jsonObject.put("业务流程",payment.getPkBusitype());
jsonObject.put("原币金额",payment.getMoney());
jsonObject.put("组织本币金额",payment.getLocalMoney());
jsonObject.put("生效状态",payment.getEffectstatus());
jsonObject.put("部门",payment.getPkDeptid());
jsonObject.put("业务员",payment.getPkPsndoc());
jsonObject.put("供应商",payment.getSupplier());
jsonObject.put("币种",payment.getPkCurrtype());
jsonObject.put("收支项目",payment.getPkSubjcode());
jsonObject.put("结算方式",payment.getPkBalatype());
jsonObject.put("往来对象",payment.getObjtype());
jsonObject.put("付款银行账户",payment.getPayaccount());
jsonObject.put("收款银行账户",payment.getRecaccount());
jsonObject.put("现金账户",payment.getCashaccount());
jsonObject.put("审批状态",payment.getApprovestatus());
jsonObject.put("客户",payment.getCustomer());
jsonMain.put("formmain_0260",jsonObject);
PaymentDetailsEntity paymentDetailsEntity=new PaymentDetailsEntity();
paymentDetailsEntity.setDataSourceCode("");
paymentDetailsEntity.setTopBillid(payment.getPkPaybill());
//查询NCC付款单明细
List<PaymentDetailsEntity> paymentDetailsEntities = paymentDetailsDao.query(paymentDetailsEntity);
if(paymentDetailsEntities == null || paymentDetailsEntities.size() == 0){
logger.info("=====没有需要从NCC传递到OA的付款单明细数据==========");
}else{
for (PaymentDetailsEntity detailsEntity : paymentDetailsEntities) {
JSONObject jsonDetails=new JSONObject();
jsonDetails.put("付款性质",detailsEntity.getPrepay());
jsonDetails.put("物料",detailsEntity.getMaterial());
jsonDetails.put("供应商-明细表",detailsEntity.getSupplier());
jsonDetails.put("挂起标志",detailsEntity.getPausetransact());
jsonDetails.put("往来对象-明细表",detailsEntity.getObjtype());
jsonDetails.put("票据类型",detailsEntity.getChecktype());
jsonDetails.put("摘要",detailsEntity.getScomment());
jsonDetails.put("币种-明细表",detailsEntity.getPkCurrtype());
jsonDetails.put("组织本币汇率-明细表",detailsEntity.getRate());
jsonDetails.put("部门-明细表",detailsEntity.getPkDeptid());
jsonDetails.put("业务员-明细表",detailsEntity.getPkPsndoc());
jsonDetails.put("借方原币金额",detailsEntity.getMoneyDe());
jsonDetails.put("组织本币金额-借方",detailsEntity.getLocalMoneyDe());
jsonDetails.put("借方原币无税金额",detailsEntity.getNotaxDe());
jsonDetails.put("税率",detailsEntity.getTaxrate());
jsonDetails.put("结算方式-明细表",detailsEntity.getPkBalatype());
jsonDetails.put("票据号",detailsEntity.getCheckno());
jsonDetails.put("付款银行账户-明细表",detailsEntity.getPayaccount());
jsonDetails.put("收款银行账户-明细表",detailsEntity.getRecaccount());
jsonDetails.put("现金账户-明细表",detailsEntity.getCashaccount());
jsonDetails.put("集团本币无税金额-借方",detailsEntity.getGroupnotaxDe());
jsonDetails.put("全局本币无税金额-借方",detailsEntity.getGlobalnotaxDe());
jsonDetails.put("客户-明细表",detailsEntity.getCustomer());
jsonDetails.put("付款业务类型",detailsEntity.getPkRecpaytype());
jsonDetails.put("税码",detailsEntity.getTaxcodeid());
jsonDetails.put("直联电票",detailsEntity.getDirectCheckno());
jsonArray.add(jsonDetails);
}
}
jsonMain.put("formson_0261",jsonArray);
Map<String, Object> map = new HashMap<String, Object>();
map.put("appName", "collaboration");
Map<String, Object> data1 = new HashMap<String, Object>();
data1.put("templateCode", "formmain_0260");
data1.put("draft", "1");
data1.put("data", jsonMain);
map.put("data", data1);
logger.info("========NCC付款单传递OA的请求参数为:{}=========",map);
//发送数据
String result = HttpRequest.post(url).
header("appId", "800064").
header("apiCode", "8000640000").
header("publicKey", "ZJYAQ/VtQ66PqKXlV0EowrrlKkhBHYgS/Zk39Q5ezIQne51Ce7eDIk+3zDUT+v578prj").
header("secretKey", "iLLk424Bmzknbu+ROeJoiVDMYY5EFXtbZY/aU13HmVYIiQrIw9c0Ag4ipxbfpUqqj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=").
body(map.toString()).
execute().
body();
logger.info("========NCC付款单传递OA的返回参数为:{}=========",result);
JSONObject resultJson = JSONObject.parseObject(result);
if(!resultJson.getBoolean("flag")){
JSONObject attribute = resultJson.getJSONObject("attribute");
if("0".equals(attribute.getString("code"))){
//修改NCC付款单推送状态
}
}
}
logger.info("=======NCC付款单传递OA执行成功=======");
return BaseResult.getSuccessMessageEntity("NCC付款单传递OA执行成功");
}
}catch (Exception e){
logger.info("======执行NCC付款单传递OA失败:{}========", e.getMessage());
e.printStackTrace();
}
return BaseResult.getFailureMessageEntity("NCC付款单传递OA执行失败");
}
private void saveTaskLivingDetails(String rootAppPk,String rootAppBill,String rootAppNewData,String newTransmitInfo,boolean flag) {
try {
IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity();
integrationTaskLivingDetailsEntity.setId(UUIDUtils.getUUID());
integrationTaskLivingDetailsEntity.setSts("Y");
integrationTaskLivingDetailsEntity.setCreate_user_id("1");
integrationTaskLivingDetailsEntity.setModify_user_id("1");
integrationTaskLivingDetailsEntity.setCreate_time(new Date());
integrationTaskLivingDetailsEntity.setModify_time(new Date());
integrationTaskLivingDetailsEntity.setOrg_id("0");
integrationTaskLivingDetailsEntity.setCompanyId("0");
integrationTaskLivingDetailsEntity.setRootAppPk(rootAppPk);
integrationTaskLivingDetailsEntity.setRootAppBill(rootAppBill);
integrationTaskLivingDetailsEntity.setPluginId("PaymentToOAPluginInitializer");
integrationTaskLivingDetailsEntity.setRootAppNewData(rootAppNewData);
integrationTaskLivingDetailsEntity.setNewTransmitInfo(newTransmitInfo);
if(flag){
taskLivingDetailsService.saveLogToSuccess(integrationTaskLivingDetailsEntity);
}else {
taskLivingDetailsService.saveLogToFail(integrationTaskLivingDetailsEntity);
}
}catch (Exception e){
logger.info("保存日志到集成任务日志明细中失败:{}",e.getMessage());
}
}
}

View File

@ -0,0 +1,24 @@
package com.hzya.frame.plugin.oa.payment.service;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.web.entity.JsonResultEntity;
/**
* @Description 支付申请
* @Author xiangerlin
* @Date 2025/5/29 15:43
**/
public interface IPaymentPluginService {
/**
* 支付申请
* @param requestJson
* @return
*/
JsonResultEntity payRequest(JSONObject requestJson);
/**
* 查询交易结果
* @param requestJson
*/
void queryPayResult(JSONObject requestJson);
}

View File

@ -1,7 +0,0 @@
package com.hzya.frame.plugin.oa.payment.service;
import com.hzya.frame.basedao.service.IBaseService;
import com.hzya.frame.plugin.oa.payment.entity.PaymentEntity;
public interface IPaymentService extends IBaseService<PaymentEntity, String> {
}

View File

@ -0,0 +1,181 @@
package com.hzya.frame.plugin.oa.payment.service.impl;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.lang.Assert;
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.oa.payment.service.IPaymentPluginService;
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.BaseResult;
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.List;
/**
* @Description 支付申请
* @Author xiangerlin
* @Date 2025/5/29 15:43
**/
public class PaymentPluginServiceImpl implements IPaymentPluginService {
Logger logger = LoggerFactory.getLogger(PaymentPluginServiceImpl.class);
@Autowired
private IPaymentService paymentService;
@Autowired
private ICbs8Service cbs8Service;
@Autowired
private ICbsLogService cbsLogService;;
/**
* 支付申请
*
* @param requestJson
* @return
*/
@Override
public JsonResultEntity payRequest(JSONObject requestJson) {
String headersStr = requestJson.getString("headers");//请求头
String formAppId = requestJson.getString("formAppId");
String eventType = requestJson.getString("eventType");
String id = requestJson.getString("id");
String dataSouceCode = requestJson.getString("sourceCode");
Assert.notEmpty(id,"id不能为空");
Assert.notEmpty(formAppId,"formAppId不能为空");
Assert.notEmpty(eventType,"eventType不能为空");
Assert.notEmpty(headersStr,"headers不能为空");
Assert.notEmpty(dataSouceCode,"数据源编码不能为空");
logger.info("准备开始查询待支付的单据");
PaymentEntity paymentEntity = new PaymentEntity();
paymentEntity.setId(id);
paymentEntity.setDataSourceCode(dataSouceCode);
try {
//查询OA待支付的数据
List<PaymentEntity> paymentList = paymentService.queryUnpaid(paymentEntity);
if (CollectionUtils.isNotEmpty(paymentList) && paymentList.size() == 1){
PaymentEntity pay = paymentList.get(0);
PayResponseDTO payResponseDTO = cbs8Service.payApply(JSONObject.toJSONString(pay));
String payResStr = JSONObject.toJSONString(payResponseDTO);
logger.info("支付申请响应结果:{}",payResStr);
if (null != payResponseDTO){
//保存支付日志
saveCbsLog(pay,payResponseDTO,dataSouceCode);
if (payResponseDTO.getSuccessed()) {
return BaseResult.getSuccessMessageEntity("支付申请成功",payResponseDTO.getBusNum());
}else {
BaseResult.getFailureMessageEntity("支付申请失败:{}",payResStr);
}
}else {
BaseResult.getFailureMessageEntity("支付申请失败");
}
return BaseResult.getSuccessMessageEntity("",payResponseDTO);
}
}catch (Exception e){
logger.error("OA单据推CBS支付申请失败:{}",e);
}
return null;
}
/**
* 查询交易结果
*
* @param requestJson
*/
@Override
public void queryPayResult(JSONObject requestJson) {
String dataSourceCode = requestJson.getString("sourceCode");
Assert.notEmpty(dataSourceCode,"数据源编码不能为空");
try {
CbsLogEntity cbsLogEntity = new CbsLogEntity();
cbsLogEntity.setDataSourceCode(dataSourceCode);
List<CbsLogEntity> queryList = cbsLogService.queryInPayment(cbsLogEntity);
if (CollectionUtils.isNotEmpty(queryList)){
for (CbsLogEntity entity : queryList) {
List<PayResultResDTO> payResultResDTOList = cbs8Service.queryPayResult(new PayResultRequestDTO(entity.getBill_code()));
if (CollectionUtils.isNotEmpty(payResultResDTOList)){
PayResultResDTO payResultResDTO = payResultResDTOList.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());
paymentEntity.setDataSourceCode(dataSourceCode);
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));
entity.setDataSourceCode(dataSourceCode);
cbsLogService.update(entity);
}
}
}
}
}
}catch (Exception e){
logger.error("查询交易结果出错:{}",e);
}
}
/**
* 保存支付日志
* @param entity 支付参数
* @param payResponseDTO cbs返回参数
* @param dataSourceCode 数据源编码
* @throws Exception
*/
private void saveCbsLog(PaymentEntity entity,PayResponseDTO payResponseDTO,String dataSourceCode)throws Exception{
if (null != payResponseDTO){
//4. 保存日志
CbsLogEntity cbsLogEntity = new CbsLogEntity();
cbsLogEntity.setTitle(entity.getTitle());
cbsLogEntity.setPay_company(entity.getPayCompany());
cbsLogEntity.setPayee(entity.getRevAccountName());
cbsLogEntity.setAmount(entity.getAmount());
cbsLogEntity.setOa_id(entity.getOaId());
cbsLogEntity.setBill_code(Convert.toStr(entity.getReferenceNumNew(),entity.getReferenceNum()));
cbsLogEntity.setTab_name_ch(entity.getBillName());
cbsLogEntity.setTab_name_en(entity.getTableName());
Boolean successed = payResponseDTO.getSuccessed();
if (successed){
cbsLogEntity.setPay_state(PayState.p.getValue());
cbsLogEntity.setApply_state(PayState.two.getValue());
cbsLogEntity.setCbs_apply_code(payResponseDTO.getBusNum());
cbsLogEntity.setSuccessed("true");
entity.setPayResult(PayState.p.getValue());
}else {
cbsLogEntity.setPay_state("推送失败");
cbsLogEntity.setMessage(payResponseDTO.getErrorMsg());
cbsLogEntity.setSuccessed("false");
entity.setPayResult("推送失败");
}
cbsLogEntity.setDataSourceCode(dataSourceCode);
cbsLogService.saveLog(cbsLogEntity);
//5.更新视图的支付状态
paymentService.updatePayState(entity);
}
}
}

View File

@ -1,8 +0,0 @@
package com.hzya.frame.plugin.oa.payment.service.impl;
import com.hzya.frame.basedao.service.impl.BaseService;
import com.hzya.frame.plugin.oa.payment.entity.PaymentEntity;
import com.hzya.frame.plugin.oa.payment.service.IPaymentService;
public class PaymentServiceImpl extends BaseService<PaymentEntity, String> implements IPaymentService {
}