package com.fjhx.sale.controller.statement;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.sale.entity.commission.dto.CommissionDto;
import com.fjhx.sale.entity.contract.po.Contract;
import com.fjhx.sale.entity.statement.dto.ProfitSettlementDto;
import com.fjhx.sale.entity.statement.vo.ProfitSettlementVo;
import com.fjhx.sale.service.commission.CommissionService;
import com.fjhx.sale.service.contract.ContractService;
import com.fjhx.sale.service.statement.SaleStatementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/saleStatement")
public class SaleStatementController {

    @Autowired
    private SaleStatementService saleStatementService;

    @Autowired
    private ContractService contractService;

    @Autowired
    private CommissionService commissionService;

    /**
     * 利润结算表
     */
    @PostMapping("/getProfitSettlement")
    public Page<ProfitSettlementVo> getProfitSettlement(@RequestBody ProfitSettlementDto dto) {
        return saleStatementService.getProfitSettlement(dto);
    }

    /**
     * 编辑
     */
    @PostMapping("/update")
    public void update(@RequestBody Contract contract) {
        contractService.updateById(contract);
    }

    /**
     * 结算功能(添加业务提成表与业务提成规则表,修改合同表的结算状态)
     */
    @PostMapping("/settlement")
    public void settlement(@RequestBody CommissionDto commissionDto){
        commissionService.settlement(commissionDto);
    }

}
