package com.hzs.report.report.controller;

import com.hzs.common.core.web.controller.BaseController;
import com.hzs.common.core.web.domain.AjaxResult;
import com.hzs.common.security.utils.SecurityUtils;
import com.hzs.report.report.service.ICuMemberAchieveService;
import com.hzs.report.report.vo.CuMemberNewAddAchieveVO;
import lombok.extern.slf4j.Slf4j;
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;

/**
 * @Description:
 * @Author: jiang chao
 * @Time: 2023/9/19 9:20
 * @Classname: ApiCuMemberAchieveDisController
 * @PackageName: com.hzs.report.report.controller
 */
@Slf4j
@RestController
@RequestMapping("/api/achieve")
public class ApiCuMemberAchieveDisController extends BaseController {

    @Autowired
    private ICuMemberAchieveService cuMemberAchieveService;

    /**
     * 新增业绩
     *
     * @return
     */
    @GetMapping("/new-add-achieve-day")
    public AjaxResult selectNewAddAchieveByDay() {
        CuMemberNewAddAchieveVO newAddAchieveVO = CuMemberNewAddAchieveVO.builder().days(30L)
                .pkMember(SecurityUtils.getUserId()).pkCountry(SecurityUtils.getPkCountry()).build();
        return AjaxResult.success(cuMemberAchieveService.selectNewAddAchieveByDay(newAddAchieveVO));
    }

    /**
     * 安置业绩分布
     *
     * @return
     */
    @GetMapping("/az-achievement")
    public AjaxResult azAchievement() {
        return AjaxResult.success(cuMemberAchieveService.azAchievement(SecurityUtils.getUserId(), SecurityUtils.getPkCountry()));
    }

    /**
     * 推荐小区分布
     *
     * @return
     */
    @GetMapping("recommend-community")
    public AjaxResult recommendCommunity() {
        return AjaxResult.success(cuMemberAchieveService.recommendAchievement(SecurityUtils.getUserId(), SecurityUtils.getPkCountry()));
    }

    /**
     * 首购业绩分布
     *
     * @return
     */
    @GetMapping("/query-first-performance-pic")
    public AjaxResult queryFirstPerformancePic() {
        return AjaxResult.success(cuMemberAchieveService.firstPerformancePic(SecurityUtils.getUserId(), SecurityUtils.getPkCountry()));
    }

    /**
     * 复购业绩分布
     *
     * @return
     */
    @GetMapping("/query-repurchase-performance-pic")
    public AjaxResult queryRepurchasePerformancePic() {
        return AjaxResult.success(cuMemberAchieveService.queryRepurchasePerformancePic(SecurityUtils.getUserId(), SecurityUtils.getPkCountry()));
    }

}
