|
|
@@ -1,6 +1,7 @@
|
|
|
package com.zhongshu.card.server.core.service.pay;
|
|
|
|
|
|
import com.github.microservice.components.data.mongo.queue.service.ExecQueueService;
|
|
|
+import com.github.microservice.core.helper.ApplicationContextHolder;
|
|
|
import com.github.microservice.core.util.JsonUtil;
|
|
|
import com.github.microservice.core.util.bean.BeanUtil;
|
|
|
import com.github.microservice.net.ResultContent;
|
|
|
@@ -22,24 +23,29 @@ import com.github.microservice.types.payment.PaymentType;
|
|
|
import com.zhongshu.card.client.model.pay.ChinaumsSenselessUserSignInfoModel;
|
|
|
import com.zhongshu.card.client.model.pay.UnionApplySignParam;
|
|
|
import com.zhongshu.card.client.type.ContractState;
|
|
|
+import com.zhongshu.card.client.type.RefundState;
|
|
|
import com.zhongshu.card.client.type.ShareOrderType;
|
|
|
import com.zhongshu.card.client.utils.DateUtils;
|
|
|
import com.zhongshu.card.server.core.dao.pay.ChinaumsSenselessUserSignInfoDao;
|
|
|
import com.zhongshu.card.server.core.dao.pay.ShareOrderDao;
|
|
|
+import com.zhongshu.card.server.core.dao.payment.ExpenseFlowDao;
|
|
|
import com.zhongshu.card.server.core.domain.pay.ChinaumsSenselessUserSignInfo;
|
|
|
import com.zhongshu.card.server.core.domain.pay.PayAccount;
|
|
|
import com.zhongshu.card.server.core.domain.pay.ShareOrder;
|
|
|
+import com.zhongshu.card.server.core.domain.payment.ExpenseFlow;
|
|
|
import com.zhongshu.card.server.core.event.ChinaumsRefundEvent;
|
|
|
import com.zhongshu.card.server.core.model.pay.ChinaumsSenselessSrcReserve;
|
|
|
import com.zhongshu.card.server.core.model.pay.UnionFrictionlessPayFinishModel;
|
|
|
import com.zhongshu.card.server.core.service.base.SuperService;
|
|
|
import com.zhongshu.card.server.core.service.paySetting.OrgPayAccountService;
|
|
|
+import com.zhongshu.card.server.core.service.payment.PayCallService;
|
|
|
import com.zhongshu.card.server.core.util.BeanUtils;
|
|
|
import com.zhongshu.card.server.core.util.CommonUtil;
|
|
|
import io.micrometer.common.util.StringUtils;
|
|
|
import lombok.SneakyThrows;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.context.ApplicationContext;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.StopWatch;
|
|
|
|
|
|
@@ -413,7 +419,31 @@ public class ChinaumsSenselessPayService extends SuperService {
|
|
|
Map bodyMap = JsonUtil.toObject(JsonUtil.toJson(refundResultContent.getContent()), Map.class);
|
|
|
|
|
|
if (bodyMap.get("respCode").equals("TARGET_PROCESSING")) {
|
|
|
- String queueId = execQueueService.add(Map.of("refundOrderNo", refundOrderNo), 5, ChinaumsRefundEvent.class);
|
|
|
+ execQueueService.add(Map.of("refundOrderNo", refundOrderNo), 5, data->{
|
|
|
+ final ExpenseFlowDao expenseFlowDao = ApplicationContextHolder.getContext().getBean(ExpenseFlowDao.class);
|
|
|
+ final ChinaumsSenselessPayService chinaumsSenselessPayService = ApplicationContextHolder.getContext().getBean(ChinaumsSenselessPayService.class);
|
|
|
+ final PayCallService payCallService = ApplicationContextHolder.getContext().getBean(PayCallService.class);
|
|
|
+ String number = (String) data.get("refundOrderNo");
|
|
|
+ ExpenseFlow refundOrder = expenseFlowDao.findTopByRefundNo(number);
|
|
|
+ if (refundOrder == null) {
|
|
|
+ log.info("找不到退款单");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (refundOrder.getRefundState().equals(RefundState.Refunded) || refundOrder.getRefundState().equals(RefundState.Fail)){
|
|
|
+ log.info("当前退款单状态为已退款或退款失败");
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ ResultContent<UnionFrictionlessPayFinishModel> refundQuery = chinaumsSenselessPayService.refundQuery(refundOrder.getProjectOid(), refundOrder.getUserId(), refundOrder.getShopOid(), refundOrderNo, true);
|
|
|
+ if (!refundQuery.getState().equals(com.github.microservice.net.ResultState.Success)){
|
|
|
+ log.info("查询退款结果失败:{}", refundQuery.getMsg());
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (refundQuery.getContent().getRefundStatus().equals("PROCESSING") || refundQuery.getContent().getRefundStatus().equals("UNKNOWN")){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ ResultContent resultContent = payCallService.unionFrictionlessPayRefundFinish(refundQuery.getContent());
|
|
|
+ return resultContent.getState().equals(com.github.microservice.net.ResultState.Success);
|
|
|
+ }, System.currentTimeMillis() + 30*24*60*60*1000L);
|
|
|
return ResultContent.buildContent(refundResultContent.getContent());
|
|
|
}
|
|
|
return ResultContent.buildFail(bodyMap.get("respDesc").toString());
|