package cn.pluss.platform.userRewardFlow.impl;

import cn.pluss.platform.entity.UserManageProfit;
import cn.pluss.platform.entity.UserRewardFlow;
import cn.pluss.platform.mapper.UserManageProfitMapper;
import cn.pluss.platform.mapper.UserRewardFlowMapper;
import cn.pluss.platform.userManageProfit.UserManageProfitService;
import cn.pluss.platform.userRewardFlow.UserRewardFlowService;
import cn.pluss.platform.util.DateUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

/**
 * 直营贝斯特管理奖流水表 服务实现类
 * </p>
 *
 * @author bzg
 * @since 2022-01-23
 */
@Service
public class UserRewardFlowServiceImpl extends ServiceImpl<UserRewardFlowMapper, UserRewardFlow> implements UserRewardFlowService {

    @Resource
    private UserManageProfitService userManageProfitService;

    @Override
    public void countManageProfit() {
        String date = DateUtils.toString(DateUtils.add(Calendar.DAY_OF_MONTH,new Date(),-1),DateUtils.DEFAULT_FORMAT);
        List<UserManageProfit> list = baseMapper.listManageProfit(date);
        if(!list.isEmpty()){
            userManageProfitService.saveBatch(list);
        }
    }
}
