|
|
@@ -41,9 +41,10 @@ import com.fs.course.domain.FsCourseRedPacketLog;
|
|
|
import com.fs.course.mapper.FsCourseRedPacketLogMapper;
|
|
|
import com.fs.course.service.IFsCourseRedPacketLogService;
|
|
|
import com.fs.his.config.FsSysConfig;
|
|
|
-import com.fs.his.domain.FsUser;
|
|
|
-import com.fs.his.domain.FsUserWx;
|
|
|
+import com.fs.his.domain.*;
|
|
|
+import com.fs.his.mapper.FsStorePaymentErrorMapper;
|
|
|
import com.fs.his.mapper.FsUserWxMapper;
|
|
|
+import com.fs.his.param.FsPackageOrderCancelParam;
|
|
|
import com.fs.his.service.IFsUserService;
|
|
|
import com.fs.his.service.IFsUserWxService;
|
|
|
import com.fs.his.utils.ConfigUtil;
|
|
|
@@ -147,6 +148,8 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
|
|
|
|
|
|
@Autowired
|
|
|
private IFsStoreOrderScrmService storeOrderService;
|
|
|
+ @Autowired
|
|
|
+ private FsStorePaymentErrorMapper fsStorePaymentErrorMapper;
|
|
|
|
|
|
/**
|
|
|
* 查询支付明细
|
|
|
@@ -1101,18 +1104,54 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
|
|
|
return "同步完成";
|
|
|
}
|
|
|
|
|
|
+ long TWENTY_DAYS_IN_MILLIS = 1728000000L;
|
|
|
@Override
|
|
|
public void synchronizePayStatus() {
|
|
|
FsStorePaymentScrm queryParam = new FsStorePaymentScrm();
|
|
|
queryParam.setStatus(0);//未支付
|
|
|
- queryParam.setBeginTime(DateUtils.addDateDays(-1));
|
|
|
+// queryParam.setBeginTime(DateUtils.addDateDays(-1));
|
|
|
queryParam.setEndTime(DateUtils.getDate());
|
|
|
List<FsStorePaymentScrm> list = selectFsStorePaymentList(queryParam);
|
|
|
if (list != null && !list.isEmpty()) {
|
|
|
List<CompletableFuture<Void>> futures = new ArrayList<>();
|
|
|
for (FsStorePaymentScrm fsStorePayment : list) {
|
|
|
CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
|
|
|
- updateFsStorePaymentByDecryptForm(fsStorePayment.getPaymentId());
|
|
|
+ try {
|
|
|
+ updateFsStorePaymentByDecryptForm(fsStorePayment.getPaymentId());
|
|
|
+ //查询是否改为已支付
|
|
|
+ FsStorePaymentScrm finalPayment = fsStorePaymentMapper.selectFsStorePaymentById(fsStorePayment.getPaymentId());
|
|
|
+ try {
|
|
|
+ Date createTime = finalPayment.getCreateTime();
|
|
|
+ Date now = new Date();
|
|
|
+ long value = now.getTime() - createTime.getTime();
|
|
|
+ if(finalPayment.getStatus() == 0
|
|
|
+ && finalPayment.getBusinessType() == 2
|
|
|
+ && (value > TWENTY_DAYS_IN_MILLIS)
|
|
|
+ && finalPayment.getBusinessId() != null){
|
|
|
+ //套餐包超过20天取消订单
|
|
|
+ storeOrderService.cancelOrder(Long.valueOf(finalPayment.getBusinessId()));
|
|
|
+ }
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ logger.info("定时任务:同步支付状态超时取消订单失败,payment_id:{}",fsStorePayment.getPaymentId());
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ //添加失败记录
|
|
|
+ FsStorePaymentError fsStorePaymentError = new FsStorePaymentError();
|
|
|
+ fsStorePaymentError.setOrderFlowNo(fsStorePayment.getTradeNo());
|
|
|
+ String businessId = fsStorePayment.getBusinessId();
|
|
|
+ fsStorePaymentError.setBusinessType(fsStorePayment.getBusinessType());
|
|
|
+ fsStorePaymentError.setMsg(e.getMessage());
|
|
|
+ fsStorePaymentError.setStatus(0);
|
|
|
+ fsStorePaymentError.setCreateTime(new Date());
|
|
|
+ if (businessId != null && fsStorePayment.getBusinessType() == 2) {
|
|
|
+ fsStorePaymentError.setOrderId(Long.valueOf(businessId));
|
|
|
+ FsStoreOrderScrm fsStoreOrder = storeOrderService.selectFsStoreOrderById(Long.valueOf(businessId));
|
|
|
+ if (fsStoreOrder != null) {
|
|
|
+ fsStorePaymentError.setOrderNo(fsStoreOrder.getOrderCode());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ fsStorePaymentErrorMapper.insertFsStorePaymentError(fsStorePaymentError);
|
|
|
+ }
|
|
|
logger.info("定时任务:同步支付状态,payment_id:{}",fsStorePayment.getPaymentId());
|
|
|
});
|
|
|
futures.add(future);
|