package com.fs.company.controller.live;

import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.core.page.TableDataInfo;
import com.fs.company.domain.CompanyUser;
import com.fs.core.security.SecurityUtils;
import com.fs.live.service.ILiveUserFirstEntryService;
import com.fs.live.vo.LiveUserEntryDetail;
import com.fs.live.vo.LiveUserFirstProfit;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 业绩归属控制类Controller
 *
 * @author fs
 * @date 2025-09-08
 */
@RestController
@RequestMapping("/live/liveProfit")
public class LiveProfitController extends BaseController {

    @Autowired
    private ILiveUserFirstEntryService liveUserFirstEntryService;

    @GetMapping("/list")
    public TableDataInfo list(LiveUserFirstProfit liveUserFirstProfit) {
        CompanyUser user = SecurityUtils.getLoginUser().getUser();
//        liveUserFirstProfit.setCompanyUserId(user.getUserId());
        liveUserFirstProfit.setCompanyId(user.getCompanyId());
        startPage();
        List<LiveUserFirstProfit> list = liveUserFirstEntryService.selectLiveProfitList(liveUserFirstProfit);
        return getDataTable(list);
    }

    /**
     * 查询直播间用户进入详情
     *
     * @param liveId 直播间ID
     * @param companyUserId 销售ID
     * @return 用户进入详情列表
     */
    @GetMapping("/detail")
    public AjaxResult detail(@RequestParam Long liveId, @RequestParam Long companyUserId) {
        List<LiveUserEntryDetail> list = liveUserFirstEntryService.selectLiveUserEntryDetailList(liveId, companyUserId);
        return AjaxResult.success(list);
    }

}
