package com.dayou.controller;

import com.dayou.dto.CommissionDeclareDTO;
import com.dayou.dto.WorkNodeCommit;
import com.dayou.vo.CommissionDeclareDetailVO;
import com.dayou.vo.CommissionDeclareVO;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.web.bind.annotation.RestController;
import com.dayou.controller.BaseController;
import com.dayou.service.ICommissionDeclareService;
import com.dayou.entity.CommissionDeclare;
import com.dayou.common.RestResponse;
import org.springframework.web.bind.annotation.*;
import com.dayou.utils.ConvertUtil;
import com.dayou.utils.HttpKit;
import com.dayou.exception.ErrorCode;
import java.util.Date;
import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.http.MediaType;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.Valid;

/**
 * 提成申报
 *
 * @author wucl
 * @since 2024-05-15
 */
@RestController
@RequestMapping("commissionDeclare")
@Slf4j
public class CommissionDeclareController extends BaseController {
    @Autowired
    private ICommissionDeclareService commissionDeclareService;

    /**
    * 大中型市场人员提成申报列表
    */
    @GetMapping("/major/market")
    public RestResponse<Page<CommissionDeclareVO>> majorMarketDeclarePage(CommissionDeclareVO commissionDeclare, Page page){
        Page<CommissionDeclareVO> pages=commissionDeclareService.majorMarketDeclarePage(page,commissionDeclare);
        return RestResponse.data(pages);
    }

    /**
     * 大中型评估人员提成申报列表
     */
    @GetMapping("/major/evaluate")
    public RestResponse<Page<CommissionDeclareVO>> majorEvaluateDeclarePage(CommissionDeclareVO commissionDeclare, Page page){
        Page<CommissionDeclareVO> pages=commissionDeclareService.majorEvaluateDeclarePage(page,commissionDeclare);
        return RestResponse.data(pages);
    }


    /**
     * 大中型提成申报
     * @param declareDTO
     * @return
     */
    @PostMapping("/major")
    public synchronized RestResponse<Boolean> commissionDeclare(@RequestBody @Valid CommissionDeclareDTO declareDTO){
        Boolean ret = commissionDeclareService.commissionDeclare(declareDTO);
        return RestResponse.data(ret);
    }

    /**
     * 提成申报删除
     */
    @DeleteMapping("/{id}")
    public RestResponse<Boolean> delete(@PathVariable Long id) {
        Boolean ret = commissionDeclareService.delete(id);
        return RestResponse.data(ret);
    }

    /**
     * 申报详情
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public RestResponse<CommissionDeclareDetailVO> detail(@PathVariable("id") Long id){
        CommissionDeclareDetailVO detail = commissionDeclareService.detail(id);
        return RestResponse.data(detail);
    }

}

