package com.cool.store.controller.webb;


import com.cool.store.context.CurrentUserHolder;
import com.cool.store.context.LoginUserInfo;
import com.cool.store.request.AddSignFranchiseRequest;
import com.cool.store.request.AssignOperationConsultantRequest;
import com.cool.store.request.AuditApproveRequest;
import com.cool.store.request.SignFranchiseDecorationRequest;
import com.cool.store.response.AddSignFranchiseResponse;
import com.cool.store.response.ResponseResult;
import com.cool.store.service.SignFranchiseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(tags = "pc加盟合同签约")
@RestController
@RequestMapping("/pc/signFranchise")
public class PCSignFranchiseController {
    @Resource
    SignFranchiseService signFranchiseService;

    @ApiOperation("提交(更新)加盟合同签约")
    @PostMapping("/submitOrUpdate")
    public ResponseResult<Boolean> submitSignFranchise(@RequestBody @Validated AddSignFranchiseRequest request) {
        LoginUserInfo user = CurrentUserHolder.getUser();
        return signFranchiseService.submitSignFranchise(request,user);
    }

    @ApiOperation("重新提交加盟合同签约")
    @PostMapping("/reSubmitSignFranchise")
    public ResponseResult<Boolean> reSubmitSignFranchise(@RequestBody @Validated AddSignFranchiseRequest request) {
        LoginUserInfo user = CurrentUserHolder.getUser();
        return ResponseResult.success(signFranchiseService.reSubmitSignFranchise(request,user));
    }

    @ApiOperation("修改装修信息")
    @PostMapping("/decorationUpdate")
    public ResponseResult<Boolean> decorationUpdate(@RequestBody @Validated SignFranchiseDecorationRequest request) {
        return ResponseResult.success(signFranchiseService.decorationUpdate(request));
    }

    @ApiOperation("加盟合同签约审核")
    @PostMapping("/audit/result")
    public ResponseResult<Boolean> auditSignFranchise(@RequestBody @Validated AuditApproveRequest request) {
        LoginUserInfo user = CurrentUserHolder.getUser();
        return ResponseResult.success(signFranchiseService.auditApprove(request,user));
    }

    @ApiOperation("加盟合同签约财务审核")
    @PostMapping("/audit/finance")
    public ResponseResult<Boolean> financeAuditApprove(@RequestBody @Validated AuditApproveRequest request) {
        LoginUserInfo user = CurrentUserHolder.getUser();
        return ResponseResult.success(signFranchiseService.financeAuditApprove(request,user));
    }

    @ApiOperation("获取默认值")
    @GetMapping("/default/get")
    public ResponseResult<AddSignFranchiseResponse> getSignFranchise(@RequestParam("shopId") Long shopId) {
        return ResponseResult.success(signFranchiseService.getSignFranchise(shopId));
    }

    @ApiOperation("重新缴费(加盟合同阶段退回后)")
    @GetMapping("/rePay")
    public ResponseResult<Boolean> rePay(@RequestParam("shopId") Long shopId) {
        return ResponseResult.success(signFranchiseService.rePay(shopId));
    }

    @ApiOperation("回到缴费阶段")
    @PostMapping("/backPayFeeStage")
    public ResponseResult<Boolean> backPayFeeStage(@RequestBody @Validated AuditApproveRequest request) {
        return ResponseResult.success(signFranchiseService.backPayFeeStage(request, CurrentUserHolder.getUser()));
    }

    @ApiOperation("数据处理，全部设置为新签")
    @GetMapping("/dateHandle")
    public ResponseResult<Integer> dateHandle() {
        return ResponseResult.success(signFranchiseService.dateHandle());
    }


    @ApiOperation("分配运营顾问")
    @PostMapping("/assignOperationConsultant")
    public ResponseResult<Boolean> assignOperationConsultant(@RequestBody @Validated AssignOperationConsultantRequest request) {
        return ResponseResult.success(signFranchiseService.assignOperationConsultant(request));
    }


}
