package com.hzs.member.account.provider;

import com.hzs.common.core.domain.R;
import com.hzs.member.account.IMemberJobServiceApi;
import com.hzs.member.account.service.ICuMemberAccountDetailService;
import com.hzs.member.base.mapper.DeleteGarbageDataMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * 会员模块定时任务服务提供
 */
@Slf4j
@DubboService
public class IMemberJobServiceProvider implements IMemberJobServiceApi {

    @Autowired
    private ICuMemberAccountDetailService iCuMemberAccountDetailService;

    @Autowired
    private DeleteGarbageDataMapper deleteGarbageDataMapper;

    @Override
    public R insertAccountDetail() {
        try {
            iCuMemberAccountDetailService.insertAccountDetail();
        } catch (Exception e) {
            log.info("定时插入账户详情数据失败：", e);
            return R.fail(e.getMessage());
        }
        return R.ok();
    }

    @Override
    public R autoDeleteGarbageData() {
        deleteGarbageDataMapper.deleteMemberAwards(30);
        deleteGarbageDataMapper.deleteMemberLevel(30);
        deleteGarbageDataMapper.deleteMemberGrade(30);
        return R.ok();
    }

}
