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

import com.zfire.mall.manager.bean.k3.KingDeeInterfaceBean;
import com.zfire.mall.manager.helper.ResponseHelper;
import com.zfire.mall.manager.logic.k3.*;
import com.zfire.mall.manager.plus.entity.KingDeeDepartment;
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.*;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@RestController
@Api(value = "金蝶同步接口API", tags ={"金蝶同步接口API"} )
@RequestMapping(value = "/k3", produces = "application/json; charset=utf-8")
public class K3Controller {

    @Resource
    K3InterfaceLogic k3InterfaceLogic;
    @Resource
    K3OrgLogic k3OrgLogic;
    @Resource
    K3MaterialLogic k3MaterialLogic;
    @Resource
    K3CategoryLogic k3CategoryLogic;
    @Autowired
    K3CustomerLogic k3CustomerLogic;
    @Resource
    K3StockLogic stockLogic;
    @Resource
    K3DepartmentLogic k3DepartmentLogic;
    @Autowired
    K3WalletLogic k3WalletLogic;

    @ApiOperation(value = "添加新接口")
    @PostMapping("/interface/add")
    public ResponseHelper interfaceAdd(@RequestBody KingDeeInterfaceBean kingDeeInterfaceBean) throws Exception {
        k3InterfaceLogic.interfaceAdd(kingDeeInterfaceBean);
        return ResponseHelper.success();
    }

    @ApiOperation("金蝶部门列表")
    @GetMapping("/department/list")
    public ResponseHelper<List<KingDeeDepartment>> departmentList() throws Exception {
        List<KingDeeDepartment> list = k3DepartmentLogic.list();
        return ResponseHelper.success(list);
    }

//    @ApiOperation(value = "同步组织")
//    @PostMapping("/org/sync")
//    public ResponseHelper syncOrg() throws Exception {
//        k3OrgLogic.allSync();
//        return ResponseHelper.success();
//    }
//
//
//    @ApiOperation(value = "同步物料")
//    @PostMapping("/material/sync")
//    public ResponseHelper syncMaterial(
//            @ApiParam(required = true, value = "组织机构") @RequestParam(required = true) String orgId,
//            @ApiParam(required = true, value = "组织机构编码") @RequestParam(required = true) String orgNumber,
//            @ApiParam(required = false, value = "开始时间") @RequestParam(required = false) String startTime,
//            @ApiParam(required = false, value = "结束时间") @RequestParam(required = false) String endTime
//    ) throws Exception {
//        k3MaterialLogic.allSync(orgId, orgNumber,startTime,endTime);
//        return ResponseHelper.success();
//    }
//
//    @ApiOperation(value = "同步存货类别")
//    @PostMapping("/category/sync")
//    public ResponseHelper syncCategory(
//            @ApiParam(required = true, value = "组织机构") @RequestParam(required = true) String orgId,
//            @ApiParam(required = true, value = "组织机构编码") @RequestParam(required = true) String orgNumber,
//            @ApiParam(required = false, value = "开始时间") @RequestParam(required = false) String startTime,
//            @ApiParam(required = false, value = "结束时间") @RequestParam(required = false) String endTime
//    ) throws Exception {
//        k3CategoryLogic.allSync(orgId, orgNumber,startTime,endTime);
//        return ResponseHelper.success();
//    }
//
//    @ApiOperation(value = "同步经销商")
//    @PostMapping("/customer/sync")
//    public ResponseHelper syncCustomer(
//            @ApiParam(required = true, value = "组织机构") @RequestParam(required = true) String orgId,
//            @ApiParam(required = true, value = "组织机构编码") @RequestParam(required = true) String orgNumber,
//            @ApiParam(required = false, value = "开始时间") @RequestParam(required = false) String startTime,
//            @ApiParam(required = false, value = "结束时间") @RequestParam(required = false) String endTime
//    ) throws Exception {
//        k3CustomerLogic.allSync(orgId, orgNumber, startTime,endTime);
//        return ResponseHelper.success();
//    }
//
//    @ApiOperation(value = "同步仓库")
//    @PostMapping("/stock/sync")
//    public ResponseHelper syncStock(
//            @ApiParam(required = true, value = "组织机构") @RequestParam(required = true) String orgId,
//            @ApiParam(required = true, value = "组织机构编码") @RequestParam(required = true) String orgNumber,
//            @ApiParam(required = false, value = "开始时间") @RequestParam(required = false) String startTime,
//            @ApiParam(required = false, value = "结束时间") @RequestParam(required = false) String endTime
//    ) throws Exception {
//        stockLogic.allSync(orgId, orgNumber, startTime,endTime);
//        return ResponseHelper.success();
//    }
//
//    @ApiOperation(value = "同步部门")
//    @PostMapping("/department/sync")
//    public ResponseHelper syncDepartment(
//            @ApiParam(required = true, value = "组织机构") @RequestParam(required = true) String orgId,
//            @ApiParam(required = true, value = "组织机构编码") @RequestParam(required = true) String orgNumber,
//            @ApiParam(required = false, value = "开始时间") @RequestParam(required = false) String startTime,
//            @ApiParam(required = false, value = "结束时间") @RequestParam(required = false) String endTime
//    ) throws Exception {
//        k3DepartmentLogic.allSync(orgId, orgNumber, startTime,endTime);
//        return ResponseHelper.success();
//    }
//
//    @ApiOperation(value = "同步钱包")
//    @PostMapping("/wallet/sync")
//    public ResponseHelper syncWallet(
//            @ApiParam(required = true, value = "组织机构") @RequestParam(required = true) String orgId,
//            @ApiParam(required = true, value = "组织机构编码") @RequestParam(required = true) String orgNumber,
//            @ApiParam(required = false, value = "开始时间") @RequestParam(required = false) String startTime,
//            @ApiParam(required = false, value = "结束时间") @RequestParam(required = false) String endTime
//    ) throws Exception {
//        k3WalletLogic.allSync(orgId, orgNumber, startTime,endTime);
//        return ResponseHelper.success();
//    }
//
//
//    @ApiOperation(value = "同步钱包的收款单")
//    @PostMapping("/wallet-skd/sync")
//    public ResponseHelper syncSkdWallet(
////            @ApiParam(required = false, value = "开始时间") @RequestParam(required = false) String startTime,
////            @ApiParam(required = false, value = "结束时间") @RequestParam(required = false) String endTime
//    ) throws Exception {
//        //k3WalletLogic.allSyncSkd("1","100",null,null);
//        return ResponseHelper.success();
//    }


}
