package shop.alien.store.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.*;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import shop.alien.entity.result.R;
import shop.alien.entity.store.vo.ExpertGoodsTypeVo;
import shop.alien.entity.store.vo.LifeUserExpertOrderVo;
import shop.alien.entity.store.vo.LifeUserExpertVo;
import shop.alien.store.service.LifeUserExpertService;

import java.util.List;

@Api(tags = {"平台-达人管理"})
@Slf4j
@RestController
@CrossOrigin
@RequiredArgsConstructor
@RequestMapping("/lifeUserExpert")
public class LifeUserExpertController {

    private final LifeUserExpertService lifeUserExpertService;

    @ApiOperation("达人列表")
    @ApiOperationSupport(order = 1)
    @ApiImplicitParams({@ApiImplicitParam(name = "page", value = "分页页数", dataType = "Integer", paramType = "query", required = true),
            @ApiImplicitParam(name = "size", value = "分页条数", dataType = "Integer", paramType = "query", required = true),
            @ApiImplicitParam(name = "userName", value = "姓名", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "exportCode", value = "达人码", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "userId", value = "用户id", dataType = "String", paramType = "query")})
    @GetMapping("/getUserExpertList")
    public R<IPage<LifeUserExpertVo>> getUserExpertList(Integer page, Integer size, String userName, String expertCode, Integer userId) {
        log.info("LifeUserExpertController.getUserExpertList?page={},size={},userName={},phone={},userId={}", page, size, userName, expertCode, userId);
        return R.data(lifeUserExpertService.getUserExpertList(page, size, userName, expertCode, userId));
    }

    @ApiOperation("订单列表")
    @ApiOperationSupport(order = 2)
    @ApiImplicitParams({@ApiImplicitParam(name = "page", value = "分页页数", dataType = "Integer", paramType = "query", required = true),
            @ApiImplicitParam(name = "size", value = "分页条数", dataType = "Integer", paramType = "query", required = true),
            @ApiImplicitParam(name = "expertId", value = "达人id", dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "orderNo", value = "订单编号", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "storeName", value = "商家名称", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "storeName", value = "商家id", dataType = "Integer", paramType = "query")})
    @GetMapping("/getExpertOrderList")
    public R<IPage<LifeUserExpertOrderVo>> getExpertOrderList(Integer page, Integer size, Integer expertId, String orderNo, String storeName, Integer storeId) {
        log.info("LifeUserExpertController.getExpertOrderList?page={},size={},expertId={},userName={},phone={}", page, size, expertId, orderNo, storeName, storeId);
        return R.data(lifeUserExpertService.getExpertOrderList(page, size, expertId, orderNo, storeName, storeId));
    }

    @ApiOperation("成为达人，以及状态审核或驳回")
    @ApiOperationSupport(order = 3)
    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "用户id", dataType = "Integer", paramType = "query", required = true),
            @ApiImplicitParam(name = "userPhone", value = "用户电话", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "comment", value = "拒绝原因", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "expertStatus", value = "审核状态 通过0 审核中1 拒绝2", dataType = "Integer", paramType = "query", required = true)})
//    @ApiImplicitParam(name = "expertType", value = "达人类型", dataType = "String", paramType = "query", required = true)})
    @GetMapping("/becomeExpert")
    public R<Boolean> becomeExpert(Integer id,  String userPhone, String comment, Integer expertStatus) {
        log.info("LifeUserExpertController.becomeExpert?id={},expertType={}", id, expertStatus);
        return R.data(lifeUserExpertService.becomeExpert(id, userPhone,comment,expertStatus));
    }

    @ApiOperation("取消达人")
    @ApiOperationSupport(order = 4)
    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "主键id", dataType = "Integer", paramType = "query", required = true)})
    @GetMapping("/cancelExpert")
    public R<Boolean> cancelExpert(Integer id) {
        log.info("LifeUserExpertController.cancelExpert?id={}", id);
        return R.data(lifeUserExpertService.cancelExpert(id));
    }

    @ApiOperation("占比信息")
    @ApiOperationSupport(order = 5)
    @GetMapping("/getPercentageInfo")
    public R<LifeUserExpertVo> getPercentageInfo() {
        log.info("LifeUserExpertController.getPercentageInfo");
        return R.data(lifeUserExpertService.getPercentageInfo());
    }

    @ApiOperation("作品信息")
    @ApiOperationSupport(order = 6)
    @GetMapping("/getWorksInfo")
    public R<LifeUserExpertVo> getWorksInfo(Integer expertId) {
        log.info("LifeUserExpertController.getWorksInfo");
        return R.data(lifeUserExpertService.getWorksInfo(expertId));
    }

    @ApiOperation("合作商家")
    @ApiOperationSupport(order = 7)
    @GetMapping("/getCooperateStore")
    public R<List<LifeUserExpertOrderVo>> getCooperateStore(Integer expertId) {
        log.info("LifeUserExpertController.getCooperateStore");
        return R.data(lifeUserExpertService.getCooperateStore(expertId));
    }

    @ApiOperation("优势带货类型")
    @ApiOperationSupport(order = 8)
    @GetMapping("/greatGoodsType")
    public R<List<ExpertGoodsTypeVo>> greatGoodsType(Integer expertId) {
        log.info("LifeUserExpertController.greatGoodsType?expertId={}", expertId);
        return R.data(lifeUserExpertService.greatGoodsType(expertId));
    }

    @ApiOperation("申请中达人列表")
    @ApiOperationSupport(order = 9)
    @ApiImplicitParams({@ApiImplicitParam(name = "page", value = "分页页数", dataType = "Integer", paramType = "query", required = true),
            @ApiImplicitParam(name = "size", value = "分页条数", dataType = "Integer", paramType = "query", required = true),
            @ApiImplicitParam(name = "userName", value = "姓名", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "userId", value = "用户id", dataType = "String", paramType = "query")})
    @GetMapping("/getApplicationExpertList")
    public R<IPage<LifeUserExpertVo>> getApplicationExpertList(Integer page, Integer size, String userName, String expertCode, Integer userId) {
        log.info("LifeUserExpertController.getUserExpertList?page={},size={},userName={},phone={},userId={}", page, size, userName, expertCode, userId);
        return R.data(lifeUserExpertService.getApplicationExpertList(page, size, userName, expertCode, userId));
    }


}
