package com.malk.qiwang.Controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.malk.qiwang.Service.IInvoiceLibraryService;
import com.malk.qiwang.Service.QiWangService;
import com.malk.qiwang.Service.TXYInvoice;
import com.malk.qiwang.entity.InvoiceLibrary;
import com.malk.qiwang.mapper.InvoiceLibraryMapper;
import com.malk.server.common.McR;
import com.malk.service.aliwork.YDClient;
import com.malk.service.dingtalk.DDClient;
import com.malk.service.dingtalk.DDClient_Contacts;
import com.malk.service.dingtalk.DDClient_Workflow;
import com.malk.utils.UtilMap;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;

import java.util.Map;

/**
 * <p>
 * 发票库表 前端控制器
 * </p>
 *
 * @author LQY
 * @since 2026-04-27
 */
@RestController
@RequestMapping("/qw2")
@Slf4j
public class InvoiceLibraryController {
    @Autowired
    private IInvoiceLibraryService invoiceLibrary;
    @Autowired
    private DDClient ddClient;
    @Autowired
    private YDClient ydClient;
    @Autowired
    private TXYInvoice txyInvoice;
    @Value("${dingtalk.operator}")
    private String operator;
    @Value("${dingtalk.downloadPath}")
    private String downloadPath;
    @Autowired
    private DDClient_Workflow ddClientWorkflow ;
    @Autowired
    private DDClient_Contacts ddClient_contacts;
    @Autowired
    private InvoiceLibraryMapper baseMapper;
    private static final String url = "http://47.103.203.2:9092/qiwang/";
// private static final String url = "http://410a09c5.r39.cpolar.top/qiwang/"
//员工报销
    @PostMapping("/invoiceLibrary")
    public McR test(@RequestBody Map map)  {
        log.info("map:{}", map);
        invoiceLibrary.invoiceLibrary(map);
       return McR.success();
    }
    //付款申请
    @PostMapping("/invoiceLibrary1")
    public McR invoiceLibrary1(@RequestBody Map map) {
        log.info("map:{}", map);
        invoiceLibrary.invoiceLibrary1(map);
        return McR.success();
    }

    //合作商付款申请
    @PostMapping("/invoiceLibrary2")
    public McR invoiceLibrary2(@RequestBody Map map) {
        log.info("map:{}", map);
        invoiceLibrary.invoiceLibrary2(map);
        return McR.success();
    }

    //合作商报销申请
    @PostMapping("/invoiceLibrary3")
    public McR invoiceLibrary3(@RequestBody Map map) {
        log.info("map:{}", map);
        invoiceLibrary.invoiceLibrary3(map);
        return McR.success();
    }

    //出差费用申请
    @PostMapping("/invoiceLibrary5")
    public McR invoiceLibrary5(@RequestBody Map map) {
        log.info("map:{}", map);
        invoiceLibrary.invoiceLibrary5(map);
        return McR.success();
    }

    //批量付款申请（一对多）
    @PostMapping("/invoiceLibrary6")
    public McR invoiceLibrary6(@RequestBody Map map) {
        log.info("map:{}", map);
        invoiceLibrary.invoiceLibrary6(map);
        return McR.success();
    }
    @PostMapping("/invoiceLibrarys")
    public McR test2(@RequestBody Map map) {
        log.info("map:{}", map);
        invoiceLibrary.invoiceLibrarys(map);
        return McR.success();
    }
    @PostMapping("/updateOaStatusByOaId")
    public McR test1(@RequestBody Map map) {
        log.info("map:{}", map);
        invoiceLibrary.updateOaStatusByOaId(map);
        return McR.success();
    }

    @PostMapping("/updateSfctByOaId")
    public McR updateSfctByOaId(@RequestBody Map map) {
        log.info("map:{}", map);
        invoiceLibrary.updateSfctByOaId(map);
        return McR.success();
    }
    @PostMapping("/deleteAll")
    public McR deleteAllByOaId(@RequestParam("oaId") String oaId) {

        log.info("map:{}", oaId);
        invoiceLibrary.deleteAllByOaId(oaId);
       return McR.success();
    }
}
