package com.malk.jinlun.controller;

import com.alibaba.fastjson.JSONObject;
import com.malk.jinlun.service.JinlunService;
import com.malk.server.common.McR;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
public class JinlunController {
    @Autowired
    private JinlunService jinlunService;

    @GetMapping("/test")
    public McR test(){
        return McR.success("111");
    }

    /**
     * 金蝶新增客户
     * @param map
     * @return
     */
    @PostMapping("/addCustomer")
    public McR addCustomer(@RequestBody Map map){
        return jinlunService.addCustomer(map);
    }

    /**
     * 金蝶更新客户销售员
     * @param map
     * @return
     */
    @PostMapping("/updateCustomer")
    public McR updateCustomer(@RequestBody Map map){
        jinlunService.updateCustomer(map);

        return McR.success();
    }

    /**
     * 金蝶新增客户联系人
     * @param map
     * @return
     */
    @PostMapping("/addCustomerContact")
    public McR addCustomerContact(@RequestBody Map map){
        jinlunService.addCustomerContact(map);

        return McR.success();
    }

    /**
     * 金蝶新增销售订单
     * @param map
     * @return
     */
    @PostMapping("/addSaleOrder")
    public McR addSaleOrder(@RequestBody Map map){
        return jinlunService.addSaleOrder(map);
    }

    /**
     * 创建tb项目
     * @param map
     * @return
     */
    @PostMapping("/createTbProject")
    public McR createTbProject(@RequestBody Map map) {
        jinlunService.createTbProject(map);

        return McR.success();
    }

    /**
     *
     * 查询客户回款对账明细
     * @param startDate
     * @param endDate
     * @param customerName
     * @return
     */
    @GetMapping("/getCustomerDzmx")
    public McR getCustomerDzmx(String startDate, String endDate, String customerName){
        return jinlunService.getCustomerDzmx(startDate,endDate,customerName);
//        return null;
    }

    @GetMapping("/getCustomerWqqk")
    public McR getCustomerWqqk(String startDate, String customerName){
        return jinlunService.getCustomerWqqk(startDate,customerName);
//        return null;
    }

    /***
     * 查询表单数据
     * @param param
     * @return
     */
    @PostMapping("/queryFromData")
    public McR queryFromData(@RequestBody JSONObject param){
        return jinlunService.queryFromData(param);
    }
}
