package org.ta.pddserver;

import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.ta.pddserver.entity.LogOrderMailDetailEntity;
import org.ta.pddserver.model.enums.OrderProblemType;
import org.ta.pddserver.model.pddjy.request.*;
import org.ta.pddserver.model.pddjy.response.PddServiceConsoDerelictionResponse;
import org.ta.pddserver.utils.PddHttpTool;
import org.ta.pddserver.utils.PddSignTool;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

@Slf4j
public class CommonTest {

    private static final String PROVIDER_CODE = "HAIJI_KR";
    private static final String WAREHOUSE_CODE = "HJJY001";

    private static final String CLIENT_ID = "d0217707e1194c46b57e696ac7619a06";
    private static final String CLIENT_SECRET = "a5aba84483d8387030899f01276b06a194942470";

    private static String getNowString() {
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return sdf.format(date);
    }

    @Test
    public void Test1() {
        PddServiceConsoDerelictionRequest derelictionRequest = new PddServiceConsoDerelictionRequest();
        derelictionRequest.setProviderCode(PROVIDER_CODE);
        derelictionRequest.setExecuteTime("2025-10-23 14:53:22");
        derelictionRequest.setTimeZone("UTC+8");
        derelictionRequest.setMailNo("2343534632");
        derelictionRequest.setExpressCode("快递公司编码");
        derelictionRequest.setDereRecogCode("D00NJL01");
        log.info("derelictionRequest:{}", JSON.toJSONString(derelictionRequest));
        JYBaseRequestModel requestModel = new JYBaseRequestModel();
        requestModel.setRequest(JSON.toJSONString(derelictionRequest));
        requestModel.setRequest_id("111");
        requestModel.setType("pdd.service.conso.dereliction");
        requestModel.setTarget_client_id(CLIENT_ID);
        requestModel.setClient_id(CLIENT_ID);
        long time = new Date().getTime() / 1000;
        requestModel.setTimestamp(time);
        requestModel.setSign(PddSignTool.generateSign(requestModel, CLIENT_SECRET));
        log.info("requestModel:{}", JSON.toJSONString(requestModel));
//        String resp = PddHttpTool.postRequest(requestModel);
        String resp = PddHttpTool.sendJsonPost(requestModel);
        log.info("resp = {}", resp);
    }

    @Test
    public void Test2() {
        PddServiceConsoFirstBizActionNotifyRequest notifyRequest = new PddServiceConsoFirstBizActionNotifyRequest();
        notifyRequest.setProviderCode(PROVIDER_CODE);
        notifyRequest.setExecuteTime("2025-10-23 14:53:22");
        notifyRequest.setTimeZone("UTC+8");
        notifyRequest.setLogisticsOrderCode("xx198985333");
        notifyRequest.setBizAction("warehouse_sign");
        notifyRequest.setBizActionDesc("仓库签收");
        notifyRequest.setMailNo("234546666");
        notifyRequest.setExpressCode("快递公司编码");
        PddServiceConsoFirstBizActionNotifyRequest.Result notifyResult = new PddServiceConsoFirstBizActionNotifyRequest.Result();
        notifyResult.setCode(22);
        notifyResult.setDesc("运输品类限制");
        notifyRequest.setResult(notifyResult);
        log.info("derelictionRequest:{}", JSON.toJSONString(notifyRequest));
        JYBaseRequestModel requestModel = new JYBaseRequestModel();
        requestModel.setRequest(JSON.toJSONString(notifyRequest));
        requestModel.setRequest_id("111");
        requestModel.setType("pdd.service.conso.first.biz.action.notify");
        requestModel.setTarget_client_id(CLIENT_ID);
        requestModel.setClient_id(CLIENT_ID);
        long time = new Date().getTime() / 1000;
        requestModel.setTimestamp(time);
        requestModel.setSign(PddSignTool.generateSign(requestModel, CLIENT_SECRET));
        log.info("requestModel:{}", JSON.toJSONString(requestModel));
//        String resp = PddHttpTool.postRequest(requestModel);
        String resp = PddHttpTool.sendJsonPost(requestModel);
        log.info("resp = {}", resp);
    }


    /**
     * 确认收货
     */
    @Test
    public void receive() {
        String LogisticsOrderCode = "PC25102914698518937718059";
        String mailNo = "TT3713660160898";
        String expressCode = "STO";
        String action = "warehouse_sign";
        PddServiceConsoFirstBizActionNotifyRequest notifyRequest = new PddServiceConsoFirstBizActionNotifyRequest();
        notifyRequest.setProviderCode(PROVIDER_CODE);
        notifyRequest.setExecuteTime(getNowString());
        notifyRequest.setTimeZone("UTC+8");
        notifyRequest.setLogisticsOrderCode(LogisticsOrderCode);
        notifyRequest.setBizAction(action);
        PddServiceConsoFirstBizActionNotifyRequest.Result notifyResult = new PddServiceConsoFirstBizActionNotifyRequest.Result();
        notifyRequest.setMailNo(mailNo);
        notifyRequest.setExpressCode(expressCode);
        if (action == "warehouse_sign") {
            notifyRequest.setBizActionDesc("仓库签收");
            notifyResult.setCode(0);
        } else if (action == "warehouse_reject_sign") {
            notifyRequest.setBizActionDesc("仓库拒签");

            notifyResult.setCode(22);
            notifyResult.setDesc("运输品类限制");
            notifyResult.setRemark("运输品类限制");
            notifyRequest.setResult(notifyResult);
        } else if (action == "destroy") {
            notifyRequest.setBizActionDesc("包裹销毁");
            notifyResult.setCode(0);
        }
        notifyRequest.setResult(notifyResult);


        log.info("derelictionRequest:{}", JSON.toJSONString(notifyRequest));
        JYBaseRequestModel requestModel = new JYBaseRequestModel();
        requestModel.setRequest(JSON.toJSONString(notifyRequest));
        requestModel.setRequest_id("" + new Date().getTime());
        requestModel.setType("pdd.service.conso.first.biz.action.notify");
        requestModel.setTarget_client_id(CLIENT_ID);
        requestModel.setClient_id(CLIENT_ID);
        long time = new Date().getTime() / 1000;
        requestModel.setTimestamp(time);
        requestModel.setSign(PddSignTool.generateSign(requestModel, CLIENT_SECRET));
        log.info("requestModel:{}", JSON.toJSONString(requestModel));
//        String resp = PddHttpTool.postRequest(requestModel);
        String resp = PddHttpTool.sendJsonPost(requestModel);
        log.info("resp = {}", resp);
    }

    /**
     * 拒收
     */
    @Test
    public void reject() {
        String LogisticsOrderCode = "PC25102916466837504518059";
        String mailNo = "773763730734477";
        String expressCode = "STO";
        String action = "warehouse_reject_sign";
        PddServiceConsoFirstBizActionNotifyRequest notifyRequest = new PddServiceConsoFirstBizActionNotifyRequest();
        notifyRequest.setProviderCode(PROVIDER_CODE);
        notifyRequest.setExecuteTime(getNowString());
        notifyRequest.setTimeZone("UTC+8");
        notifyRequest.setLogisticsOrderCode(LogisticsOrderCode);
        notifyRequest.setBizAction(action);
        PddServiceConsoFirstBizActionNotifyRequest.Result notifyResult = new PddServiceConsoFirstBizActionNotifyRequest.Result();
        notifyRequest.setMailNo(mailNo);
        notifyRequest.setExpressCode(expressCode);
        if (action == "warehouse_sign") {
            notifyRequest.setBizActionDesc("仓库签收");
            notifyResult.setCode(0);
        } else if (action == "warehouse_reject_sign") {
            notifyRequest.setBizActionDesc("仓库拒签");
            notifyResult.setCode(22);
            notifyResult.setDesc("运输品类限制");
            notifyResult.setRemark("运输品类限制");
            notifyRequest.setResult(notifyResult);
        } else if (action == "destroy") {
            notifyRequest.setBizActionDesc("包裹销毁");
            notifyResult.setCode(0);
        }
        notifyRequest.setResult(notifyResult);


        log.info("derelictionRequest:{}", JSON.toJSONString(notifyRequest));
        JYBaseRequestModel requestModel = new JYBaseRequestModel();
        requestModel.setRequest(JSON.toJSONString(notifyRequest));
        requestModel.setRequest_id("" + new Date().getTime());
        requestModel.setType("pdd.service.conso.first.biz.action.notify");
        requestModel.setTarget_client_id(CLIENT_ID);
        requestModel.setClient_id(CLIENT_ID);
        long time = new Date().getTime() / 1000;
        requestModel.setTimestamp(time);
        requestModel.setSign(PddSignTool.generateSign(requestModel, CLIENT_SECRET));
        log.info("requestModel:{}", JSON.toJSONString(requestModel));
//        String resp = PddHttpTool.postRequest(requestModel);
        String resp = PddHttpTool.sendJsonPost(requestModel);
        log.info("resp = {}", resp);
    }

    /**
     * 入库
     */
    @Test
    public void inBound() {

        String LogisticsOrderCode = "PC25102914698518937718059";
        String mailNo = "TT3713660160898";
        String expressCode = "STO";
        PddServiceConsoInboundRequest notifyRequest = new PddServiceConsoInboundRequest();


//        PddServiceConsoFirstBizActionNotifyRequest notifyRequest = new PddServiceConsoFirstBizActionNotifyRequest();
        notifyRequest.setProviderCode(PROVIDER_CODE);
        notifyRequest.setLogisticsOrderCode(LogisticsOrderCode);
        notifyRequest.setExecuteTime(getNowString());
        notifyRequest.setTimeZone("UTC+8");

        notifyRequest.setStatus("FULL_INBOUND");
//        notifyRequest.setStatus("PART_INBOUND");
        notifyRequest.setPackageQuantity(1L);

        notifyRequest.setPackageInfo(new PddServiceConsoInboundRequest.PackageInfo());
        notifyRequest.getPackageInfo().setMailNo(mailNo);
        notifyRequest.getPackageInfo().setExpressCode(expressCode);
        notifyRequest.getPackageInfo().setLength(30L);
        notifyRequest.getPackageInfo().setWidth(30L);
        notifyRequest.getPackageInfo().setHeight(30L);
        notifyRequest.getPackageInfo().setWeight(300L);
        notifyRequest.getPackageInfo().setActualWeight(300L);
        notifyRequest.getPackageInfo().setGoodsType("NORMAL");

        notifyRequest.setResult(new PddServiceConsoInboundRequest.Result());
        notifyRequest.getResult().setCode(0);

        log.info("derelictionRequest:{}", JSON.toJSONString(notifyRequest));
        JYBaseRequestModel requestModel = new JYBaseRequestModel();
        requestModel.setRequest(JSON.toJSONString(notifyRequest));
        requestModel.setRequest_id("" + new Date().getTime());
        requestModel.setType("pdd.service.conso.inbound");
        requestModel.setTarget_client_id(CLIENT_ID);
        requestModel.setClient_id(CLIENT_ID);
        long time = new Date().getTime() / 1000;
        requestModel.setTimestamp(time);
        requestModel.setSign(PddSignTool.generateSign(requestModel, CLIENT_SECRET));
        log.info("requestModel:{}", JSON.toJSONString(requestModel));
//        String resp = PddHttpTool.postRequest(requestModel);
        String resp = PddHttpTool.sendJsonPost(requestModel);
        log.info("resp = {}", resp);
    }

    /**
     * 开始拣货
     */
    @Test
    public void beginPick() {
        String LogisticsOrderCode = "PP25102913743895347818059";
        String mailNo = "773833357957029";
        String expressCode = "STO";
        String action = "begin_pick";
        PddServiceConsoCoBizActionNotifyRequest notifyRequest = new PddServiceConsoCoBizActionNotifyRequest();
        notifyRequest.setProviderCode(PROVIDER_CODE);
        notifyRequest.setOrderCode(LogisticsOrderCode);
        notifyRequest.setBizAction(action);
        notifyRequest.setExecuteTime(getNowString());
        notifyRequest.setTimeZone("UTC+8");


        PddServiceConsoCoBizActionNotifyRequest.Result notifyResult = new PddServiceConsoCoBizActionNotifyRequest.Result();
//        notifyRequest.setMailNo(mailNo);
//        notifyRequest.setExpressCode(expressCode);
        if (action == "begin_pick") {
            notifyRequest.setBizActionDesc("开始拣货");
            notifyResult.setCode(0);
        } else if (action == "finish_pick") {
            notifyRequest.setBizActionDesc("拣货完成");
            notifyResult.setCode(0);
        } else if (action == "finish_unpack") {
            notifyRequest.setBizActionDesc("拆包完成");
            notifyRequest.setUnpackRemark("");
            notifyResult.setCode(0);
        }
        notifyRequest.setResult(notifyResult);


        log.info("derelictionRequest:{}", JSON.toJSONString(notifyRequest));
        JYBaseRequestModel requestModel = new JYBaseRequestModel();
        requestModel.setRequest(JSON.toJSONString(notifyRequest));
        requestModel.setRequest_id("" + new Date().getTime());
        requestModel.setType("pdd.service.conso.co.biz.action.notify");
        requestModel.setTarget_client_id(CLIENT_ID);
        requestModel.setClient_id(CLIENT_ID);
        long time = new Date().getTime() / 1000;
        requestModel.setTimestamp(time);
        requestModel.setSign(PddSignTool.generateSign(requestModel, CLIENT_SECRET));
        log.info("requestModel:{}", JSON.toJSONString(requestModel));
//        String resp = PddHttpTool.postRequest(requestModel);
        String resp = PddHttpTool.sendJsonPost(requestModel);
        log.info("resp = {}", resp);
    }

    /**
     * 完成拣货
     */
    @Test
    public void finishPick() {
        String LogisticsOrderCode = "PP25102913743895347818059";
        String mailNo = "773833357957029";
        String expressCode = "STO";
        String action = "finish_pick";
        PddServiceConsoCoBizActionNotifyRequest notifyRequest = new PddServiceConsoCoBizActionNotifyRequest();
        notifyRequest.setProviderCode(PROVIDER_CODE);
        notifyRequest.setOrderCode(LogisticsOrderCode);
        notifyRequest.setBizAction(action);
        notifyRequest.setExecuteTime(getNowString());
        notifyRequest.setTimeZone("UTC+8");


        PddServiceConsoCoBizActionNotifyRequest.Result notifyResult = new PddServiceConsoCoBizActionNotifyRequest.Result();
//        notifyRequest.setMailNo(mailNo);
//        notifyRequest.setExpressCode(expressCode);
        if (action == "begin_pick") {
            notifyRequest.setBizActionDesc("开始拣货");
            notifyResult.setCode(0);
        } else if (action == "finish_pick") {
            notifyRequest.setBizActionDesc("拣货完成");
            notifyResult.setCode(0);
        } else if (action == "finish_unpack") {
            notifyRequest.setBizActionDesc("拆包完成");
            notifyRequest.setUnpackRemark("");
            notifyResult.setCode(0);
            notifyRequest.setPackageInfos(new ArrayList<>());
            PddServiceConsoCoBizActionNotifyRequest.PackageInfo packageInfo = new PddServiceConsoCoBizActionNotifyRequest.PackageInfo();
            notifyRequest.getPackageInfos().add(packageInfo);
            packageInfo.setWeight(280L);
            packageInfo.setWidth(28L);
            packageInfo.setHeight(28L);
            packageInfo.setLength(28L);
            packageInfo.setActualWeight(280L);
            packageInfo.setConsoType("SEA");
            packageInfo.setGoodsType("NORMAL");
        }
        notifyRequest.setResult(notifyResult);


        log.info("derelictionRequest:{}", JSON.toJSONString(notifyRequest));
        JYBaseRequestModel requestModel = new JYBaseRequestModel();
        requestModel.setRequest(JSON.toJSONString(notifyRequest));
        requestModel.setRequest_id("" + new Date().getTime());
        requestModel.setType("pdd.service.conso.co.biz.action.notify");
        requestModel.setTarget_client_id(CLIENT_ID);
        requestModel.setClient_id(CLIENT_ID);
        long time = new Date().getTime() / 1000;
        requestModel.setTimestamp(time);
        requestModel.setSign(PddSignTool.generateSign(requestModel, CLIENT_SECRET));
        log.info("requestModel:{}", JSON.toJSONString(requestModel));
//        String resp = PddHttpTool.postRequest(requestModel);
        String resp = PddHttpTool.sendJsonPost(requestModel);
        log.info("resp = {}", resp);
    }


    /**
     * 拣货完成后出库
     */
    @Test
    public void outBound() {

        String mailNo = "773467488920323";
        String expressCode = "STO";
        String orderCode = "PP25102914698518937618059";
//        String segmentCode = "RETURNSELLER";
        String segmentCode = "SENDTORECEVER";

        PddServiceConsoOutboundRequest notifyRequest = new PddServiceConsoOutboundRequest();

        notifyRequest.setProviderCode(PROVIDER_CODE);
        notifyRequest.setOrderCode(orderCode);
        notifyRequest.setSegmentCode(segmentCode);
        notifyRequest.setExecuteTime(getNowString());
        notifyRequest.setTimeZone("UTC+8");
        notifyRequest.setIsSplitOut("N");
        notifyRequest.setPackageInfos(new ArrayList<>());
        PddServiceConsoOutboundRequest.PackageInfo packageInfo = new PddServiceConsoOutboundRequest.PackageInfo();
        notifyRequest.getPackageInfos().add(packageInfo);
        packageInfo.setOutboundMailNo(mailNo);
        packageInfo.setExpressCode(expressCode);
        packageInfo.setPackageType("2");
        packageInfo.setLength(28L);
        packageInfo.setWidth(28L);
        packageInfo.setHeight(28L);
        packageInfo.setWeight(280L);

        notifyRequest.setSenderDetail(new PddServiceConsoOutboundRequest.SenderDetail());
        notifyRequest.getSenderDetail().setName("海际集货仓");
        notifyRequest.getSenderDetail().setTelePhone("18660975251");
        notifyRequest.getSenderDetail().setCountry("CN");
        notifyRequest.getSenderDetail().setProvince("山东省");
        notifyRequest.getSenderDetail().setCity("临沂市");
        notifyRequest.getSenderDetail().setDistrict("兰山区");
        notifyRequest.getSenderDetail().setDetailAddress("山东省临沂市兰山区横九路与纵十路交汇兰山财金智慧云仓五期二层二号仓");

        notifyRequest.setReceiverDetail(new PddServiceConsoOutboundRequest.ReceiverDetail());
        notifyRequest.getReceiverDetail().setName("nanjiexi");
        notifyRequest.getReceiverDetail().setTelePhone("01099999999");
        notifyRequest.getReceiverDetail().setCountry("KR");
        notifyRequest.getReceiverDetail().setProvince("서울특별시");
        notifyRequest.getReceiverDetail().setCity("강북구");
        notifyRequest.getReceiverDetail().setDistrict("우이동");
        notifyRequest.getReceiverDetail().setDetailAddress("서울특별시测试地址");

        notifyRequest.setResult(new PddServiceConsoOutboundRequest.Result());
        notifyRequest.getResult().setCode(0);
//        notifyRequest.getResult().setDesc("");
//        notifyRequest.getResult().setRemark("");


        log.info("derelictionRequest:{}", JSON.toJSONString(notifyRequest));
        JYBaseRequestModel requestModel = new JYBaseRequestModel();
        requestModel.setRequest(JSON.toJSONString(notifyRequest));
        requestModel.setRequest_id("" + new Date().getTime());
        requestModel.setType("pdd.service.conso.outbound");
        requestModel.setTarget_client_id(CLIENT_ID);
        requestModel.setClient_id(CLIENT_ID);
        long time = new Date().getTime() / 1000;
        requestModel.setTimestamp(time);
        requestModel.setSign(PddSignTool.generateSign(requestModel, CLIENT_SECRET));
        log.info("requestModel:{}", JSON.toJSONString(requestModel));
//        String resp = PddHttpTool.postRequest(requestModel);
        String resp = PddHttpTool.sendJsonPost(requestModel);
        log.info("resp = {}", resp);
    }

    /**
     * 收到拆包通知后 完成拆包 （不一定收到出库通知）
     */
    @Test
    public void finishUnpack() {
        String LogisticsOrderCode = "PP25102914698518937618059";
        String mailNo = "773467488920323";
        String expressCode = "STO";
        String action = "finish_unpack";
        PddServiceConsoCoBizActionNotifyRequest notifyRequest = new PddServiceConsoCoBizActionNotifyRequest();
        notifyRequest.setProviderCode(PROVIDER_CODE);
        notifyRequest.setOrderCode(LogisticsOrderCode);
        notifyRequest.setBizAction(action);
        notifyRequest.setExecuteTime(getNowString());
        notifyRequest.setTimeZone("UTC+8");


        PddServiceConsoCoBizActionNotifyRequest.Result notifyResult = new PddServiceConsoCoBizActionNotifyRequest.Result();
//        notifyRequest.setMailNo(mailNo);
//        notifyRequest.setExpressCode(expressCode);
        if (action == "begin_pick") {
            notifyRequest.setBizActionDesc("开始拣货");
            notifyResult.setCode(0);
        } else if (action == "finish_pick") {
            notifyRequest.setBizActionDesc("拣货完成");
            notifyResult.setCode(0);
        } else if (action == "finish_unpack") {
            notifyRequest.setBizActionDesc("拆包完成");
            notifyRequest.setUnpackRemark("");
            notifyResult.setCode(0);
            notifyRequest.setPackageInfos(new ArrayList<>());
            PddServiceConsoCoBizActionNotifyRequest.PackageInfo packageInfo = new PddServiceConsoCoBizActionNotifyRequest.PackageInfo();
            notifyRequest.getPackageInfos().add(packageInfo);
            packageInfo.setWeight(280L);
            packageInfo.setWidth(28L);
            packageInfo.setHeight(28L);
            packageInfo.setLength(28L);
            packageInfo.setActualWeight(280L);
            packageInfo.setConsoType("SEA");
            packageInfo.setGoodsType("NORMAL");
        }
        notifyRequest.setResult(notifyResult);


        log.info("derelictionRequest:{}", JSON.toJSONString(notifyRequest));
        JYBaseRequestModel requestModel = new JYBaseRequestModel();
        requestModel.setRequest(JSON.toJSONString(notifyRequest));
        requestModel.setRequest_id("" + new Date().getTime());
        requestModel.setType("pdd.service.conso.co.biz.action.notify");
        requestModel.setTarget_client_id(CLIENT_ID);
        requestModel.setClient_id(CLIENT_ID);
        long time = new Date().getTime() / 1000;
        requestModel.setTimestamp(time);
        requestModel.setSign(PddSignTool.generateSign(requestModel, CLIENT_SECRET));
        log.info("requestModel:{}", JSON.toJSONString(requestModel));
//        String resp = PddHttpTool.postRequest(requestModel);
        String resp = PddHttpTool.sendJsonPost(requestModel);
        log.info("resp = {}", resp);
    }

    /**
     * 无主件识别
     */
    @Test
    public void dereliction() {
        String mailNo = "TT3713660160898";
        String expressCode = "STO";
        String dereRecogCode = "51029HYX06800";
        PddServiceConsoDerelictionRequest notifyRequest = new PddServiceConsoDerelictionRequest();
        notifyRequest.setProviderCode(PROVIDER_CODE);
        notifyRequest.setExecuteTime(getNowString());
        notifyRequest.setTimeZone("UTC+8");
        notifyRequest.setMailNo(mailNo);
        notifyRequest.setExpressCode(expressCode);
        notifyRequest.setDereRecogCode(dereRecogCode);

        log.info("derelictionRequest:{}", JSON.toJSONString(notifyRequest));
        JYBaseRequestModel requestModel = new JYBaseRequestModel();
        requestModel.setRequest(JSON.toJSONString(notifyRequest));
        requestModel.setRequest_id("" + new Date().getTime());
        requestModel.setType("pdd.service.conso.dereliction");
        requestModel.setTarget_client_id(CLIENT_ID);
        requestModel.setClient_id(CLIENT_ID);
        long time = new Date().getTime() / 1000;
        requestModel.setTimestamp(time);
        requestModel.setSign(PddSignTool.generateSign(requestModel, CLIENT_SECRET));
        log.info("requestModel:{}", JSON.toJSONString(requestModel));
//        String resp = PddHttpTool.postRequest(requestModel);
        String resp = PddHttpTool.sendJsonPost(requestModel);
        log.info("resp = {}", resp);
        PddServiceConsoDerelictionResponse response = JSON.parseObject(resp, PddServiceConsoDerelictionResponse.class);
        String logisticsOrderCode = response.getLogisticsOrderCode();
        log.info("logisticsOrderCode = {}", logisticsOrderCode);
    }

    /**
     * 问题件上传
     */
    @Test
    public void problemNofity() {
        String mailNo = "TT3713660160898";
        String expressCode = "STO";
        String orderCode = "PC25102914698518937718059";
        PddServiceConsoProblemOrderNotifyRequest notifyRequest = new PddServiceConsoProblemOrderNotifyRequest();
        notifyRequest.setProviderCode(PROVIDER_CODE);
        notifyRequest.setExecuteTime(getNowString());
        notifyRequest.setTimeZone("UTC+8");
        notifyRequest.setMailInfos(new ArrayList<>());
        PddServiceConsoProblemOrderNotifyRequest.MailInfo mailInfo = new PddServiceConsoProblemOrderNotifyRequest.MailInfo();
        notifyRequest.getMailInfos().add(mailInfo);
        mailInfo.setMailNo(mailNo);
        mailInfo.setOrderCode(orderCode);
        mailInfo.setExpressCode(expressCode);
        mailInfo.setReasonCode(OrderProblemType.PoSun.getValue());

        log.info("derelictionRequest:{}", JSON.toJSONString(notifyRequest));
        JYBaseRequestModel requestModel = new JYBaseRequestModel();
        requestModel.setRequest(JSON.toJSONString(notifyRequest));
        requestModel.setRequest_id("" + new Date().getTime());
        requestModel.setType("pdd.service.conso.problem.order.notify");
        requestModel.setTarget_client_id(CLIENT_ID);
        requestModel.setClient_id(CLIENT_ID);
        long time = new Date().getTime() / 1000;
        requestModel.setTimestamp(time);
        requestModel.setSign(PddSignTool.generateSign(requestModel, CLIENT_SECRET));
        log.info("requestModel:{}", JSON.toJSONString(requestModel));
//        String resp = PddHttpTool.postRequest(requestModel);
        String resp = PddHttpTool.sendJsonPost(requestModel);
        log.info("resp = {}", resp);

    }


}
