package com.hai.schedule;

import com.alibaba.fastjson.JSONObject;
import com.hai.entity.HighChildOrder;
import com.hai.entity.HighGoldRec;
import com.hai.entity.HighOrder;
import com.hai.service.BsIntegralRebateService;
import com.hai.service.HighGoldRecService;
import com.hai.service.HighUserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Scheduled;

import javax.annotation.Resource;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Configuration
public class HighIntegralSchedule {

    private static final Logger log = LoggerFactory.getLogger(HighIntegralSchedule.class);


    @Resource
    private HighGoldRecService highGoldRecService;

    @Resource
    private HighUserService highUserService;

    @Scheduled(cron="0 0/1 * * * ?")   //每1分钟执行一次
    public void integralRebateOrder() {
       List<HighGoldRec> list = highGoldRecService.selectByExpiringSoonByAll(365);

       for (HighGoldRec goldRec : list) {

           highUserService.goldHandle(goldRec.getUserId(), goldRec.getGold(), 2, 5, goldRec.getResId() , "积分过期" );

           goldRec.setStatus(9);
           goldRec.setUpdateTime(new Date());
           highGoldRecService.updateGoldRec(goldRec);


       }
    }

}
