package com.sunxung.factoring.web.biddingManagement;

import com.sunxung.factoring.component.util.ConstantUtil;
import com.sunxung.factoring.component.util.ThreadLocalUtil;
import com.sunxung.factoring.entity.ResponseJson;
import com.sunxung.factoring.entity.biddingManagement.*;
import com.sunxung.factoring.service.biddingManagement.*;
import com.sunxung.factoring.service.project.IProjectInformationService;
import com.sunxung.factoring.service.sys.flowable.FlowableService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @Description 招投标管理controller
 * @Author Yafan Wang
 * @Date 2023/12/25 19:57
 */
@RestController
@RequestMapping("/biddingManagement")
public class BiddingManagementController {

    @Autowired
    private IBiddingTemplateReviewService biddingTemplateReviewService;
    @Autowired
    private IBiddingGuaranteeMethodService biddingGuaranteeMethodService;
    @Autowired
    private FlowableService flowableService;
    @Autowired
    private IBiddingAwardConfirmService biddingAwardConfirmService;
    @Autowired
    private IBiddingBondCollectionConfirmationService biddingBondCollectionConfirmationService;
    @Autowired
    private IBiddingRefundDepositConfirmationService biddingRefundDepositConfirmationService;


    @RequestMapping("/templateReview")
    public ResponseJson templateReview(@RequestBody BiddingTemplateReview biddingTemplateReview){
        flowableService.claimTask(biddingTemplateReview.getTaskId(), ThreadLocalUtil.getUserId(), ConstantUtil.LEGAL_SPECIALIST);
        biddingTemplateReviewService.add(biddingTemplateReview);
        return new ResponseJson("操作成功！");
    }

    /**
     * 保证方式确认
     * @param biddingGuaranteeMethod
     * @return
     */
    @RequestMapping("/guaranteeMethod/doAdd")
    public ResponseJson templateReview(@RequestBody BiddingGuaranteeMethod biddingGuaranteeMethod){
        biddingGuaranteeMethodService.add(biddingGuaranteeMethod);
        return new ResponseJson("操作成功！");
    }

    /**
     * 中标确认
     * @param biddingAwardConfirm
     * @return
     */
    @RequestMapping("/bondCollectionConfirm/doAdd")
    public ResponseJson templateReview(@RequestBody BiddingAwardConfirm biddingAwardConfirm){
        biddingAwardConfirmService.add(biddingAwardConfirm);
        return new ResponseJson("操作成功！");
    }

    /**
     * 保证金收款确认
     * @param biddingBondCollectionConfirmation
     * @return
     */
    @RequestMapping("/awardConfirm/doAdd")
    public ResponseJson templateReview(@RequestBody BiddingBondCollectionConfirmation biddingBondCollectionConfirmation){
        flowableService.claimTask(biddingBondCollectionConfirmation.getTaskId(),ThreadLocalUtil.getUserId(),ConstantUtil.ACCOUNTANT);
        biddingBondCollectionConfirmationService.add(biddingBondCollectionConfirmation);
        return new ResponseJson("操作成功！");
    }

    /**
     * 保证金退款确认
     * @param biddingRefundDepositConfirmation
     * @return
     */
    @RequestMapping("refundDepositConfirmation/doAdd")
    public ResponseJson templateReview(@RequestBody BiddingRefundDepositConfirmation biddingRefundDepositConfirmation){
//        flowableService.claimTask(biddingRefundDepositConfirmation.getTaskId(),ThreadLocalUtil.getUserId(),ConstantUtil.ACCOUNTANT);
        biddingRefundDepositConfirmationService.add(biddingRefundDepositConfirmation);
        return new ResponseJson("操作成功！");
    }

}
