package com.czg.task;

import com.czg.account.entity.ShopUser;
import com.czg.account.service.ShopUserService;
import com.czg.market.service.MkBirthdayGiftService;
import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Component;

/**
 * 生日有礼奖励发放
 *
 * @author ww
 * @description
 */
@Slf4j
@Component
public class BirthdayGiftTask {
    @Resource
    private MkBirthdayGiftService birthdayGiftService;
    @DubboReference
    private ShopUserService shopUserService;

    /**
     * 生日有礼奖励发放
     * AAMarketTasks 统一调用位置
     */
//    @Scheduled(cron = "0 0 0 * * ?")
    public void deliver() {
        birthdayGiftService.deliver();
    }

    public void remind() {
        shopUserService.update(new ShopUser().setBirthDayRemind(0), new QueryWrapper()
                .isNotNull(ShopUser::getBirthDay).eq(ShopUser::getBirthDayRemind, 1));
    }
}
