package com.prolog.cs.biz.outbound.controller;

import com.prolog.cs.biz.outbound.model.print.PrintDataWithMark;
import com.prolog.cs.biz.outbound.service.PrintService;
import com.prolog.framework.bz.common.print.PrintData;
import com.prolog.framework.common.message.RestMessage;
import com.prolog.framework.log.aop.annotation.UserLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author zzz
 * @desc
 * @date 2021/4/27
 */
@Api(tags = "打印")
@Slf4j
@RestController
@RequestMapping("/print")
public class PrintController {

    @Autowired
    private PrintService printService;



    @UserLog
    @ApiOperation(value = "QN行业线销售清单打印")
    @PostMapping("/print-qnSalesData")
    public RestMessage<PrintData> printQnSalesData(@RequestParam String billId){
        PrintData data = printService.printQnSalesData(billId);
        return RestMessage.success("操作成功", data);
    }


    @UserLog
    @ApiOperation(value = "YM行业线销售清单模板")
    @PostMapping("/print-ymSalesData")
    public RestMessage<List<PrintData>> printYmSalesData(@RequestParam String billId){
        List<PrintData> data = printService.printYmSalesData(billId);
        return RestMessage.success("操作成功", data);
    }

    @UserLog
    @ApiOperation(value = "社会性物流面单")
    @PostMapping("/print-logisticData")
    public RestMessage<PrintData> printLogisticData(@RequestParam String billId){
        PrintData data = printService.printLogisticData(billId);
        return RestMessage.success("操作成功", data);
    }

    @UserLog
    @ApiOperation(value = "pdf打印数据")
    @PostMapping("/print-pdfData")
    public RestMessage<Map<String,Object>> printPdfData(@RequestBody List<Map<String,String>> fileInfo){
        Map<String,Object> data = printService.printPdfData(fileInfo);
        return RestMessage.success("操作成功", data);
    }

    @UserLog
    @ApiOperation(value = "快递面单打印数据")
    @PostMapping("/print-expressData")
    public RestMessage<PrintDataWithMark> printExpressData(@RequestBody List<String> waybillCode){
        PrintDataWithMark data = printService.printExpressData(waybillCode);
        return RestMessage.success("操作成功", data);
    }

    @UserLog
    @ApiOperation(value = "发票打印数据")
    @PostMapping("/print-invoiceData")
    public RestMessage<Map<String,Object>> printInvoiceData(@RequestParam String orderNo){
        Map<String,Object> data = printService.printInvoiceData(orderNo);
        return RestMessage.success("操作成功", data);
    }

    @UserLog
    @ApiOperation(value = "标签打印数据")
    @PostMapping("/print-labelData")
    public RestMessage<PrintDataWithMark> printLabelData(@RequestBody List<String> billGroupIds){
        PrintDataWithMark data = printService.printLabelData(billGroupIds);
        return RestMessage.success("操作成功", data);
    }
}
