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.customer.OperationCenterCustomerParam;
import cn.superdesk.uniorder.dto.param.operationCenter.customer.settlement.UnifiedSettlementParam;
import cn.superdesk.uniorder.dto.vo.operationCenter.customer.settlement.UnifiedSettlementVo;
import cn.superdesk.uniorder.dubbo.consumer.operationCenter.customer.UnifiedSettlementDubboService;
import com.alibaba.fastjson2.JSON;
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/5/10 16:22
 * Description : 结算方案接口
 */
@Slf4j
@RestController
@RequestMapping("/accounting/unified/settlement")
@RequiredArgsConstructor
public class UnifiedSettlementController extends BaseController {
    private final UnifiedSettlementDubboService unifiedSettlementDubboService;
    /**
     * 列表
     */
    @PostMapping("/list")
    public R<List<UnifiedSettlementVo>> list(@RequestBody @Validated OperationCenterCustomerParam param) {
        log.info("运营中心--客户管理-列表：入参：param:{}", JSON.toJSONString(param));
        return unifiedSettlementDubboService.list(param);
    }


    /**
     * 新增
     */
    @PostMapping("/add")
    public R<String> add(@Validated @RequestBody UnifiedSettlementParam param) {
        log.info("运营中心--客户管理-新增 或修改 ：入参：param:{}", JSON.toJSONString(param));
        return unifiedSettlementDubboService.saveUnifiedSettlement(param,getToken());

    }

    /**
     * 修改
     */
    @PostMapping("/update")
    public R<String> update(@Validated @RequestBody UnifiedSettlementParam param) {
        log.info("运营中心--客户管理-新增 或修改 ：入参：param:{}", JSON.toJSONString(param));
        return unifiedSettlementDubboService.updateUnifiedSettlement(param,getToken());

    }


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

    }

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



}
