package com.cool.store.controller.webb;

import com.cool.store.context.CurrentUserHolder;
import com.cool.store.context.LoginUserInfo;

import com.cool.store.dto.decoration.ConstructionScheduleDTO;
import com.cool.store.entity.ShopAuditInfoDO;
import com.cool.store.request.*;
import com.cool.store.response.ResponseResult;
import com.cool.store.response.ThreeSignResponse;
import com.cool.store.service.DecorationService;
import com.cool.store.service.PreparationService;
import com.cool.store.service.SeeAcceptanceService;
import com.cool.store.vo.ConstructionDataVO;
import com.cool.store.vo.DecorationDesignVO;
import com.cool.store.vo.Fitment.DesignInfoVo;
import com.cool.store.vo.LinePayVO;

import com.cool.store.vo.fitmentCheckVO;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Auther: WangShuo
 * @Date: 2024/04/28/下午4:19
 * @Version 1.0
 * @注释:
 */
@RestController
@RequestMapping("/pc/decoration")
@Api(tags = "PC装修阶段")
@Slf4j
public class PCDecorationController {
    @Resource
    private DecorationService decorationService;
    @Resource
    private PreparationService preparationService;
    @Resource
    private SeeAcceptanceService seeAcceptanceService;
    @ApiOperation("获取新店装修flush")
    @GetMapping("/flush")
    public ResponseResult<Boolean> getFitmentSub(@RequestParam Long shopId) {
        return ResponseResult.success(preparationService.decorationFlush(shopId));
    }
    @ApiOperation("获取设计子阶段信息")
    @GetMapping("/designSub")
    public ResponseResult<DesignInfoVo> getDesignSub(@RequestParam Long shopId){
        return ResponseResult.success( decorationService.DesignInfo(shopId)) ;
    }

    @ApiOperation("获取施工子阶段信息")
    @GetMapping("/getConstructionSub")
    public  ResponseResult<List<ConstructionScheduleDTO>> getConstructionSub(@RequestParam Long shopId){
        return ResponseResult.success(decorationService.getConstruction(shopId)) ;
    }
    @ApiOperation("获取装修款信息")
    @GetMapping("/getDecorationModelInfo")
    public ResponseResult<LinePayVO> getDecorationModelInfo(@RequestParam Long shopId){
        return ResponseResult.success(decorationService.getDecorationModel(shopId,null));
    }
    @ApiOperation("获取验收列表：三方验收1200待预约，1210 待验收，1220验收中，1230已验收；视觉验收：1300待验收,1310验收不通过,1320验收通过")
    @PostMapping("/getAcceptanceList")
    public ResponseResult<PageInfo<fitmentCheckVO>> getAcceptanceList(@RequestBody AcceptanceListRequest request){
        LoginUserInfo user = CurrentUserHolder.getUser();
        return ResponseResult.success(decorationService.getFitmentAcceptanceList(request,user));
    }
    @ApiOperation("获取三方验收列表详情")
    @GetMapping("/getAcceptanceDetail")
    public ResponseResult<fitmentCheckVO> getAcceptanceDetail(@RequestParam("shopId") Long shopId){
        LoginUserInfo user = CurrentUserHolder.getUser();
        return ResponseResult.success(decorationService.getAcceptanceDetail(shopId,user));
    }
    @ApiOperation("预约三方验收")
    @PostMapping("/bookingAcceptance")
    public ResponseResult<Boolean> submitBookingAcceptance(@RequestBody BookingAcceptanceRequest response){
        LoginUserInfo user = CurrentUserHolder.getUser();
        return ResponseResult.success(decorationService.bookingAcceptance(response,user));
    }
    @ApiOperation("获取三方验收检查项")
    @GetMapping("/getAcceptanceChecks")
    public ResponseResult<ThreeAcceptanceCheckRequest> getAcceptanceChecks(@RequestParam Long shopId){
        return ResponseResult.success(decorationService.getThreeChecks(shopId));
    }
    @ApiOperation("提交三方验收签字")
    @PostMapping("/submitThreeAcceptanceSign")
    public ResponseResult<Boolean> submitThreeAcceptanceSign(@RequestBody ThreeAcceptanceRequest request){
        return ResponseResult.success(decorationService.pcSubmitAcceptanceSign(request));
    }
    @ApiOperation("查看三方验收签字")
    @GetMapping("/getThreeSign")
    public ResponseResult<ThreeSignResponse> getThreeAcceptance(@RequestParam Long shopId){
        return ResponseResult.success(decorationService.getThreeAcceptanceSign(shopId));
    }
    @ApiOperation("获取视觉验收撤场数据")
    @GetMapping("/getSeeAcceptanceWithdrawal")
    public ResponseResult<ConstructionScheduleDTO> getSeeAcceptanceWithdrawal(@RequestParam Long shopId){
        return ResponseResult.success(seeAcceptanceService.getWithdrawal(shopId));
    }
    @ApiOperation("视觉验收列表")
    @PostMapping("/getSeeAcceptanceList")
    public ResponseResult< PageInfo<fitmentCheckVO>> getSeeAcceptanceList(@RequestBody AcceptanceListRequest request){
        LoginUserInfo user = CurrentUserHolder.getUser();
        return ResponseResult.success(seeAcceptanceService.getAcceptanceList(request,user));
    }
    @ApiOperation("获取撤场数据")
    @GetMapping("/getWithdrawal")
    public ResponseResult<ConstructionScheduleDTO> getWithdrawal(@RequestParam Long shopId){
        return ResponseResult.success(seeAcceptanceService.getWithdrawal(shopId));
    }
    @ApiOperation("获取视觉验收审核数据")
    @GetMapping("/getSeeAuditInfo")
    public ResponseResult< List<ShopAuditInfoDO> > getAuditInfo(@RequestParam Long shopId){
        return ResponseResult.success(seeAcceptanceService.getAuditInfo(shopId));
    }
    @ApiOperation("验收视觉验收")
    @PostMapping("/auditSee")
    public ResponseResult<Boolean> auditSee(@RequestBody SeeAcceptanceRequest request){
        LoginUserInfo user = CurrentUserHolder.getUser();
        return ResponseResult.success(seeAcceptanceService.auditSeeAcceptance(request,user));
    }


    @ApiOperation("提交设计方案")
    @PostMapping("/submitDecorationDesign")
    public ResponseResult<Boolean> submitDecorationDesign(@RequestBody DecorationDesignRequest request){
        return ResponseResult.success(decorationService.submitDecorationDesign(request,CurrentUserHolder.getUser()));
    }

    @ApiOperation("查询设计方案")
    @GetMapping("/getDecorationDesign")
    public ResponseResult<DecorationDesignVO> getDecorationDesign(@RequestParam Long shopId){
        return ResponseResult.success(decorationService.getDecorationDesign(shopId));
    }

    @ApiOperation("提交施工方案")
    @PostMapping("/submitConstructionData")
    public ResponseResult<Boolean> submitConstructionData(@RequestBody ConstructionRequest request){
        return ResponseResult.success(decorationService.submitConstructionData(request,CurrentUserHolder.getUser()));
    }

    @ApiOperation("查询施工方案")
    @GetMapping("/getConstructionData")
    public ResponseResult<ConstructionDataVO> getConstructionData(@RequestParam Long shopId){
        return ResponseResult.success(decorationService.getConstructionData(shopId));
    }

    @ApiOperation("装修阶段完成")
    @PostMapping("/confirmComplete")
    public ResponseResult<Boolean> confirmComplete(@RequestBody DecorationDesignRequest request){
        return ResponseResult.success(decorationService.confirmComplete(request.getShopId(),CurrentUserHolder.getUser()));
    }
}
