package com.cool.store.controller.webc;

import com.cool.store.context.CurrentUserHolder;
import com.cool.store.context.PartnerUserHolder;
import com.cool.store.dto.decoration.ConstructionScheduleDTO;
import com.cool.store.dto.decoration.DecorationModelDTO;
import com.cool.store.dto.decoration.ThreeAcceptanceDTO;
import com.cool.store.entity.ShopAuditInfoDO;
import com.cool.store.request.DecorationDesignRequest;
import com.cool.store.request.LinePaySubmitRequest;
import com.cool.store.request.ThreeAcceptanceCheckRequest;
import com.cool.store.request.ThreeAcceptanceRequest;
import com.cool.store.response.ResponseResult;

import com.cool.store.response.ThreeSignResponse;
import com.cool.store.service.AssessmentTemplateService;
import com.cool.store.service.DecorationService;
import com.cool.store.service.SeeAcceptanceService;
import com.cool.store.vo.*;
import com.cool.store.vo.Fitment.DecorationStageVO;

import com.cool.store.vo.Fitment.DesignInfoVo;
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/29/下午2:46
 * @Version 1.0
 * @注释:
 */
@RestController
@RequestMapping("/mini/decoration")
@Api(tags = "mini装修阶段")
@Slf4j
public class MiniDecorationController {
    @Resource
    private DecorationService decorationService;
    @Resource
    private AssessmentTemplateService assessmentTemplateService;
    @Resource
    private SeeAcceptanceService seeAcceptanceService;
    @ApiOperation("获取设计阶段子阶段信息")
    @GetMapping("/designSub")
    public ResponseResult<DesignInfoVo> getDesign(@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)) ;
    }
    @PostMapping("/submitDecorationModel")
    @ApiOperation("提交装修款")
    public ResponseResult<Boolean> submitDecorationModel(@RequestBody LinePaySubmitRequest linePaySubmitRequest){
        return ResponseResult.success(decorationService.submitDecorationModel(linePaySubmitRequest, PartnerUserHolder.getUser()));
    }
    @ApiOperation("获取装修款信息,和二维码")
    @GetMapping("/getDecorationModel")
    public ResponseResult<DecorationModelDTO> getDecorationModel(@RequestParam Long shopId){
        return ResponseResult.success(decorationService.decorationModel(shopId)) ;
    }
    @ApiOperation("获取装修款阶段信息")
    @GetMapping("/getDecorationModeStage")
    public ResponseResult<DecorationStageVO> getDecorationModeStage(@RequestParam Long shopId){
        return ResponseResult.success(decorationService.getDecorationGoldStage(shopId)) ;
    }

    @ApiOperation("获取装修款详情信息")
    @GetMapping("/getDecorationModelInfo")
    public ResponseResult<LinePayVO> getDecorationModelInfo(@RequestParam Long shopId){
        PartnerUserInfoVO user = PartnerUserHolder.getUser();
        return ResponseResult.success(decorationService.getDecorationModel(shopId,user));
    }
    @ApiOperation("获取三方验收模板检查项")
    @GetMapping("/getChecks")
    public ResponseResult<List<AssessmentTemplateVO>> getChecks(@RequestParam Integer type){
       return ResponseResult.success(assessmentTemplateService.listByType(type));
    }
    @ApiOperation("提交三方验收检查项")
    @PostMapping("/submitThreeChecks")
    public ResponseResult<Boolean> submitThreeChecks(@RequestBody ThreeAcceptanceCheckRequest request){
        return ResponseResult.success(decorationService.submitThreeCheck(request));
    }
    @ApiOperation("获取三方验收检查项")
    @GetMapping("/getAcceptanceChecks")
    public ResponseResult<ThreeAcceptanceCheckRequest> getAcceptanceChecks(@RequestParam Long shopId){
        return ResponseResult.success(decorationService.getThreeChecks(shopId));
    }
    @ApiOperation("提交三方验收签字")
    @PostMapping("/submitThreeAcceptanceSign")
    public ResponseResult<Boolean> submitThreeAcceptance(@RequestBody ThreeAcceptanceRequest request){
        return ResponseResult.success(decorationService.miniSubmitAcceptanceSign(request));
    }
    @ApiOperation("查看三方验收签字")
    @GetMapping("/getThreeSign")
    public ResponseResult<ThreeSignResponse> getThreeAcceptance(@RequestParam Long shopId){
        return ResponseResult.success(decorationService.getThreeAcceptanceSign(shopId));
    }
    @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("查询设计方案")
    @GetMapping("/getDecorationDesign")
    public ResponseResult<DecorationDesignVO> getDecorationDesign(@RequestParam Long shopId){
        return ResponseResult.success(decorationService.getDecorationDesign(shopId));
    }

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

    @ApiOperation("加盟商确定设计方案")
    @PostMapping("/confirmDesign")
    public ResponseResult<Boolean> confirmDesign(@RequestBody DecorationDesignRequest request){
        return ResponseResult.success(decorationService.confirmDesign(request,CurrentUserHolder.getUser()));
    }


}
