|
|
|
@@ -3,6 +3,7 @@ package com.iformall.schedule; |
|
|
|
import com.iformall.domain.po.WxAppinfo; |
|
|
|
import com.iformall.domain.po.WxPayAccount; |
|
|
|
import com.iformall.domain.po.base.TenantEntity; |
|
|
|
import com.iformall.domain.po.tt.TtOrder; |
|
|
|
import com.iformall.enums.*; |
|
|
|
import com.iformall.service.WxAppinfoService; |
|
|
|
import com.iformall.service.WxPayAccountService; |
|
|
|
@@ -16,7 +17,9 @@ import org.springframework.scheduling.annotation.Scheduled; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
import java.util.Date; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
@Component |
|
|
|
public class TtOrderExpiringSchedule { |
|
|
|
@@ -33,31 +36,26 @@ public class TtOrderExpiringSchedule { |
|
|
|
private TtOrderService ttOrderService; |
|
|
|
|
|
|
|
|
|
|
|
private TenantEntity getTenantInfo() { |
|
|
|
TenantEntity tenantEntity = new TenantEntity() ; |
|
|
|
tenantEntity.setTenantId("1"); |
|
|
|
return tenantEntity; |
|
|
|
} |
|
|
|
|
|
|
|
@Scheduled(cron = "0 */10 * * * *?") // 每10分钟检查一次 |
|
|
|
public void orderExpireSchedule() { |
|
|
|
Date now = new Date(); |
|
|
|
Date expireDate = new Date(now.getTime() - Constant.PRESS_TIME_OUT ); |
|
|
|
List<Long> idList = ttOrderService.findExpireIdList(expireDate); |
|
|
|
if(idList != null && idList.size() > 0){ |
|
|
|
|
|
|
|
WxAppinfo cAppInfo = wxAppinfoService.getCAppInfo(getTenantInfo(), EnumPayWay.PAY_WAY_TT); |
|
|
|
if(cAppInfo == null){ |
|
|
|
return; |
|
|
|
} |
|
|
|
WxPayAccount payAccout = payAccountService.getById(cAppInfo.getId()); |
|
|
|
if(payAccout == null){ |
|
|
|
return; |
|
|
|
List<TtOrder> orderList = ttOrderService.findExpireIdList(expireDate); |
|
|
|
if(orderList != null && orderList.size() > 0){ |
|
|
|
Map<String, WxAppinfo> wxAppinfoMap = new HashMap<>(); |
|
|
|
Map<String, WxPayAccount> wxPayAccountMap = new HashMap<>(); |
|
|
|
WxAppinfo appQ = new WxAppinfo(); |
|
|
|
appQ.setType(EnumAppType.C.getCode()); |
|
|
|
appQ.setPlat(EnumPayWay.PAY_WAY_TT.getCode()); |
|
|
|
List<WxAppinfo> wxAppinfoList = wxAppinfoService.getList(appQ); |
|
|
|
for (WxAppinfo wxAppinfo:wxAppinfoList) { |
|
|
|
wxAppinfoMap.put(wxAppinfo.getFinalTenantId(),wxAppinfo);//一个集团一个小程序 |
|
|
|
wxPayAccountMap.put(wxAppinfo.getFinalTenantId(),payAccountService.getById(wxAppinfo.getId())); |
|
|
|
} |
|
|
|
|
|
|
|
for (Long orderId:idList) { |
|
|
|
for (TtOrder order:orderList) { |
|
|
|
try { |
|
|
|
ttOrderService.updateOrderStatus(orderId,cAppInfo,payAccout); |
|
|
|
ttOrderService.updateOrderStatus(order.getId(),wxAppinfoMap.get(order.getFinalTenantId()),wxPayAccountMap.get(order.getFinalTenantId())); |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
|