package com.jwipc.tender.controller.pc;

import com.jwipc.page.PageView;
import com.jwipc.tender.constant.ModuleConst;
import com.jwipc.tender.dto.SubmitBargainingDTO;
import com.jwipc.tender.dto.SubmitQuotationDTO;
import com.jwipc.tender.logic.BidLogic;
import com.jwipc.tender.model.query.BidQuery;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * <p> 投标管理相关接口</p>
 *
 * @author ZhangJie
 * @version 1.0
 * @since JDK 1.8
 */
@RestController
@RequiredArgsConstructor
@Slf4j
@RequestMapping(ModuleConst.MODULE_ROOT + "/bid/rest")
public class TenderBidRestController {
    private final BidLogic bidLogic;

    /**
     * 待确认投标 列表
     *
     * @param query 查询参数
     * @return
     */
    @GetMapping(value = "confirmJoinList")
    public PageView confirmJoinList(BidQuery query) {
        return bidLogic.getConfirmJoinList(query);
    }

    /**
     * 待缴纳保证金 列表
     *
     * @param query 查询参数
     * @return
     */
    @GetMapping(value = "/securityDepositList")
    public PageView securityDepositList(BidQuery query) {
        return bidLogic.getSecurityDepositList(query);
    }

    /**
     * 投标待报价 列表页面
     *
     * @return
     */
    @GetMapping("toBeQuotedList")
    public PageView toBeQuotedList(BidQuery query) {
        return bidLogic.getToBeQuotedList(query);
    }

    /**
     * 投标报价历史 列表页面
     *
     * @return
     */
    @GetMapping("historyList")
    public PageView historyList(BidQuery query) {
        return bidLogic.getHistoryList(query);
    }

    /**
     * 确认参加
     *
     * @param id     投标单id
     * @param status 是否参加
     * @param remark 不参加原因
     * @return
     */
    @PostMapping("submitBidStatus")
    public ResponseEntity submitBidStatus(Long id, Integer status, String remark) {
        bidLogic.submitBidStatus(id, status, remark);
        return ResponseEntity.ok().build();
    }

    /**
     * 供应商报价 接口
     *
     * @param submitQuotationDTO 报价数据
     * @return
     */
    @PostMapping("submitQuotation")
    public ResponseEntity submitQuotation(@RequestBody SubmitQuotationDTO submitQuotationDTO) {
        bidLogic.submitQuotation(submitQuotationDTO);
        return ResponseEntity.ok().build();
    }

    @PostMapping("submitBargaining")
    public ResponseEntity submitBargaining(@RequestBody SubmitBargainingDTO submitQuotationDTO) {
        bidLogic.submitBargaining(submitQuotationDTO);
        return ResponseEntity.ok().build();
    }

    /**
     * 保证金凭证上传接口
     *
     * @param id 投标单id
     * @param id 文件id
     * @return
     */
    @PostMapping("submitDeposit")
    public ResponseEntity submitDeposit(Long id, Long fileId) {
        bidLogic.submitDeposit(id, fileId);
        return ResponseEntity.ok().build();
    }

    /**
     * 投标单信息
     *
     * @param id 投标单id
     * @return
     */
    @GetMapping("getDetail")
    public ResponseEntity getDetail(Long id) {
        return ResponseEntity.ok(bidLogic.getDetail(id));
    }


}
