package com.taoke.autopay.task;
|
|
import com.taoke.autopay.entity.KeyOrder;
|
import com.taoke.autopay.service.KeyOrderService;
|
import org.springframework.context.annotation.Configuration;
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import javax.annotation.Resource;
|
import java.util.Date;
|
import java.util.List;
|
|
@Configuration
|
@EnableScheduling
|
public class KeyOrderDistributeTask {
|
@Resource
|
private KeyOrderService keyOrderService;
|
|
@Scheduled(cron = "0/5 * * * * ? ")
|
private void distribute(){
|
try {
|
List<KeyOrder> results = keyOrderService.listNotDistributed(1, 20);
|
if (results != null) {
|
for (KeyOrder order : results) {
|
if (order.getDistributeClientUid() == null) {
|
continue;
|
}
|
Long uid = keyOrderService.getCanDistributeUid();
|
if (uid != null) {
|
KeyOrder orderUpdate = new KeyOrder();
|
orderUpdate.setId(order.getId());
|
orderUpdate.setDistributeClientUid(uid);
|
orderUpdate.setDistributeTime(new Date());
|
keyOrderService.update(orderUpdate);
|
}
|
}
|
}
|
}catch(Exception e){
|
|
}
|
}
|
|
}
|