|
|
@@ -4,6 +4,18 @@ import cn.hutool.json.JSONArray;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.fs.common.annotation.QuartzRunnable;
|
|
|
import com.fs.common.core.redis.RedisCache;
|
|
|
+import com.fs.common.utils.StringUtils;
|
|
|
+import com.fs.huifuPay.domain.HuiFuQueryOrderResult;
|
|
|
+import com.fs.huifuPay.dto.*;
|
|
|
+import com.fs.huifuPay.sdk.opps.core.request.V2TradePaymentScanpayQueryRequest;
|
|
|
+import com.fs.huifuPay.service.HuiFuService;
|
|
|
+import com.fs.live.service.ILiveOrderService;
|
|
|
+import com.fs.pay.pay.domain.OrderResult;
|
|
|
+import com.fs.pay.pay.dto.OrderQueryDTO;
|
|
|
+import com.fs.pay.pay.service.PayService;
|
|
|
+import com.fs.store.domain.TzConfigInfoDTO;
|
|
|
+import com.fs.tzBank.TzBankService;
|
|
|
+import com.fs.tzBank.utils.TzConfigUtils;
|
|
|
import com.fs.company.domain.CompanyUser;
|
|
|
import com.fs.company.mapper.CompanyUserMapper;
|
|
|
import com.fs.core.security.SecurityUtils;
|
|
|
@@ -31,7 +43,7 @@ import com.fs.wx.mapper.FsWxExpressTaskMapper;
|
|
|
import com.google.common.util.concurrent.RateLimiter;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.lang.ObjectUtils;
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.apache.http.util.Asserts;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@@ -41,6 +53,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
@@ -116,7 +129,14 @@ public class StoreTask {
|
|
|
|
|
|
@Autowired
|
|
|
private IFsStorePaymentService fsStorePaymentService;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private HuiFuService huiFuService;
|
|
|
+ @Autowired
|
|
|
+ private PayService ybPayService;
|
|
|
+ @Autowired
|
|
|
+ private TzBankService tzBankService;
|
|
|
+ @Autowired
|
|
|
+ private ILiveOrderService liveOrderService;
|
|
|
|
|
|
@Autowired
|
|
|
private FsWxExpressTaskMapper fsWxExpressTaskMapper;
|
|
|
@@ -130,6 +150,88 @@ public class StoreTask {
|
|
|
@Autowired
|
|
|
private FsJstCodPushService fsJstCodPushService;
|
|
|
|
|
|
+
|
|
|
+ // 订单银行回调数据丢失补偿(与 FsStorePaymentController.returnPayStatus 一致,仅处理商城近期待支付订单下的支付单)
|
|
|
+ public void recoveryBankOrder() {
|
|
|
+ List<FsStoreOrder> list = fsStoreOrderService.selectBankOrder();
|
|
|
+ if (CollectionUtils.isEmpty(list)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (FsStoreOrder storeOrder : list) {
|
|
|
+ try {
|
|
|
+ List<FsStorePayment> payments = fsStorePaymentService.selectFsStorePaymentByOrderIdNew(storeOrder.getId());
|
|
|
+ if (CollectionUtils.isEmpty(payments)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ for (FsStorePayment payment : payments) {
|
|
|
+ if (payment.getStatus() == null || payment.getStatus() != 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(payment.getTradeNo()) || StringUtils.isEmpty(payment.getPayMode())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String payMode = payment.getPayMode();
|
|
|
+ if ("hf".equals(payMode)) {
|
|
|
+ V2TradePaymentScanpayQueryRequest request = new V2TradePaymentScanpayQueryRequest();
|
|
|
+ request.setOrgReqDate(new SimpleDateFormat("yyyyMMdd").format(payment.getCreateTime()));
|
|
|
+ request.setOrgHfSeqId(payment.getTradeNo());
|
|
|
+ HuiFuQueryOrderResult o = huiFuService.queryOrder(request);
|
|
|
+ logger.info("商城订单补偿 汇付查询 orderId={} resp={}", storeOrder.getId(), o);
|
|
|
+ if (o != null && "00000000".equals(o.getResp_code()) && "S".equals(o.getTrans_stat())) {
|
|
|
+ String[] parts = o.getOrg_req_seq_id().split("-");
|
|
|
+ if (parts.length < 2) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (parts[0].equals("store")) {
|
|
|
+ orderService.payConfirm(1, null, parts[1], o.getOrg_hf_seq_id(), o.getOut_trans_id(), o.getParty_order_id());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if ("yb".equals(payMode)) {
|
|
|
+ OrderQueryDTO q = new OrderQueryDTO();
|
|
|
+ q.setUpOrderId(payment.getTradeNo());
|
|
|
+ OrderResult orderResult = ybPayService.getOrder(q);
|
|
|
+ if (orderResult == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if ("4".equals(orderResult.getState()) || "5".equals(orderResult.getState())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (!"0".equals(orderResult.getState()) || !"100".equals(orderResult.getStatus())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String[] parts = orderResult.getLowOrderId().split("-");
|
|
|
+ if (parts.length < 2) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (parts[0].equals("store")) {
|
|
|
+ orderService.payConfirm(1, null, parts[1], payment.getTradeNo(), orderResult.getBankTrxId(), orderResult.getBankOrderId());
|
|
|
+ }
|
|
|
+ } else if ("tzbk".equals(payMode)) {
|
|
|
+ FsStoreOrder fsOrder = orderService.selectFsStoreOrderById(payment.getOrderId());
|
|
|
+ Asserts.notNull(fsOrder, "当前订单不存在!");
|
|
|
+ RequestDTO<QueryOrderRestDTO> requestDTO = new RequestDTO<>();
|
|
|
+ QueryOrderRestDTO queryOrderRestDTO = new QueryOrderRestDTO();
|
|
|
+ queryOrderRestDTO.setOrderFlowNo(payment.getTradeNo());
|
|
|
+ TzConfigInfoDTO tzConfigInfoDTO = TzConfigUtils.getConfig();
|
|
|
+ queryOrderRestDTO.setPlatMerCstNo(tzConfigInfoDTO.getPlatMerCstNo());
|
|
|
+ requestDTO.setReqBody(queryOrderRestDTO);
|
|
|
+ requestDTO.setReqHeader(TzReqHeaderDTO.getInstance(payment.getPayCode()));
|
|
|
+ TzReqResultDTO<QueryOrderInfoDTO> resultDTO = tzBankService.payQueryOrder(requestDTO);
|
|
|
+ if (resultDTO == null || !"00000000".equals(resultDTO.getRetCode())) {
|
|
|
+ logger.info("商城订单补偿 台州银行查询失败 orderId={} ret={}", storeOrder.getId(), resultDTO);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ QueryOrderInfoDTO body = resultDTO.getBody();
|
|
|
+ orderService.payConfirm(1, fsOrder.getId(), payment.getPayCode(),
|
|
|
+ payment.getTradeNo(), body.getChlTrxId(), payment.getTradeNo());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error("商城订单银行补偿失败 orderId={}", storeOrder.getId(), e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 推送jst售后单
|
|
|
*/
|