package org.ta.pddserver;

import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
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 = "PC25110315105366425637527";
        String mailNo = "773888539989914";
        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 = "PC25110309183009177837527";
        String mailNo = "773074032778146";
        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(20);
            notifyResult.setDesc("超大");
            notifyResult.setRemark("超大");
            notifyRequest.setResult(notifyResult);
            PddServiceConsoFirstBizActionNotifyRequest.PackageInfo packageInfo = new PddServiceConsoFirstBizActionNotifyRequest.PackageInfo();
            notifyRequest.setPackageInfo(packageInfo);
            packageInfo.setWidth(100L);
            packageInfo.setHeight(100L);
            packageInfo.setLength(100L);
            packageInfo.setWeight(30000L);
            packageInfo.setActualWeight(30000L);
        } 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 = "PC25110315105366425637527";
        String mailNo = "773888539989914";
        String expressCode = "STO";
        PddServiceConsoInboundRequest notifyRequest = new PddServiceConsoInboundRequest();


//        PddServiceConsoFirstBizActionNotifyRequest notifyRequest = new PddServiceConsoFirstBizActionNotifyRequest();
        notifyRequest.setProviderCode(PROVIDER_CODE);
        notifyRequest.setLogisticsOrderCode(LogisticsOrderCode);
        notifyRequest.setExecuteTime(getNowString());
//        notifyRequest.setExecuteTime("2025-05-04 00:00:00");
        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(1000L);
        notifyRequest.getPackageInfo().setActualWeight(1000L);
        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 = "PP25110323338785177837527";
        String mailNo = "773129289243424";
        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 = "PP25110323338785177837527";
        String mailNo = "773129289243424";
        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(1100L);
            packageInfo.setWidth(30L);
            packageInfo.setLength(30L);
            packageInfo.setHeight(30L);
            packageInfo.setActualWeight(1100L);
            packageInfo.setConsoType("SEA");
            packageInfo.setGoodsType("SPECIAL");
        }
        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 = "BK-25110316466837504237527";
        String expressCode = "KR_JD";
        String orderCode = "PP25110316466837504237527";
//        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.setIsSplitOut("Y");



        notifyRequest.setPackageInfos(new ArrayList<>());
        PddServiceConsoOutboundRequest.PackageInfo packageInfo0 = new PddServiceConsoOutboundRequest.PackageInfo();
        notifyRequest.getPackageInfos().add(packageInfo0);
        packageInfo0.setOutboundMailNo(mailNo + "1");
        packageInfo0.setExpressCode(expressCode);
        packageInfo0.setPackageType("2");
        packageInfo0.setLength(30L);
        packageInfo0.setWidth(30L);
        packageInfo0.setHeight(30L);
        packageInfo0.setWeight(1500L);
        packageInfo0.setInboundMailDetails(new ArrayList<>());
        PddServiceConsoOutboundRequest.InboundMailDetail inboundMailDetail0 = new PddServiceConsoOutboundRequest.InboundMailDetail();
        packageInfo0.getInboundMailDetails().add(inboundMailDetail0);
        inboundMailDetail0.setMailNo("773608936457954");
        inboundMailDetail0.setExpressCode("STO");
        PddServiceConsoOutboundRequest.InboundMailDetail inboundMailDetail1 = new PddServiceConsoOutboundRequest.InboundMailDetail();
        packageInfo0.getInboundMailDetails().add(inboundMailDetail1);
        inboundMailDetail1.setMailNo("773010635902734");
        inboundMailDetail1.setExpressCode("STO");

        PddServiceConsoOutboundRequest.PackageInfo packageInfo = new PddServiceConsoOutboundRequest.PackageInfo();
        notifyRequest.getPackageInfos().add(packageInfo);
        packageInfo.setOutboundMailNo(mailNo + "2");
        packageInfo.setExpressCode(expressCode);
        packageInfo.setPackageType("2");
        packageInfo.setLength(30L);
        packageInfo.setWidth(30L);
        packageInfo.setHeight(30L);
        packageInfo.setWeight(1500L);
        packageInfo.setInboundMailDetails(new ArrayList<>());
        PddServiceConsoOutboundRequest.InboundMailDetail inboundMailDetail2 = new PddServiceConsoOutboundRequest.InboundMailDetail();
        packageInfo.getInboundMailDetails().add(inboundMailDetail2);
        inboundMailDetail2.setMailNo("TT773010635902734");
        inboundMailDetail2.setExpressCode("STO");

        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("김명상");
        notifyRequest.getReceiverDetail().setTelePhone("01012345678");
        notifyRequest.getReceiverDetail().setCountry("KR");
        notifyRequest.getReceiverDetail().setProvince("서울특별시");
        notifyRequest.getReceiverDetail().setCity("강북구");
        notifyRequest.getReceiverDetail().setDistrict("강북구");
        notifyRequest.getReceiverDetail().setDetailAddress("护照1号");

        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 = "PP25110323338785177837527";
//        String mailNo = "773129289243424";
        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 packageInfo0 = new PddServiceConsoCoBizActionNotifyRequest.PackageInfo();
            notifyRequest.getPackageInfos().add(packageInfo0);
            packageInfo0.setWeight(1500L);
            packageInfo0.setWidth(30L);
            packageInfo0.setHeight(30L);
            packageInfo0.setLength(20L);
            packageInfo0.setActualWeight(1500L);
            packageInfo0.setConsoType("SEA");
            packageInfo0.setGoodsType("NORMAL");

            PddServiceConsoCoBizActionNotifyRequest.PackageInfo packageInfo = new PddServiceConsoCoBizActionNotifyRequest.PackageInfo();
            notifyRequest.getPackageInfos().add(packageInfo);
            packageInfo.setWeight(1500L);
            packageInfo.setWidth(30L);
            packageInfo.setHeight(30L);
            packageInfo.setLength(20L);
            packageInfo.setActualWeight(1500L);
            packageInfo.setConsoType("SEA");
            packageInfo.setGoodsType("SPECIAL");
        }
        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 = "TT773010635902734";
        String expressCode = "STO";
        String dereRecogCode = "51103HHF52832";
        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);

    }


    @Test
    public void testFee() {

    }


}
