Bläddra i källkod

一号专线接口下单&尾程信息

zhangdehua 1 år sedan
förälder
incheckning
ff6e6b3762

+ 33 - 0
app/common.php

@@ -440,3 +440,36 @@ function getStoreId(): int
 {
     return 10001;
 }
+
+
+function curl_post($url, $data = [],array $header = [])
+{
+    //$header[] = "Content-type: text/xml";//设置http报文头text/xml
+
+    $ch = curl_init();
+    curl_setopt($ch, CURLOPT_POST, 1);//1:post方式 0:get方式
+    curl_setopt($ch, CURLOPT_HEADER, 0);
+    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+    curl_setopt($ch, CURLOPT_URL, $url);
+    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
+    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
+    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+    $result = curl_exec($ch);
+    curl_close($ch);
+    return $result;
+}
+
+function curl_get($url)
+{
+    $header[] = "Accept: application/json";
+    $ch = curl_init();
+    curl_setopt($ch, CURLOPT_POST, 0);//1:post方式 0:get方式
+    curl_setopt($ch, CURLOPT_HEADER, 0);
+    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+    curl_setopt($ch, CURLOPT_URL, $url);
+    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
+    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+    $result = curl_exec($ch);
+    curl_close($ch);
+    return $result;
+}

+ 55 - 7
app/common/library/express/Usps.php

@@ -15,6 +15,7 @@ namespace app\common\library\express;
 use think\facade\Cache;
 use cores\traits\ErrorTrait;
 use app\common\library\helper;
+use think\facade\Log;
 
 /**
  * 快递USPS模块
@@ -50,7 +51,7 @@ class Usps
     public function query(string $expressNo)
     {
         // 缓存索引
-        $cacheIndex = 'express_usps_'. $expressNo;
+        $cacheIndex = 'express_usps_' . $expressNo;
         if ($cacheData = Cache::get($cacheIndex)) {
             return $cacheData;
         }
@@ -59,13 +60,12 @@ class Usps
         // 请求快递100 api
         $result = $this->curlPost(self::QUERY_URL, $postDataXML);
 
-        if(array_key_exists('HTTP_RAW_POST_DATA', $GLOBALS))
-        {
+        if (array_key_exists('HTTP_RAW_POST_DATA', $GLOBALS)) {
             $post_data = $GLOBALS['HTTP_RAW_POST_DATA'];//php接收xml文件的唯一方式
-            $post_obj = SimpleXml_load_String($post_data,'SimpleXMLElement',LIBXML_NOCDATA);//加载xml
+            $post_obj = SimpleXml_load_String($post_data, 'SimpleXMLElement', LIBXML_NOCDATA);//加载xml
             //$username = (string)$post_obj->username;//直接获取xml中username的值
             //todo
-        }else{
+        } else {
             return false;
         }
 
@@ -110,12 +110,12 @@ class Usps
     public function queryF1(string $expressNo)
     {
         // 缓存索引
-        $cacheIndex = 'express_usps_'. $expressNo;
+        $cacheIndex = 'express_usps_' . $expressNo;
         if ($cacheData = Cache::get($cacheIndex)) {
             return $cacheData;
         }
         // 请求快递100 api
-        $result = $this->curlGet(self::QUERY_URL.$expressNo);
+        $result = $this->curlGet(self::QUERY_URL . $expressNo);
 
         $express = helper::jsonDecode($result);
         // 记录错误信息
@@ -128,6 +128,54 @@ class Usps
         return $express['data'];
     }
 
+    //查询尾程信息
+    public function queryTrackingInfo(string $expressNo)
+    {
+        // 缓存索引
+        $cacheIndex = 'express_usps_' . $expressNo;
+        if ($cacheData = Cache::get($cacheIndex)) {
+            return $cacheData;
+        }
+        $params = ['keHuDanHaoList' => $expressNo, 'type' => 3];
+        // 请求快递100 api
+        $url = 'http://f1.itdida.com/itdida-api/trackingInfo' . http_build_query($params);
+
+        $result = $this->curlGet(self::QUERY_URL . $expressNo);
+
+        $express = helper::jsonDecode($result);
+        // 记录错误信息
+        if (!isset($express['data']) || !empty($express['errorMsg'])) {
+            $this->error = $express['errorMsg'] ?? '查询失败';
+            return false;
+        }
+        // 记录缓存, 时效30分钟
+        Cache::set($cacheIndex, $express['data'], 3000);
+        return $express['data'];
+    }
+
+    public function getItdidaToken()
+    {
+        $token = Cache::get('ItdidaToken');
+        if (empty($token)) {
+            $params = ['username' => '18665946835', 'password' => 'Yh123456'];
+
+            $url = 'http://f1.itdida.com/itdida-api/login?' . http_build_query($params);
+            $header = ['Content-Type: application/x-www-form-urlencode'];
+            //$res = curl_post($url, [], $header);
+            $resJson = '{"data":"eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhODFiMzZkNGYwZDUxMWVlODM1YjViMWQ1MmE0NjcxNSIsImNyZWF0ZWQiOjE3MTM0OTc1MzQ1MDEsInJvbGVzIjpbeyJhdXRob3JpdHkiOiJST0xFX0tFSFUifV0sImRvbWFpbiI6ImYxIiwiZXhwIjoxNzEzNjcwMzM0fQ.bMVc3E2pTJFA0wztgizsXpqexD65TH471lRpj92jqgVKx2-q2qqhevUMRmZ73c2TQihDVXvmjlaNp0dPdEgZDg","statusCode":200,"success":true}';
+            $res = json_decode($resJson, true);
+            if (isset($res['statusCode']) && $res['statusCode'] == 200 && $res['success']) {
+                Cache::set('ItdidaToken', $res['data'], 169200);
+                return $res['data'];
+            } else {
+                Log::error('getItdidaToken失败::' . json_encode($res));
+                return null;
+            }
+        } else {
+            return $token;
+        }
+    }
+
     private function curlGet($url)
     {
         $header[] = "Accept: application/json";

+ 2 - 1
app/common/model/Express.php

@@ -122,7 +122,8 @@ class Express extends BaseModel
         // 实例化快递100类
         $Usps = new Usps();
         // 请求查询接口
-        $data['list'] = $Usps->queryF1($expressNo);
+        //$data['list'] = $Usps->queryF1($expressNo);
+        $data['list'] = $Usps->queryTrackingInfo($expressNo);
         if ($data['list'] === false) {
             Log::error('有问题');
             return false;

+ 24 - 0
app/console/model/Order.php

@@ -45,6 +45,30 @@ class Order extends OrderModel
     }
 
     /**
+     * 未发货列表
+     * @param int $storeId
+     * @param array $filter
+     * @param array $with
+     * @return Order[]|array|\think\Collection
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    public function getUsableList(int $storeId, array $filter = [])
+    {
+        // 获取数据列表
+        return $this->with(['goods', 'address'])
+            ->where($filter)
+            ->where('store_id', '=', $storeId)
+            ->where('pay_status', '=', PayStatusEnum::SUCCESS)
+            ->where('delivery_status', '=', DeliveryStatus::NOT_DELIVERED)
+            ->where('order_status', '=', OrderStatusEnum::NORMAL)
+            ->where('is_delete', '=', 0)
+            ->limit(1)
+            ->select();
+    }
+
+    /**
      * 获取订单ID集
      * @param int $storeId 商城ID
      * @param array $filter

+ 25 - 0
app/console/model/UploadFile.php

@@ -0,0 +1,25 @@
+<?php
+// +----------------------------------------------------------------------
+// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
+// +----------------------------------------------------------------------
+// | Author: 萤火科技 <admin@yiovo.com>
+// +----------------------------------------------------------------------
+declare (strict_types=1);
+
+namespace app\console\model;
+
+use app\common\model\UploadFile as UploadFileModel;
+
+/**
+ * 文件库模型
+ * Class UploadFile
+ * @package app\store\model
+ */
+class UploadFile extends UploadFileModel
+{
+
+}

+ 182 - 0
app/console/service/OrderGetYundan.php

@@ -0,0 +1,182 @@
+<?php
+// +----------------------------------------------------------------------
+// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
+// +----------------------------------------------------------------------
+// | Author: 萤火科技 <admin@yiovo.com>
+// +----------------------------------------------------------------------
+declare (strict_types=1);
+
+namespace app\console\service;
+
+use app\common\library\express\Usps;
+use app\common\library\helper;
+use app\console\library\Tools;
+use app\common\service\BaseService;
+use app\console\model\Order as OrderModel;
+use think\facade\Log;
+
+
+/**
+ * 服务类:会员等级
+ * Class UserGrade
+ * @package app\console\service
+ */
+class OrderGetYundan extends BaseService
+{
+    /**
+     * 设置用户的会员等级
+     * @param int $storeId
+     * @return array|bool
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    public function orderCreateYundans(int $storeId)
+    {
+        $Usps = new Usps();
+        // 请求查询接口
+        $token = $Usps->getItdidaToken();
+        if (empty($token)) {
+            Log::error('无有效的Iddida token');
+            return false;
+        }
+
+        // 获取所有待发货订单
+        $list = $this->getUsableList($storeId);
+        // 遍历等级,根据升级条件 查询满足消费金额的用户列表,并且他的等级小于该等级
+        $data = [];
+
+        $url = 'http://f1.itdida.com/itdida-api/yundans';
+        $params =
+            [
+                "baoGuanFangShi" => 0,
+                "baoGuoLeiXing" => 1,
+                "cardType" => 0,
+                "clientId" => $token,
+                "danJianList" => [
+                    [
+                        "chang" => 1,
+                        "gao" => 1,
+                        "kuan" => 1,
+                        "origBoardNum" => 0,
+                        "shiZhong" => 0.5,
+                        "stackable" => true
+                    ]
+                ],
+                "eori" => "",
+                "extraFreight" => 0,
+                "freightPaymentWay" => 0,
+                "fuShuiJin" => 0,
+                "guoJia" => "US",
+                "huoWuTeXing" => "带电",
+                "ioss" => "",
+                "jianShu" => 1,//to fix
+                "kapaiWaybill" => false,
+                "keHuDanHao" => "",//todo fill
+                "maiJiaId" => "",//to fill
+                "needDispatch" => false,
+                "needValidateAddress" => false,
+                "pushBackLabelAndInvoice" => false,
+                "qiTaDanHao1" => "JCX0415047275YQ",
+                "requiredChangeNo" => false,
+                "requiredTrackNo" => true,
+                "requiredZhuanDanFaPiao" => false,
+                "shenBaoXinXiList" => [
+                    [
+                        "shenBaoBiZhong" => "USD",
+                        "shenBaoDanJia" => 0,//todo fill 申报单价
+                        "shenBaoHaiGuanBianMa" => "",
+                        "shenBaoJinE" => 0,////todo fill 申报金额
+                        "shenBaoPinMing" => "",//todo fill 品名
+                        "shenBaoShuLiang" => 1,
+                        "zhongWenPinMing" => ""//to fill
+                    ],
+                ],
+                "shouHuoQuDao" => "美国专线小包普货",
+                "shouHuoShiZhong" => 0.500,
+                "shouJianRenChengShi" => "",//to fill收货城市
+                "shouJianRenDiZhi1" => "",//to fill收货地址
+                "shouJianRenDiZhi2" => "",
+                "shouJianRenDiZhi3" => "",
+                "shouJianRenDianHua" => "",//to fill收货电话
+                "shouJianRenGongSi" => "",
+                "shouJianRenXingMing" => "",//to fill收货人姓名
+                "shouJianRenYouBian" => "",//to fill收货人邮编
+                "skuText" => "null,null,null",
+                "synPushBill" => false,
+                "tradeTerms" => "",
+                "useReferenceApi" => false,
+                "wuLiuFangShi" => 2,
+                "zhouMing" => ""//to fill收货人州名
+
+        ];
+
+        $headers = [
+            "Content-type: application/json;charset=utf-8",
+            //'Content-Length: ' . strlen($data_string)),
+            "Authorization: {$token}",
+            "Accept: */*"
+        ];
+        foreach ($list as $item) {
+            $params['keHuDanHao'] = $item['order_no'];
+            $params['maiJiaId'] = $item['user_id'];
+            $params['zhouMing'] = $item['address']['region']['code'];
+            $params['shouJianRenChengShi'] = $item['address']['city'];
+            $params['shouJianRenYouBian'] = $item['address']['zip_code'];
+
+            $params['shouJianRenDianHua'] = $item['address']['phone'];
+            $params['shouJianRenDiZhi1'] = $item['address']['detail'];
+            $params['shouJianRenXingMing'] = $item['address']['name'] . ' ' . $item['address']['last_name'];
+
+            $goodsList = [];
+            foreach ($item['goods'] as $good) {
+                $goodsList[] = [
+                    "shenBaoBiZhong" => "USD",
+                    "shenBaoDanJia" => $good['goods_price'],//todo fill 申报单价
+                    "shenBaoHaiGuanBianMa" => "",
+                    "shenBaoJinE" => $good['total_price'],//todo fill 申报金额
+                    "shenBaoPinMing" => "vape",//$good['goods_name'],//todo fill 品名
+                    "shenBaoShuLiang" => $good['total_num'],
+                    "zhongWenPinMing" => "电子烟"//todo fill
+                ];
+            }
+            $params['shenBaoXinXiList'] = $goodsList;
+            $resJson = curl_post($url, [$params], $headers);
+            Log::write('itdida::' . $resJson);
+            $res = json_decode($resJson, true);
+            // 遍历整理数据
+            if (isset($res['data']) && $res['data'][0]['code'] == 200) {
+                $model = \app\store\model\Order::detail($item['order_id']);
+                if (!$model->delivery(['express_id' => 10001, 'express_no' => $res['data']['zhuanDanHao']])) {
+                    Log::write('发货失败orderId:' . $item['order_id'],'error');
+                }
+            }else{
+                Log::write('itdida运单失败::orderNo:' . $item['order_no'] . $resJson,'error');
+            }
+            sleep(1);
+        }
+        // 记录日志
+        Tools::taskLogs('UserGrade', 'setUserGrade', [
+            'storeId' => $storeId,
+            'data' => $data
+        ]);
+    }
+
+    /**
+     * 获取所有会员等级
+     * @param int $storeId 商城ID
+     * @return false|\think\Collection
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    private function getUsableList(int $storeId)
+    {
+        $orderModel = new OrderModel();
+        return $orderModel->getUsableList($storeId);
+    }
+}

+ 62 - 0
app/console/task/OrderGetYundan.php

@@ -0,0 +1,62 @@
+<?php
+// +----------------------------------------------------------------------
+// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
+// +----------------------------------------------------------------------
+// | Author: 萤火科技 <admin@yiovo.com>
+// +----------------------------------------------------------------------
+declare (strict_types = 1);
+
+namespace app\console\task;
+
+use app\console\service\OrderGetYundan as OrderGetYundanService;
+
+/**
+ * 定时任务:订单定时获取运单
+ * Class UserGrade
+ * @package app\console\task
+ */
+class OrderGetYundan extends Task
+{
+    // 当前任务唯一标识
+    private $taskKey = 'OrderGetYundan';
+
+    // 任务执行间隔时长 (单位:秒)
+    protected $taskExpire = 60 * 5;
+
+    // 当前商城ID
+    private $storeId;
+
+    /**
+     * 任务处理
+     * @param array $param
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    public function handle(array $param)
+    {
+        ['storeId' => $this->storeId] = $param;
+        $this->setInterval($this->storeId, $this->taskKey, $this->taskExpire, function () {
+            echo $this->taskKey . PHP_EOL;
+            // 设置用户的会员等级
+            $this->orderGetYundans();
+        });
+    }
+
+    /**
+     * 设置用户的会员等级
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    private function orderGetYundans()
+    {
+        $service = new OrderGetYundanService();
+        $service->orderCreateYundans($this->storeId);
+    }
+
+}

+ 19 - 0
app/index/controller/Index.php

@@ -2,6 +2,9 @@
 
 namespace app\index\controller;
 
+use app\common\library\express\Usps;
+use app\console\model\Order as OrderModel;
+use app\console\service\OrderGetYundan as OrderGetYundanService;
 use app\index\model\Article as ArticleModel;
 use app\index\model\Comment as CommentModel;
 use app\index\model\Goods as GoodsModel;
@@ -173,4 +176,20 @@ class Index extends Controller
         $article = $model->find($newsId)->toArray();
         return view('newsDetails', ['article' => $article]);
     }
+
+    public function goldTest()
+    {
+        $service = new OrderGetYundanService();
+        $r = $service->orderCreateYundans($this->storeId);
+        dd($r);
+
+        $orderModel = new OrderModel();
+        $r = $orderModel->getUsableList(10001);
+        dd($r->toArray());
+
+        $Usps = new Usps();
+        // 请求查询接口
+        $res =  $Usps->getItdidaToken();
+        dd($res);
+    }
 }

+ 7 - 6
app/index/controller/Order.php

@@ -112,14 +112,15 @@ class Order extends Controller
     public function expressUsps(int $orderId): Json
     {
         // 订单信息
-        $order = OrderModel::getDetail($orderId);
-        if (!$order['express_no']) {
-            return $this->renderError('No logistics information');
-        }
-        $expressUserId  = config('usps.exp_user_id');
+//        $order = OrderModel::getDetail($orderId);
+//        if (!$order['express_no']) {
+//            return $this->renderError('No logistics information');
+//        }
+        //$expressUserId  = config('usps.exp_user_id');
+        $order['express_no'] = 'AT354585357CN';
         // 获取物流信息
         $model = new ExpressModel();
-        $express = $model->dynamicUsps($expressUserId, $order['express_no']);
+        $express = $model->dynamicUsps($order['express_no']);
         if ($express === false) {
             return $this->renderError($model->getError());
         }

+ 14 - 0
app/store/controller/order/Event.php

@@ -14,6 +14,7 @@ namespace app\store\controller\order;
 
 use app\store\controller\Controller;
 use app\store\model\Order as OrderModel;
+use app\store\service\order\DeliveryByF1;
 
 /**
  * 订单操作控制器
@@ -39,6 +40,19 @@ class Event extends Controller
     }
 
     /**
+     * 壹号专线发货
+     * @param int $orderId
+     * @return \think\response\Json
+     * @throws \Exception
+     */
+    public function deliveryByF1(int $orderId)
+    {
+        $f1Service = new DeliveryByF1();
+        $res = $f1Service->orderCreateYundan($orderId);
+        return $this->renderError($res['message'] ?: '发货失败');
+    }
+
+    /**
      * 修改订单价格
      * @param int $orderId
      * @return array

+ 170 - 0
app/store/service/order/DeliveryByF1.php

@@ -0,0 +1,170 @@
+<?php
+// +----------------------------------------------------------------------
+// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
+// +----------------------------------------------------------------------
+// | Author: 萤火科技 <admin@yiovo.com>
+// +----------------------------------------------------------------------
+declare (strict_types=1);
+
+namespace app\store\service\order;
+
+use app\common\library\express\Usps;
+use app\console\library\Tools;
+use app\store\model\{Order as OrderModel, order\Export as ExportModel, OrderAddress as OrderAddressModel};
+use app\common\library\helper;
+use app\common\service\BaseService;
+use app\common\service\Goods as GoodsService;
+use app\common\enum\order\{
+    PayType as PayTypeEnum,
+    PayStatus as PayStatusEnum,
+    OrderSource as OrderSourceEnum,
+    OrderStatus as OrderStatusEnum,
+    DeliveryType as DeliveryTypeEnum,
+    ReceiptStatus as ReceiptStatusEnum,
+    DeliveryStatus as DeliveryStatusEnum,
+    export\ExportStatus as ExportStatusEnum
+};
+use cores\exception\BaseException;
+use think\facade\Log;
+
+/**
+ * 服务层:订单导出Excel
+ * Class Export
+ * @package app\store\service\order
+ */
+class DeliveryByF1 extends BaseService
+{
+    /**
+     * 设置用户的会员等级
+     * @param int $storeId
+     * @return array|bool
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    public function orderCreateYundan(int $orderId)
+    {
+        $Usps = new Usps();
+        // 请求查询接口
+        $token = $Usps->getItdidaToken();
+        if (empty($token)) {
+            Log::error('无有效的Iddida token');
+            return false;
+        }
+
+        $url = 'http://f1.itdida.com/itdida-api/yundans';
+        $params =
+            [
+                "baoGuanFangShi" => 0,
+                "baoGuoLeiXing" => 1,
+                "cardType" => 0,
+                "clientId" => $token,
+                "danJianList" => [
+                    [
+                        "chang" => 1,
+                        "gao" => 1,
+                        "kuan" => 1,
+                        "origBoardNum" => 0,
+                        "shiZhong" => 0.5,
+                        "stackable" => true
+                    ]
+                ],
+                "eori" => "",
+                "extraFreight" => 0,
+                "freightPaymentWay" => 0,
+                "fuShuiJin" => 0,
+                "guoJia" => "US",
+                "huoWuTeXing" => "带电",
+                "ioss" => "",
+                "jianShu" => 1,//to fix
+                "kapaiWaybill" => false,
+                //"keHuDanHao" => "",//todo fill
+                //"maiJiaId" => "",//to fill
+                "needDispatch" => false,
+                "needValidateAddress" => false,
+                "pushBackLabelAndInvoice" => false,
+                "qiTaDanHao1" => "JCX0415047275YQ",
+                "requiredChangeNo" => false,
+                "requiredTrackNo" => true,
+                "requiredZhuanDanFaPiao" => false,
+/*                "shenBaoXinXiList" => [
+                    [
+                        "shenBaoBiZhong" => "USD",
+                        "shenBaoDanJia" => 0,//todo fill 申报单价
+                        "shenBaoHaiGuanBianMa" => "",
+                        "shenBaoJinE" => 0,////todo fill 申报金额
+                        "shenBaoPinMing" => "",//todo fill 品名
+                        "shenBaoShuLiang" => 1,
+                        "zhongWenPinMing" => ""//to fill
+                    ],
+                ],*/
+                "shouHuoQuDao" => "美国专线小包普货",
+                "shouHuoShiZhong" => 0.500,
+                //"shouJianRenChengShi" => "",//to fill收货城市
+                //"shouJianRenDiZhi1" => "",//to fill收货地址
+                "shouJianRenDiZhi2" => "",
+                "shouJianRenDiZhi3" => "",
+                //"shouJianRenDianHua" => "",//to fill收货电话
+                "shouJianRenGongSi" => "",
+                //"shouJianRenXingMing" => "",//to fill收货人姓名
+                //"shouJianRenYouBian" => "",//to fill收货人邮编
+                "skuText" => "null,null,null",
+                "synPushBill" => false,
+                "tradeTerms" => "",
+                "useReferenceApi" => false,
+                "wuLiuFangShi" => 2,
+                //"zhouMing" => ""//to fill收货人州名
+
+            ];
+
+        $headers = [
+            "Content-type: application/json;charset=utf-8",
+            //'Content-Length: ' . strlen($data_string)),
+            "Authorization: {$token}",
+            "Accept: */*"
+        ];
+
+        $model = OrderModel::detail($orderId, ['goods', 'address']);
+
+        $params['keHuDanHao'] = $model['order_no'];
+        $params['maiJiaId'] = $model['user_id'];
+        $params['zhouMing'] = $model['address']['region']['code'];
+        $params['shouJianRenChengShi'] = $model['address']['city'];
+        $params['shouJianRenYouBian'] = $model['address']['zip_code'];
+
+        $params['shouJianRenDianHua'] = $model['address']['phone'];
+        $params['shouJianRenDiZhi1'] = $model['address']['detail'];
+        $params['shouJianRenXingMing'] = $model['address']['name'] . ' ' . $model['address']['last_name'];
+
+        $goodsList = [];
+        foreach ($model['goods'] as $good) {
+            $goodsList[] = [
+                "shenBaoBiZhong" => "USD",
+                "shenBaoDanJia" => $good['goods_price'],//todo fill 申报单价
+                "shenBaoHaiGuanBianMa" => "",
+                "shenBaoJinE" => $good['total_price'],//todo fill 申报金额
+                "shenBaoPinMing" => "vape",//$good['goods_name'],//todo fill 品名
+                "shenBaoShuLiang" => $good['total_num'],
+                "zhongWenPinMing" => "电子烟"//todo fill
+            ];
+        }
+        $params['shenBaoXinXiList'] = $goodsList;
+        $resJson = curl_post($url, [$params], $headers);
+        Log::write('itdida::' . $resJson);
+        $res = json_decode($resJson, true);
+        // 遍历整理数据
+        if (isset($res['data']) && $res['data'][0]['code'] == 200) {
+            if (!$model->delivery(['express_id' => 10001, 'express_no' => $res['data'][0]['zhuanDanHao']])) {
+                Log::write('发货失败orderId:' . $model['order_id'], 'error');
+                return ['code' => 200, 'message' => '发货成功',];
+            }
+        } else {
+            Log::write('itdida运单失败::orderNo:' . $model['order_no'] . $resJson, 'error');
+            return ['code' => 400, 'message' => $res['data'][0]['message']];
+        }
+    }
+}