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


import cn.hutool.core.convert.Convert;
import cn.hutool.core.lang.TypeReference;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zfire.mall.manager.annotation.ApiNotAuth;
import com.zfire.mall.manager.annotation.Sign;
import com.zfire.mall.manager.annotation.ZfireList;
import com.zfire.mall.manager.bean.CommonCountBean;
import com.zfire.mall.manager.bean.ExcelData;
import com.zfire.mall.manager.bean.PoySaleCountBean;
import com.zfire.mall.manager.bean.invoice.InvoiceApplicationPick;
import com.zfire.mall.manager.bean.invoice.InvoiceBean;
import com.zfire.mall.manager.bean.invoice.InvoicePickBean;
import com.zfire.mall.manager.bean.invoice.InvoiceProjectVO;
import com.zfire.mall.manager.bean.k3.StockPosition;
import com.zfire.mall.manager.bean.k3.StockPositionStock;
import com.zfire.mall.manager.bean.listV2.dto.InvoiceProjectDTO;
import com.zfire.mall.manager.bean.pick.*;
import com.zfire.mall.manager.bean.ship.ShipDocumentBean;
import com.zfire.mall.manager.bean.ship.ShipDocumentDetail;
import com.zfire.mall.manager.bean.stock.StockBeanDis;
import com.zfire.mall.manager.constant.Constant;
import com.zfire.mall.manager.exception.RemoteServiceException;
import com.zfire.mall.manager.helper.ResponseHelper;
import com.zfire.mall.manager.logic.common.SMSLogic;
import com.zfire.mall.manager.logic.pick.PickLogic;
import com.zfire.mall.manager.logic.ship.ShipLogic;
import com.zfire.mall.manager.plus.entity.*;
import com.zfire.mall.manager.utils.excel.ExcelUtils;
import com.zfire.mall.manager.zfire.bean.ZfireParamBean;
import com.zfire.mall.manager.zfire.util.FieldUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.integration.redis.util.RedisLockRegistry;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.TreeSet;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
import java.util.stream.Collectors;

/**
 * @author CHANGE
 */
@Slf4j
@RestController
@Api(value = "提货管理", tags = {"提货管理"})
@RequestMapping(value = "/pick", produces = "application/json; charset=utf-8")
public class PickController {


    @Autowired
    PickLogic pickLogic;

    @Autowired
    RedisLockRegistry redisLockRegistry;


    @ApiOperation(value = "提货列表")
    @GetMapping("/list")
    public ResponseHelper<IPage<PickManagerBean>> list(
            @ApiParam(required = false, value = "申请发货单号") @RequestParam(required = false) String invoiceId,
            @ApiParam(required = false, value = "销售出库单号") @RequestParam(required = false) String salesOrderId,
            @ApiParam(required = false, value = "申请人") @RequestParam(required = false) String createBy,
            @ApiParam(required = false, value = "提货仓库") @RequestParam(required = false) String correspondId,
            @ApiParam(required = false, value = "提货人id") @RequestParam(required = false) String takerId,
            @ApiParam(required = false, value = "提货人电话") @RequestParam(required = false) String takerPhone,
            @ApiParam(required = false, value = "物流id") @RequestParam(required = false) String logisticsId,
            @ApiParam(required = false, value = "提货开始时间") @RequestParam(required = false) String pickStartTime,
            @ApiParam(required = false, value = "提货结束时间") @RequestParam(required = false) String pickEndTime,
            @ApiParam(required = false, value = "申请开始日期") @RequestParam(required = false) String startTime,
            @ApiParam(required = false, value = "申请结束日期") @RequestParam(required = false) String endTime,
            @ApiParam(required = false, value = "经销商编码") @RequestParam(required = false) String customerNumber,
            @ApiParam(required = false, value = "经销商名称") @RequestParam(required = false) String customerName,
            @ApiParam(required = false, value = "经销商id") @RequestParam(required = false) String customerId,
            @ApiParam(required = false, value = "打印开始时间") @RequestParam(required = false) String printStartTime,
            @ApiParam(required = false, value = "打印结束时间") @RequestParam(required = false) String printEndTime,
            @ApiParam(required = false, value = "0 为打单 1已打单 2已出货 3弃单") @RequestParam(required = false) Integer status,
            @ApiParam(value = "页号", required = true) @RequestParam Integer pageNum,
            @ApiParam(value = "页大小", required = true) @RequestParam Integer pageSize
    ) throws Exception {
        IPage<PickManagerBean> kingDeeSupplier = pickLogic.list(logisticsId,printStartTime,printEndTime,salesOrderId,customerId,takerPhone,takerId, invoiceId, createBy, correspondId, pickStartTime, pickEndTime, startTime, endTime,
                customerNumber, customerName, pageNum, pageSize, status);
        return ResponseHelper.success(kingDeeSupplier);
    }


    @ZfireList
    @PostMapping("/listV2")
    @ApiOperation("提货-列表V2")
    public ResponseHelper<IPage<PickManagerBeanVO>> listV2(
            @RequestBody ZfireParamBean zfireParamBean
    ) throws RemoteServiceException {
        IPage<PickManagerBeanVO> list = pickLogic.listV2(zfireParamBean);
        return ResponseHelper.success(list, new TypeReference<PickManagerBeanVO>() {});
    }

    @PostMapping("/listV2/export")
    @ApiOperation("提货-列表V2导出")
    public void listProjectV2Export(
            @RequestBody ZfireParamBean zfireParamBean,
            HttpServletRequest request,
            HttpServletResponse response
    ) throws Exception {
        //1.组装查询条件
        ZfireParamBean zfireParam = FieldUtils.supplyParam(zfireParamBean);
        //2.查询要导出的内容
        IPage<PickManagerBeanVO> list = pickLogic.listV2(zfireParamBean);
        //3.导出
        FieldUtils.exportData(list.getRecords(),zfireParam.getExportFields(),request,response);
    }


    @ApiOperation(value = "经销商提货列表-统计")
    @GetMapping("/listCount")
    public ResponseHelper<PoySaleCountBean> list(
            @ApiParam(required = false, value = "申请发货单号") @RequestParam(required = false) String invoiceId,
            @ApiParam(required = false, value = "申请人") @RequestParam(required = false) String createBy,
            @ApiParam(required = false, value = "提货仓库") @RequestParam(required = false) String correspondId,
            @ApiParam(required = false, value = "提货人id") @RequestParam(required = false) String takerId,
            @ApiParam(required = false, value = "提货开始时间") @RequestParam(required = false) String pickStartTime,
            @ApiParam(required = false, value = "提货结束时间") @RequestParam(required = false) String pickEndTime,
            @ApiParam(required = false, value = "申请开始日期") @RequestParam(required = false) String startTime,
            @ApiParam(required = false, value = "申请结束日期") @RequestParam(required = false) String endTime,
            @ApiParam(required = false, value = "经销商编码") @RequestParam(required = false) String customerNumber,
            @ApiParam(required = false, value = "经销商名称") @RequestParam(required = false) String customerName,
            @ApiParam(required = false, value = "0 为打单 1已打单 2已出货 3弃单") @RequestParam(required = false) Integer status
    ) throws Exception {
        PoySaleCountBean bean = pickLogic.listCount(takerId, invoiceId, createBy, correspondId, pickStartTime, pickEndTime, startTime, endTime,
                customerNumber, customerName, status);
        return ResponseHelper.success(bean);
    }


    @ApiOperation(value = "打印提货列表")
    @GetMapping("/listPrint")
    public ResponseHelper<IPage<PickManagerBean>> listPrint(
            @ApiParam(required = false, value = "申请发货单号") @RequestParam(required = false) String invoiceId,
            @ApiParam(required = false, value = "申请人") @RequestParam(required = false) String createBy,
            @ApiParam(required = false, value = "提货人电话") @RequestParam(required = false) String takerPhone,
            @ApiParam(required = false, value = "提货仓库") @RequestParam(required = false) String correspondId,
            @ApiParam(required = false, value = "提货人id") @RequestParam(required = false) String takerId,
            @ApiParam(required = false, value = "提货开始时间") @RequestParam(required = false) String pickStartTime,
            @ApiParam(required = false, value = "提货结束时间") @RequestParam(required = false) String pickEndTime,
            @ApiParam(required = false, value = "申请开始日期") @RequestParam(required = false) String startTime,
            @ApiParam(required = false, value = "申请结束日期") @RequestParam(required = false) String endTime,
            @ApiParam(required = false, value = "经销商编码") @RequestParam(required = false) String customerNumber,
            @ApiParam(required = false, value = "经销商名称") @RequestParam(required = false) String customerName,
            @ApiParam(required = false, value = "0 为打单 1已打单 2已出货 3弃单") @RequestParam(required = false) Integer status,
            @ApiParam(value = "页号", required = true) @RequestParam Integer pageNum,
            @ApiParam(value = "页大小", required = true) @RequestParam Integer pageSize
    ) throws Exception {
        IPage<PickManagerBean> kingDeeSupplier = pickLogic.listPrint(takerPhone,takerId, invoiceId, createBy, correspondId, pickStartTime, pickEndTime, startTime, endTime,
                customerNumber, customerName, pageNum, pageSize, status);
        return ResponseHelper.success(kingDeeSupplier);
    }


    @ApiOperation(value = "申请发货单列表")
    @GetMapping("/listInvoice")
    public ResponseHelper<List<InvoicePickBean>> listInvoice(
            @ApiParam(required = false, value = "提货仓库Id") @RequestParam(required = false) String correspondId
    ) throws Exception {
        List<InvoicePickBean> invoiceBeanList = pickLogic.listInvoice(correspondId);
        return ResponseHelper.success(invoiceBeanList);
    }


    @PostMapping("/add")
    @ApiOperation("新增提货预约")
    public ResponseHelper addStock(@RequestBody PickManagerRequest pickManagerRequest, HttpServletRequest request) throws InterruptedException {
        Lock obtain = redisLockRegistry.obtain(Constant.RedisPrefix.PICK_MANAGER);
        try {
            if (!obtain.tryLock(5, TimeUnit.SECONDS)) {
                throw new RemoteServiceException("系统繁忙，请稍后再试");
            }
            pickLogic.add(pickManagerRequest, request);
        } finally {
            obtain.unlock();
        }
        return ResponseHelper.success();
    }

    @PostMapping("/delete")
    @ApiOperation("提货单取消")
    public ResponseHelper delete(
            @ApiParam(required = true, value = "提货单号") @RequestParam(required = true) String id
            , HttpServletRequest request) throws Exception {
        Lock obtain = redisLockRegistry.obtain(Constant.RedisPrefix.INVOICE_APPLICATION + id);
        try {
            if (!obtain.tryLock(5, TimeUnit.SECONDS)) {
                throw new RemoteServiceException("系统繁忙，请稍后再试");
            }

            pickLogic.delete(id);

        } finally {
            obtain.unlock();
        }
        return ResponseHelper.success();
    }


    @PostMapping("/deleteDa")
    @ApiOperation("提货单作废")
    public ResponseHelper deleteDa(
            @ApiParam(required = true, value = "提货单号") @RequestParam(required = true) String id
            , HttpServletRequest request) throws Exception {
        Lock obtain = redisLockRegistry.obtain(Constant.RedisPrefix.INVOICE_APPLICATION + id);
        try {
            if (!obtain.tryLock(5, TimeUnit.SECONDS)) {
                throw new RemoteServiceException("系统繁忙，请稍后再试");
            }

            pickLogic.deleteDa(id);

        } finally {
            obtain.unlock();
        }
        return ResponseHelper.success();
    }

    @PostMapping("/update")
    @ApiOperation("修改提货预约")
    public ResponseHelper update(@RequestBody PickManagerRequest pickManagerRequest, HttpServletRequest request) throws InterruptedException {
        Lock obtain = redisLockRegistry.obtain(Constant.RedisPrefix.PICK_MANAGER + pickManagerRequest.getId());
        try {
            if (!obtain.tryLock(5, TimeUnit.SECONDS)) {
                throw new RemoteServiceException("系统繁忙，请稍后再试");
            }
            pickLogic.update(pickManagerRequest, request);
        } finally {
            obtain.unlock();
        }
        return ResponseHelper.success();
    }

    @ApiOperation(value = "提货预约详情")
    @GetMapping("/detail")
    public ResponseHelper<PickManagerDetailBean> detail(
            @ApiParam(required = true, value = "id") @RequestParam(required = true) String id
    ) throws Exception {
        PickManagerDetailBean pickManagerBean = pickLogic.detail(id);
        return ResponseHelper.success(pickManagerBean);
    }

    @ApiOperation(value = "提货预约详情打印版本")
    @GetMapping("/detailPrint")
    public ResponseHelper<PickManagerDetailBean> detailPrint(
            @ApiParam(required = true, value = "出库单id") @RequestParam(required = true) String id,
            @ApiParam(required = true, value = "发货单id") @RequestParam(required = true) String invoiceId
    ) throws Exception {
        PickManagerDetailBean pickManagerBean = pickLogic.detailPrint(id,invoiceId);
        return ResponseHelper.success(pickManagerBean);
    }

    @ApiOperation(value = "提货预约详情打印版本")
    @PostMapping("/detailPrintDis")
    public ResponseHelper<List<PickManagerDetailBean>> detailPrintDis(
            @RequestBody List<StockBeanDis>  stockBeanDis
            ) throws Exception {
        List<StockBeanDis> result =
                stockBeanDis.stream().distinct().collect(Collectors.toList());
        List<PickManagerDetailBean> pickManagerDetailBeans = new ArrayList<>();
        for (StockBeanDis stockBeanDi : result) {
            PickManagerDetailBean pickManagerBean = pickLogic.detailPrint(stockBeanDi.getId(),stockBeanDi.getInvoiceId());
            pickManagerDetailBeans.add(pickManagerBean);
        }

        return ResponseHelper.success(pickManagerDetailBeans);
    }


    @ApiOperation(value = "提货预约详情打印版本提示")
    @PostMapping("/detailPrintDisString")
    public ResponseHelper<String> detailPrintDisString(
            @RequestBody List<StockBeanDis>  stockBeanDis
    ) throws Exception {
        List<StockBeanDis> result =
                stockBeanDis.stream().distinct().collect(Collectors.toList());
        String tiShi = "";
        for (StockBeanDis stockBeanDi : result) {
            PickManagerDetailBean pickManagerBean = pickLogic.detailPrint(stockBeanDi.getId(),stockBeanDi.getInvoiceId());
            if (pickManagerBean != null) {

                for (InvoicePickBean invoicePickBean : pickManagerBean.getInvoicePickBeans()) {
                    if (!invoicePickBean.getStatus().equals(0)) {
                        tiShi = tiShi + invoicePickBean.getInvoiceId() + ",";
                    }
                }
            }
        }
        if (StringUtils.isEmpty(tiShi)){
            return  ResponseHelper.success();
        }
        return ResponseHelper.success("当前打印单存在已打印，发货单号为："+tiShi+"是否继续打印。");
    }


    @PostMapping("/sendCode")
    @ApiOperation(value = "发送短信验证码")
    public ResponseHelper messageCode(
            @ApiParam(value = "联系电话", required = true) @RequestParam(required = true) String mobile
    ) throws Exception {
        pickLogic.sendCode(mobile);
        return ResponseHelper.success();
    }


    @PostMapping("/verifyCode")
    @ApiOperation(value = "验证短信验证码")
    public ResponseHelper<List<TakerRecord>> verifyCode(
            @ApiParam(value = "联系电话", required = true) @RequestParam(required = true) String mobile,
            @ApiParam(value = "验证码", required = true) @RequestParam(required = true) String code
    ) throws Exception {
        List<TakerRecord> takerRecord = pickLogic.verifyCode(mobile, code);
        return ResponseHelper.success(takerRecord);
    }

    @PostMapping("/printAdd")
    @ApiOperation("增加打印次数")
    public ResponseHelper printAdd(@ApiParam(value = "增加次数得ID", required = true) @RequestParam(required = true) List<String> ids, HttpServletRequest request) throws InterruptedException {
        Lock obtain = redisLockRegistry.obtain(Constant.RedisPrefix.PRINT_PICK_MANAGER);
        try {
            if (!obtain.tryLock(5, TimeUnit.SECONDS)) {
                throw new RemoteServiceException("系统繁忙，请稍后再试");
            }
            pickLogic.printAdd(ids, request);
        } finally {
            obtain.unlock();
        }
        return ResponseHelper.success();
    }

    @ApiOperation(value = "提货经销商列表")
    @GetMapping("/listPickBy")
    public ResponseHelper<IPage<PickManagerLog>> listPickBy(
            @ApiParam(required = false, value = "提货单号") @RequestParam(required = false) String id,

            @ApiParam(value = "页号",required = true)@RequestParam Integer pageNum,
            @ApiParam(value = "页大小",required = true)@RequestParam Integer pageSize
    ) throws Exception {
        IPage<PickManagerLog> list = pickLogic.listPickBy(id,pageNum, pageSize);
        return ResponseHelper.success(list);
    }

    @PostMapping("/verifyShip")
    @ApiOperation(value = "重新打单验证密码")
    public ResponseHelper verifyShip(
            @ApiParam(value = "发货单订单号", required = false) @RequestParam(required = false) String shipId,
            @ApiParam(value = "验证码", required = true) @RequestParam(required = true) String password
    ) {
        pickLogic.verifyShip(shipId, password);
        return ResponseHelper.success();
    }

    @ApiOperation(value = "提货列表-导出")
    @GetMapping("/export")
    public void export(
            @ApiParam(required = false, value = "申请发货单号") @RequestParam(required = false) String invoiceId,
            @ApiParam(required = false, value = "销售出库单号") @RequestParam(required = false) String salesOrderId,
            @ApiParam(required = false, value = "申请人") @RequestParam(required = false) String createBy,
            @ApiParam(required = false, value = "提货人电话") @RequestParam(required = false) String takerPhone,
            @ApiParam(required = false, value = "提货仓库") @RequestParam(required = false) String correspondId,
            @ApiParam(required = false, value = "提货人id") @RequestParam(required = false) String takerId,
            @ApiParam(required = false, value = "提货开始时间") @RequestParam(required = false) String pickStartTime,
            @ApiParam(required = false, value = "提货结束时间") @RequestParam(required = false) String pickEndTime,
            @ApiParam(required = false, value = "申请开始日期") @RequestParam(required = false) String startTime,
            @ApiParam(required = false, value = "申请结束日期") @RequestParam(required = false) String endTime,
            @ApiParam(required = false, value = "经销商编码") @RequestParam(required = false) String customerNumber,
            @ApiParam(required = false, value = "经销商名称") @RequestParam(required = false) String customerName,
            @ApiParam(required = false, value = "经销商id") @RequestParam(required = false) String customerId,
            @ApiParam(required = false, value = "物流id") @RequestParam(required = false) String logisticsId,
            @ApiParam(required = false, value = "0 为打单 1已打单 2已出货 3弃单") @RequestParam(required = false) Integer status,
            @ApiParam(required = false, value = "打印开始时间") @RequestParam(required = false) String printStartTime,
            @ApiParam(required = false, value = "打印结束时间") @RequestParam(required = false) String printEndTime,
            HttpServletRequest request, HttpServletResponse response
    ) throws Exception {
        IPage<PickManagerBean> kingDeeSupplier = pickLogic.list(logisticsId,printStartTime,printEndTime,salesOrderId,customerId,takerPhone,takerId,
                invoiceId, createBy, correspondId, pickStartTime, pickEndTime, startTime, endTime, customerNumber, customerName, 1, -1, status);
        ExcelData excelData = pickLogic.export(kingDeeSupplier.getRecords());
        ExcelUtils.exportExcel(request, response, "经销商提货预约汇总.xlsx", excelData);
    }

    @ApiOperation(value = "仓库认证打单-导出")
    @GetMapping("/storeExport")
    public void storeExport(
            @ApiParam(required = false, value = "申请发货单号") @RequestParam(required = false) String invoiceId,
            @ApiParam(required = false, value = "销售出库单号") @RequestParam(required = false) String salesOrderId,
            @ApiParam(required = false, value = "申请人") @RequestParam(required = false) String createBy,
            @ApiParam(required = false, value = "提货仓库") @RequestParam(required = false) String correspondId,
            @ApiParam(required = false, value = "提货人id") @RequestParam(required = false) String takerId,
            @ApiParam(required = false, value = "提货人电话") @RequestParam(required = false) String takerPhone,
            @ApiParam(required = false, value = "物流id") @RequestParam(required = false) String logisticsId,
            @ApiParam(required = false, value = "提货开始时间") @RequestParam(required = false) String pickStartTime,
            @ApiParam(required = false, value = "提货结束时间") @RequestParam(required = false) String pickEndTime,
            @ApiParam(required = false, value = "申请开始日期") @RequestParam(required = false) String startTime,
            @ApiParam(required = false, value = "申请结束日期") @RequestParam(required = false) String endTime,
            @ApiParam(required = false, value = "经销商编码") @RequestParam(required = false) String customerNumber,
            @ApiParam(required = false, value = "经销商名称") @RequestParam(required = false) String customerName,
            @ApiParam(required = false, value = "经销商id") @RequestParam(required = false) String customerId,
            @ApiParam(required = false, value = "打印开始时间") @RequestParam(required = false) String printStartTime,
            @ApiParam(required = false, value = "打印结束时间") @RequestParam(required = false) String printEndTime,
            @ApiParam(required = false, value = "0 为打单 1已打单 2已出货 3弃单") @RequestParam(required = false) Integer status,

            HttpServletRequest request, HttpServletResponse response
    ) throws Exception {
        IPage<PickManagerBean> kingDeeSupplier = pickLogic.list(logisticsId,printStartTime,printEndTime,salesOrderId,customerId,takerPhone,takerId, invoiceId, createBy,
                correspondId, pickStartTime, pickEndTime, startTime, endTime, customerNumber, customerName, 1, -1, status);
        ExcelData excelData = pickLogic.storeExport(kingDeeSupplier.getRecords());
        ExcelUtils.exportExcel(request, response, "仓库认证打单.xlsx", excelData);
    }


    @GetMapping("/summary")
    @ApiOperation("汇总")
    public ResponseHelper<PickSummary> summary(@ApiParam(required = false, value = "开始日期") @RequestParam(required = false) String startTime,
                                               @ApiParam(required = false, value = "结束日期") @RequestParam(required = false) String endTime) throws InterruptedException {

        PickSummary pickSummary = pickLogic.summary(startTime, endTime);

        return ResponseHelper.success(pickSummary);
    }

    @ApiOperation(value = "提货经销商列表")
    @GetMapping("/listCustomer")
    public ResponseHelper<IPage<KingDeeCustomer>> listCustomer(
            @ApiParam(required = false, value = "经销商名称") @RequestParam(required = false) String keyword,
            @ApiParam(required = false, value = "经销商编码") @RequestParam(required = false) String region,
            @ApiParam(required = false, value = "电话") @RequestParam(required = false) String phone,
            @ApiParam(value = "页号",required = true)@RequestParam Integer pageNum,
            @ApiParam(value = "页大小",required = true)@RequestParam Integer pageSize
    ) throws Exception {
        IPage<KingDeeCustomer> list = pickLogic.listCustomer(phone,keyword, region,pageNum, pageSize);
        return ResponseHelper.success(list);
    }


    @ApiOperation(value = "同步提货列表")
    @PostMapping("/listPush")
    @ApiNotAuth
    @Sign
    public ResponseHelper<PickBean> listPush(
            @ApiParam(required = false, value = "更新时间,秒级别") @RequestParam(required = false) String encrypted
    ) throws Exception {
        PickBean pickBean = pickLogic.listPush(encrypted);
        String pi = JSONUtil.toJsonStr(pickBean);
        return ResponseHelper.success(pickBean);
    }

    @ApiOperation(value = "订单查询物流")
    @GetMapping("/listOrderTrack")
    public ResponseHelper<List<OrderTrack>> listOrderTrack(
            @ApiParam(required = true, value = "订单号") @RequestParam(required = true) String orderId

    ) throws Exception {
        List<OrderTrack> list = pickLogic.listOrderTrack(orderId);
        return ResponseHelper.success(list);
    }


    @ApiOperation(value = "物流通知")
    @GetMapping("/listInvoiceOrder")
    public ResponseHelper<Page<InvoiceApplicationPick>> listInvoiceOrder(
            @ApiParam(required = false, value = "发货单号") @RequestParam(required = false) String invoiceId,
            @ApiParam(required = false, value = "开始时间") @RequestParam(required = false) String startTime,
            @ApiParam(required = false, value = "结束时间") @RequestParam(required = false) String endTime,
            @ApiParam(required = false, value = "收货客户") @RequestParam(required = false) String userName,
            @ApiParam(required = false, value = "收货地址") @RequestParam(required = false) String address,
            @ApiParam(required = false, value = "内容") @RequestParam(required = false) String remark,
            @ApiParam(value = "页号",required = true)@RequestParam Integer pageNum,
            @ApiParam(value = "页大小",required = true)@RequestParam Integer pageSize
    ) throws Exception {
        Page<InvoiceApplicationPick> list = pickLogic.listInvoiceOrder(pageNum,pageSize,invoiceId,startTime,endTime,userName,address,remark);
        return ResponseHelper.success(list);
    }

    @ApiOperation(value = "物流通知20秒拉取新消息")
    @GetMapping("/listInvoiceOrderTWO")
    public ResponseHelper<Page<InvoiceApplicationPick>> listInvoiceOrderTWO(
            @ApiParam(required = false, value = "发货单号") @RequestParam(required = false) String invoiceId,
            @ApiParam(required = false, value = "开始时间") @RequestParam(required = false) String startTime,
            @ApiParam(required = false, value = "结束时间") @RequestParam(required = false) String endTime,
            @ApiParam(required = false, value = "收货客户") @RequestParam(required = false) String userName,
            @ApiParam(required = false, value = "收货地址") @RequestParam(required = false) String address,
            @ApiParam(required = false, value = "内容") @RequestParam(required = false) String remark,
            @ApiParam(value = "页号",required = true)@RequestParam Integer pageNum,
            @ApiParam(value = "页大小",required = true)@RequestParam Integer pageSize
    ) throws Exception {
        Page<InvoiceApplicationPick> list = pickLogic.listInvoiceOrderTWO(pageNum,pageSize,invoiceId,startTime,endTime,userName,address,remark);
        return ResponseHelper.success(list);
    }


}

