package com.zfire.mall.manager.controller.customer;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zfire.mall.manager.bean.manage.customer.CustomerApplyBean;
import com.zfire.mall.manager.helper.ResponseHelper;
import com.zfire.mall.manager.logic.customer.CustomerApplyLogic;
import com.zfire.mall.manager.plus.entity.CustomerApply;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@Api(value = "经销商申请入驻API", tags ={"经销商申请入驻API"} )
@RequestMapping(value = "/customer/apply", produces = "application/json; charset=utf-8")
public class CustomerApplyController {

    @Autowired
    CustomerApplyLogic customerApplyLogic;


    @ApiOperation(value = "列表")
    @GetMapping("/list")
    public ResponseHelper<IPage<CustomerApply>> list(
            @ApiParam(required = false, value = "企业名称") @RequestParam(required = false) String customerName,
            @ApiParam(required = false, value = "联系人") @RequestParam(required = false) String linkName,
            @ApiParam(required = false, value = "联系电话") @RequestParam(required = false) String linkPhone,
            @ApiParam(required = false, value = "邮箱") @RequestParam(required = false) String email,
            @ApiParam(value = "页号",required = true)@RequestParam Integer pageNum,
            @ApiParam(value = "页大小",required = true)@RequestParam Integer pageSize
    ) throws Exception {
        IPage<CustomerApply> list = customerApplyLogic.list(customerName, linkName, linkPhone, email, pageNum, pageSize);
        return ResponseHelper.success(list);
    }

    @ApiOperation(value = "详情")
    @GetMapping("/detail")
    public ResponseHelper<CustomerApplyBean> detail(
            @ApiParam(required = true, value = "id") @RequestParam(required = true) String id
    ) throws Exception {
        CustomerApplyBean detail = customerApplyLogic.detail(id);
        return ResponseHelper.success(detail);
    }

    @ApiOperation(value = "跟进")
    @GetMapping("/follow")
    public ResponseHelper follow(
            @ApiParam(required = true, value = "id") @RequestParam(required = true) String id,
            @ApiParam(required = true, value = "状态 1=跟进中 2=已关闭") @RequestParam(required = true) Integer status,
            @ApiParam(required = true, value = "处理意见") @RequestParam(required = true) String remark
    ) throws Exception {
        customerApplyLogic.follow(id,status,remark);
        return ResponseHelper.success();
    }






}
