Bläddra i källkod

查询退费结果定时器调整

master
huminghao 1 månad sedan
förälder
incheckning
cabcba24c1

+ 5
- 3
gly-base-core/src/main/java/cn/com/taiji/core/repo/jpa/issue/IssueOrderRefundRepo.java Visa fil

@@ -4,13 +4,15 @@ import cn.com.taiji.common.repo.jpa.AbstractJpaRepo;
import cn.com.taiji.core.entity.dict.issue.RefundOperateType;
import cn.com.taiji.core.entity.dict.issue.RefundStatus;
import cn.com.taiji.core.entity.issue.IssueOrderRefund;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface IssueOrderRefundRepo extends AbstractJpaRepo<IssueOrderRefund, String>{

@Query(" from IssueOrderRefund where status = ?1 and operateType = ?2 order by updateTime desc")
List<IssueOrderRefund> findbyStatusAndOperateType(RefundStatus status, RefundOperateType operateType);

@Query(value = " from IssueOrderRefund where status = ?1 and operateType = ?2 order by updateTime desc",
countQuery = "select count(*) from IssueOrderRefund where status = ?1 and operateType = ?2")
Page<IssueOrderRefund> findByStatusAndOperateType(RefundStatus status, RefundOperateType operateType, Pageable pageable);
}

+ 51
- 49
zhywpt-dps-iasq/src/main/java/cn/com/taiji/iasq/manager/quartz/ats/OrderRefundWeChatQueryManagerImpl.java Visa fil

@@ -18,9 +18,11 @@ import cn.com.taiji.core.repo.jpa.issue.IssueOrderPayRepo;
import cn.com.taiji.core.repo.jpa.issue.IssueOrderRefundRepo;
import cn.com.taiji.core.repo.jpa.issue.IssueOrderinfoRepo;
import cn.com.taiji.iasq.manager.AbstractCommManager;
import cn.hutool.core.util.ObjectUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@@ -45,10 +47,11 @@ public class OrderRefundWeChatQueryManagerImpl extends AbstractCommManager imple
@Override
public void execute() {
logger.info("-------消息推送-消息发送开始-------");
List<IssueOrderRefund> orderRefundList = orderRefundRepo.findbyStatusAndOperateType(RefundStatus.APPLY, RefundOperateType.ORIGINAL);
for (IssueOrderRefund orderRefund : orderRefundList) {
Pageable pageable = PageRequest.of(0, 100);
Page<IssueOrderRefund> pageList = orderRefundRepo.findByStatusAndOperateType(RefundStatus.NOTREFUND, RefundOperateType.ORIGINAL, pageable);
for (IssueOrderRefund orderRefund : pageList.getContent()) {
//查询退款结果
Boolean flag = weChatRefundQuery(orderRefund);
Boolean flag = refundQuery(orderRefund);
if (flag) {
//更新IssueOrderInfo
updateIssueOrderInfo(orderRefund);
@@ -86,7 +89,7 @@ public class OrderRefundWeChatQueryManagerImpl extends AbstractCommManager imple


@Transactional(rollbackFor = Exception.class)
private Boolean weChatRefundQuery(IssueOrderRefund orderRefund) {
private Boolean refundQuery(IssueOrderRefund orderRefund) {
if (StringUtils.isEmpty(orderRefund.getExternalRefundNo())) {
logger.error("退费单号不能为空!");
return false;
@@ -96,55 +99,54 @@ public class OrderRefundWeChatQueryManagerImpl extends AbstractCommManager imple
logger.error("退费支付配置信息表未查到数据!");
return false;
}
if (!PayChannelType.WEIXINPAY.equals(payConfig.getPayChannelType())) {
return false;
}
//微信支付退费
if (PayChannelType.WEIXINPAY.equals(payConfig.getPayChannelType())) {
if (payConfig.getWxPayVersion() == 2) {
//调退费申请接口
AtsQueryRefundV2Request v2Request = new AtsQueryRefundV2Request();
v2Request.setCreateType(payConfig.getWxServiceType());
v2Request.setOutRefundNo(orderRefund.getExternalRefundNo());//退款时的订单号
v2Request.setAppId(payConfig.getWxAppId());
v2Request.setMchId(payConfig.getWxMchId());
v2Request.setSubMchId(payConfig.getWxSubMchId());
v2Request.setMchKey(payConfig.getWxKey());
AtsQueryRefundV2Response v2Response = null;
try {
v2Response = jsonPostRepeat(v2Request);
} catch (ManagerException e) {
logger.error(e.getMessage(), e);
return false;
}
for (AtsQueryRefundV2Response.RefundRecord refundRecord : v2Response.getRefundRecords()) {
if ("SUCCESS".equals(refundRecord.getRefundStatus())) {
orderRefund.setStatus(RefundStatus.STOPREFUND);
}
}

if (payConfig.getWxPayVersion() == 2) {
//调退费申请接口
AtsQueryRefundV2Request v2Request = new AtsQueryRefundV2Request();
v2Request.setCreateType(payConfig.getWxServiceType());
v2Request.setOutRefundNo(orderRefund.getExternalRefundNo());//退款时的订单号
v2Request.setAppId(payConfig.getWxAppId());
v2Request.setMchId(payConfig.getWxMchId());
v2Request.setSubMchId(payConfig.getWxSubMchId());
v2Request.setMchKey(payConfig.getWxKey());
AtsQueryRefundV2Response v2Response = null;
try {
v2Response = jsonPostRepeat(v2Request);
} catch (ManagerException e) {
logger.error(e.getMessage(), e);
return false;
}
for (AtsQueryRefundV2Response.RefundRecord refundRecord : v2Response.getRefundRecords()) {
if ("SUCCESS".equals(refundRecord.getRefundStatus())) {
} else if (payConfig.getWxPayVersion() == 3) {
AtsQueryRefundV3Request v3Request = new AtsQueryRefundV3Request();
v3Request.setCreateType(payConfig.getWxServiceType());
v3Request.setOutRefundNo(orderRefund.getExternalRefundNo());//退款时的订单号
v3Request.setMchid(payConfig.getWxMchId());
v3Request.setApiV3Key(payConfig.getWxApiv3key());
v3Request.setPrivateKey(payConfig.getWxPrivatekey());
v3Request.setSerialNo(payConfig.getWxSerialNo());
v3Request.setPublicKey(payConfig.getWxPublicKey());
v3Request.setPublicKeyId(payConfig.getWxPublicKeyId());
AtsQueryRefundV3Response v3Response = null;
try {
v3Response = jsonPostRepeat(v3Request);
} catch (ManagerException e) {
logger.error(e.getMessage(), e);
return false;
}
if (RefundV3Status.SUCCESS.equals(v3Response.getStatus())) {
orderRefund.setStatus(RefundStatus.STOPREFUND);
}
}

} else if (payConfig.getWxPayVersion() == 3) {
AtsQueryRefundV3Request v3Request = new AtsQueryRefundV3Request();
v3Request.setCreateType(payConfig.getWxServiceType());
v3Request.setOutRefundNo(orderRefund.getExternalRefundNo());//退款时的订单号
v3Request.setMchid(payConfig.getWxMchId());
v3Request.setApiV3Key(payConfig.getWxApiv3key());
v3Request.setPrivateKey(payConfig.getWxPrivatekey());
v3Request.setSerialNo(payConfig.getWxSerialNo());
v3Request.setPublicKey(payConfig.getWxPublicKey());
v3Request.setPublicKeyId(payConfig.getWxPublicKeyId());
AtsQueryRefundV3Response v3Response = null;
try {
v3Response = jsonPostRepeat(v3Request);
} catch (ManagerException e) {
logger.error(e.getMessage(), e);
} else {
logger.error("退款微信支付版本异常!");
return false;
}
if (RefundV3Status.SUCCESS.equals(v3Response.getStatus())) {
orderRefund.setStatus(RefundStatus.STOPREFUND);
}
} else {
logger.error("退款微信支付版本异常!");
return false;
}
return true;
}

Laddar…
Avbryt
Spara