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