|
@@ -4,13 +4,13 @@ import java.math.BigDecimal;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
import cn.hutool.core.util.IdUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.fs.common.annotation.DataScope;
|
|
import com.fs.common.annotation.DataScope;
|
|
-import com.fs.common.core.controller.BaseController;
|
|
|
|
import com.fs.common.core.domain.R;
|
|
import com.fs.common.core.domain.R;
|
|
import com.fs.common.exception.CustomException;
|
|
import com.fs.common.exception.CustomException;
|
|
import com.fs.common.utils.DateUtils;
|
|
import com.fs.common.utils.DateUtils;
|
|
@@ -38,6 +38,7 @@ import com.fs.store.vo.FsStorePaymentVO;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import com.fs.store.mapper.FsStorePaymentMapper;
|
|
import com.fs.store.mapper.FsStorePaymentMapper;
|
|
import com.fs.store.domain.FsStorePayment;
|
|
import com.fs.store.domain.FsStorePayment;
|
|
@@ -296,42 +297,58 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService
|
|
public void paymentSync() {
|
|
public void paymentSync() {
|
|
List<FsStorePayment> fsStorePayments = fsStorePaymentMapper.queryPendingDelayState();
|
|
List<FsStorePayment> fsStorePayments = fsStorePaymentMapper.queryPendingDelayState();
|
|
for (FsStorePayment fsStorePayment : fsStorePayments) {
|
|
for (FsStorePayment fsStorePayment : fsStorePayments) {
|
|
- RequestDTO<QueryOrderRestDTO> requestDTO = new RequestDTO<>();
|
|
|
|
-
|
|
|
|
- QueryOrderRestDTO queryOrderRestDTO = new QueryOrderRestDTO();
|
|
|
|
-
|
|
|
|
- queryOrderRestDTO.setOrderFlowNo(fsStorePayment.getTradeNo());
|
|
|
|
- TzConfigInfoDTO tzConfigInfoDTO = TzConfigUtils.getConfig();
|
|
|
|
-
|
|
|
|
- queryOrderRestDTO.setPlatMerCstNo(tzConfigInfoDTO.getPlatMerCstNo());
|
|
|
|
-
|
|
|
|
- requestDTO.setReqBody(queryOrderRestDTO);
|
|
|
|
- requestDTO.setReqHeader(TzReqHeaderDTO.getInstance(fsStorePayment.getPayCode()));
|
|
|
|
-
|
|
|
|
- TzReqResultDTO<QueryOrderInfoDTO> resultDTO = null;
|
|
|
|
- try {
|
|
|
|
- resultDTO = tzBankService.payQueryOrder(requestDTO);
|
|
|
|
- String retCode = resultDTO.getRetCode();
|
|
|
|
- // 如果查询支付成功
|
|
|
|
- if(retCode.equals("00000000")){
|
|
|
|
- QueryOrderInfoDTO body = resultDTO.getBody();
|
|
|
|
- String status = body.getStatus();
|
|
|
|
- Long orderId = fsStorePayment.getOrderId();
|
|
|
|
- String payCode = fsStorePayment.getPayCode();
|
|
|
|
- if("90".equals(status)){
|
|
|
|
- // 如果查询支付成功 更新订单状态
|
|
|
|
- orderService.payConfirm(1,orderId,fsStorePayment.getPayCode(),
|
|
|
|
- fsStorePayment.getTradeNo(),body.getChlTrxId(),fsStorePayment.getTradeNo());
|
|
|
|
-
|
|
|
|
- } else if("70".equals(status) || "80".equals(status)) {
|
|
|
|
- fsStorePayment.setStatus(-2);
|
|
|
|
- this.updateFsStorePayment(fsStorePayment);
|
|
|
|
- }
|
|
|
|
|
|
+ queryTzbk(fsStorePayment);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ @Async
|
|
|
|
+ public void delayQueryTzbk(FsStorePayment fsStorePayment){
|
|
|
|
+ try {
|
|
|
|
+ TimeUnit.SECONDS.sleep(30);
|
|
|
|
+ } catch (InterruptedException e) {
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
+ }
|
|
|
|
+ this.queryTzbk(fsStorePayment);
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public void queryTzbk(FsStorePayment fsStorePayment) {
|
|
|
|
+ RequestDTO<QueryOrderRestDTO> requestDTO = new RequestDTO<>();
|
|
|
|
+
|
|
|
|
+ QueryOrderRestDTO queryOrderRestDTO = new QueryOrderRestDTO();
|
|
|
|
+
|
|
|
|
+ queryOrderRestDTO.setOrderFlowNo(fsStorePayment.getTradeNo());
|
|
|
|
+ TzConfigInfoDTO tzConfigInfoDTO = TzConfigUtils.getConfig();
|
|
|
|
+
|
|
|
|
+ queryOrderRestDTO.setPlatMerCstNo(tzConfigInfoDTO.getPlatMerCstNo());
|
|
|
|
+
|
|
|
|
+ requestDTO.setReqBody(queryOrderRestDTO);
|
|
|
|
+ requestDTO.setReqHeader(TzReqHeaderDTO.getInstance(fsStorePayment.getPayCode()));
|
|
|
|
+
|
|
|
|
+ TzReqResultDTO<QueryOrderInfoDTO> resultDTO = null;
|
|
|
|
+ try {
|
|
|
|
+ resultDTO = tzBankService.payQueryOrder(requestDTO);
|
|
|
|
+ String retCode = resultDTO.getRetCode();
|
|
|
|
+ // 如果查询支付成功
|
|
|
|
+ if(retCode.equals("00000000")){
|
|
|
|
+ QueryOrderInfoDTO body = resultDTO.getBody();
|
|
|
|
+ String status = body.getStatus();
|
|
|
|
+ Long orderId = fsStorePayment.getOrderId();
|
|
|
|
+ String payCode = fsStorePayment.getPayCode();
|
|
|
|
+ if("90".equals(status)){
|
|
|
|
+ // 如果查询支付成功 更新订单状态
|
|
|
|
+ orderService.payConfirm(1,orderId, fsStorePayment.getPayCode(),
|
|
|
|
+ fsStorePayment.getTradeNo(),body.getChlTrxId(), fsStorePayment.getTradeNo());
|
|
|
|
+
|
|
|
|
+ } else if("70".equals(status) || "80".equals(status)) {
|
|
|
|
+ fsStorePayment.setStatus(-2);
|
|
|
|
+ this.updateFsStorePayment(fsStorePayment);
|
|
}
|
|
}
|
|
- } catch (Exception e) {
|
|
|
|
- logger.error("台州银行支付回调查询失败:",e);
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ logger.error("台州银行支付回调查询失败:",e);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|