package com.hzs.bonus.detail.controller.manage;

import com.hzs.bonus.detail.service.ICuMemberAssessService;
import com.hzs.common.core.annotation.Log;
import com.hzs.common.core.enums.EOperationMethod;
import com.hzs.common.core.enums.EOperationModule;
import com.hzs.common.core.utils.DateUtils;
import com.hzs.common.core.web.controller.BaseController;
import com.hzs.common.core.web.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/manage/assess")
public class CuMemberAssessController extends BaseController {

    private ICuMemberAssessService cuMemberAssessService;

    @Autowired
    public void setCuMemberAssessService(ICuMemberAssessService cuMemberAssessService) {
        this.cuMemberAssessService = cuMemberAssessService;
    }

    /**
     * 考核（复购考核、分红考核）
     * 考核默认考核当月
     * @return AjaxResult
     */
    @GetMapping("/examine")
    @Log(module = EOperationModule.CU_MEMBER_ASSESSMENT, method = EOperationMethod.UPDATE)
    public AjaxResult calculationCuMemberAssess(String settleDate) {
        cuMemberAssessService.calculationCuMemberAssess(DateUtils.parseStringToDate(settleDate));
        return AjaxResult.success();
    }

    /**
     * 重算考核（复购考核、分红考核）
     * 考核默认考核当月
     * @return AjaxResult
     */
    @GetMapping("/retry-examine")
    @Log(module = EOperationModule.CU_MEMBER_ASSESSMENT, method = EOperationMethod.UPDATE)
    public AjaxResult retryCalculationCuMemberAssess(String settleDate) {
        cuMemberAssessService.retryCalculationAssess(DateUtils.currentMonthFirstDate(DateUtils.parseStringToDate(settleDate)), Boolean.FALSE);
        return AjaxResult.success();
    }
}
