package com.cool.store.controller.webb;

import com.cool.store.context.CurrentUserHolder;
import com.cool.store.dao.LineInfoDAO;
import com.cool.store.entity.LineInfoDO;
import com.cool.store.enums.WorkflowSubStageEnum;
import com.cool.store.request.AuditCloseRequest;
import com.cool.store.request.AuditPassRequest;
import com.cool.store.request.AuditRejectRequest;
import com.cool.store.response.ResponseResult;
import com.cool.store.service.BankService;
import com.cool.store.service.impl.CommonService;
import com.cool.store.service.impl.DefaultLineFlowService;
import com.cool.store.service.impl.LineFlowService;
import com.cool.store.service.impl.LineInterviewServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.ApplicationContext;
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;

import javax.annotation.Resource;

/**
 * @author zhangchenbiao
 * @FileName: LineOperationController
 * @Description:
 * @date 2024-03-20 14:20
 */
@Api(tags = "线索审核")
@RestController
@RequestMapping({"pc/audit"})
public class LineAuditController {

    @Resource
    private CommonService commonService;
    @Resource(name = "defaultLineFlowService")
    private LineFlowService lineFlowService;

    @Resource
    BankService bankService;

    @ApiOperation("审核通过")
    @PostMapping("/pass")
    public ResponseResult<Boolean> auditPass(@RequestBody AuditPassRequest request){
        return ResponseResult.success(commonService.getLineFlowService(request.getWorkflowSubStage()).auditPass(request,CurrentUserHolder.getUserId()));
    }

    @ApiOperation("审核拒绝")
    @PostMapping("/reject")
    public ResponseResult<Boolean> auditReject(@RequestBody AuditRejectRequest request){
        return ResponseResult.success(commonService.getLineFlowService(request.getWorkflowSubStage()).auditReject(request,CurrentUserHolder.getUserId()));
    }

    @ApiOperation("重新缴费")
    @PostMapping("/repayment")
    public ResponseResult<Boolean> repayment(@RequestBody AuditRejectRequest request){
        return ResponseResult.success(bankService.repayment(request));
    }

    @ApiOperation("结束跟进")
    @PostMapping("/close")
    public ResponseResult<Boolean> auditClose(@RequestBody AuditCloseRequest request){
        return ResponseResult.success(lineFlowService.auditClose(request, CurrentUserHolder.getUser()));
    }

}
