package com.fjhx.sale.controller.claim;

import com.fjhx.file.utils.ObsFileUtil;
import com.fjhx.sale.entity.claim.po.Claim;
import com.fjhx.sale.entity.claim.po.ClaimContract;
import com.fjhx.sale.entity.claim.vo.ClaimContractVo;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.sale.entity.claim.vo.ClaimVo;
import com.fjhx.sale.entity.claim.dto.ClaimSelectDto;
import com.fjhx.sale.entity.claim.dto.ClaimDto;
import com.ruoyi.common.core.domain.BaseSelectDto;
import com.fjhx.sale.service.claim.ClaimService;
import org.springframework.beans.factory.annotation.Autowired;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;


/**
 * <p>
 * 到账认领 前端控制器
 * </p>
 *
 * @author
 * @since 2023-04-18
 */
@RestController
@RequestMapping("/claim")
public class ClaimController {

    @Autowired
    private ClaimService claimService;

    /**
     * 到账认领分页
     */
    @PostMapping("/page")
    public Page<ClaimVo> page(@RequestBody ClaimSelectDto dto) {
        return claimService.getPage(dto);
    }

    /**
     * 到账认领明细
     */
    @PostMapping("/detail")
    public ClaimVo detail(@RequestBody BaseSelectDto dto) {
        return claimService.detail(dto.getId());
    }

    /**
     * 到账认领新增
     */
    @PostMapping("/add")
    public void add(@RequestBody Claim claim) {
        claimService.add(claim);
    }

    /**
     * 到账认领编辑
     */
    @PostMapping("/edit")
    public void edit(@RequestBody ClaimDto claimDto) {
        claimService.edit(claimDto);
    }

    /**
     * 到账认领删除
     */
    @PostMapping("/delete")
    public void delete(@RequestBody BaseSelectDto dto) {
        claimService.delete(dto.getId());
    }

    /**
     * 到账认领明细
     */
    @GetMapping("/sumClaimMoney")
    public BigDecimal sumClaimMoney(@RequestParam("businessId") Long businessId) {
        return claimService.sumClaimMoney(businessId);
    }


    /**
     * 查询认领记录
     */
    @PostMapping("/claimRecord")
    public List<ClaimContractVo> claimRecord(@RequestBody Claim claim) {
        return claimService.claimRecord(claim.getBusinessId());
    }

    /**
     * 查询到账认领明细数据
     */
    @PostMapping("/claimDetail")
    public Map<String,Object> claimDetail(@RequestBody Claim claim) {
        return claimService.claimDetail(claim.getBusinessId());
    }

}
