package cn.superdesk.uniorder.controller.operationCenter.customer;

import cn.superdesk.uniorder.common.rest.response.R;
import cn.superdesk.uniorder.controller.base.BaseController;
import cn.superdesk.uniorder.dto.param.operationCenter.base.OperationCenterBaseParam;
import cn.superdesk.uniorder.dto.param.operationCenter.customer.OperationCenterBillStartParam;
import cn.superdesk.uniorder.dto.vo.operationCenter.customer.OperationCenterBillStartVo;
import cn.superdesk.uniorder.dto.vo.operationCenter.customer.OperationCenterCustomerVo;
import cn.superdesk.uniorder.dubbo.consumer.operationCenter.customer.OperationCenterBillStartDubboService;
import com.alibaba.fastjson2.JSON;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author : zx
 * @Create : 2023/4/17 14:10
 * Description : 开票抬头
 */
@Api(value = "运营中心-客户管理-开票抬头", tags = {"数据管理-客户管理-开票抬头"})
@Slf4j
@RestController
@RequestMapping("/operationCenter/billStart")
@RequiredArgsConstructor
public class OperationCenterBillStartController extends BaseController {
    private final OperationCenterBillStartDubboService operationCenterBillStartDubboService;

    /**
     * 列表
     */
    @PostMapping("/list")
    public R<List<OperationCenterBillStartVo>> list(@RequestBody @Validated OperationCenterBaseParam param) {
        log.info("运营中心-客户管理-开票抬头-列表：入参：param:{}", JSON.toJSONString(param));
        return operationCenterBillStartDubboService.getBillStartListByCustomerId(param);
    }

    /**
     * 新增 修改
     */
    @PostMapping("/addOrUpdate")
    public R<String> addOrUpdate(@Validated @RequestBody OperationCenterBillStartParam param) {
        log.info("运营中心-客户管理-开票抬头-新增 或修改 ：入参：param:{}", JSON.toJSONString(param));
        return operationCenterBillStartDubboService.saveOperationCenterBillStart(param, getToken());

    }


    /**
     * 根据id查询客户信息
     */
    @PostMapping("/get/{id}")
    public R<OperationCenterBillStartVo> get(@PathVariable("id") Long id) {
        log.info("运营中心-客户管理-开票抬头-根据id查询客户信息--->入参：id:{}", id);
        return operationCenterBillStartDubboService.getBillStartById(id);

    }

    /**
     * 删除
     */
    @PostMapping("/delete/{id}")
    public R<String> delete(@PathVariable("id") Long id) {
        log.info("运营中心-客户管理-开票抬头-根据id软删除客户信息--->入参：id:{}", id);
        return operationCenterBillStartDubboService.deleteOperationCenterBillStartById(id,getToken());
    }

    /**
     * 设为默认开票抬头
     */
    @PostMapping("/enable/{billId}")
    public R<String> enable(@PathVariable("billId") Long billId) {
        log.info("运营中心-客户管理-开票抬头-根据id软删除客户信息--->入参：id:{}", billId);
        return operationCenterBillStartDubboService.enableOperationCenterBillStartById(billId,getToken());
    }

}

