Ver código fonte

定时任务

afa 2 meses atrás
pai
commit
5cd7443527

+ 29 - 29
app/admin/command/Task.php → app/admin/command/TaskDy.php

@@ -12,29 +12,41 @@ declare(strict_types=1);
 namespace app\admin\command;
 
 use app\common\model\FengsuShip;
+
 use think\console\Command;
 use think\console\Input;
 use think\console\Output;
 use GuzzleHttp\Client;
+use app\common\model\CrontabLog;
+use app\common\model\FengsuSku;
+use app\common\model\ShopList;
+use app\common\model\ProductConfig;
+use app\common\model\ShopDelivery;
+use app\common\model\CustomerSpec;
+use app\admin\service\FengsuService;
 use GuzzleHttp\Psr7\Request;
 
-class Task extends Command
+//抖音
+class TaskDy extends Command
 {
     // 指令配置
     protected function configure()
     {
-        $this->setName('task')->setDescription('the task command');
+        $this->setName('task:dy')->setDescription('the task command');
     }
 
     //根据shop_id
     protected function execute(Input $input, Output $output)
     {
         $client = new Client([ 'verify' => false]);
+        $last_time = CrontabLog::getLastRunTime(0);
         $body = '{
         "goodType": 2,
         "goodsFlag": 1,
         "current": 1,
         "size": 25,
+        "startTime": "'.$last_time.'",
+        "endTime": "'.date('Y-m-d H:i:s').'",
         "skuOuterIdExact": false,
         "skuPropExact": false,
         "sort": "CONSIGN_TIME",
@@ -42,7 +54,7 @@ class Task extends Command
         "timeType": 2,
         "tradeStatus": 2
         }';
-        $request = new Request('POST', $this->getUrl('xhs'), $this->getHeaders('xhs'), $body);
+        $request = new Request('POST', $this->getUrl('dy'), $this->getHeaders('dy'), $body);
         $res = $client->sendAsync($request)->wait();
         if($res->getStatusCode() == 200) {
             $data = json_decode($res->getBody()->getContents(), true);  
@@ -52,7 +64,13 @@ class Task extends Command
                 return;
             }
             $queue = [];
+            $shopList = new ShopList();
+            $fengsuSku = new FengsuSku();
+            $productConfig = new ProductConfig();
+            $shopDelivery = new ShopDelivery();
+            $customerSpec = new CustomerSpec();
             foreach($list as $item) {
+                $status = FengsuService::getAdditionalPrice( $shopList, $fengsuSku, $productConfig, $shopDelivery, $customerSpec, $item);
                 $queue[] = [
                     'shop_id'       => $item['shopId'],
                     'trade_from'    => $item['tradeFrom'],
@@ -66,12 +84,18 @@ class Task extends Command
                     'num'           => $item['tradeOrderPrintVos'][0]['total'],
                     'goods_title'   => $item['tradeOrderPrintVos'][0]['goodsTitle'],
                     'weigh'         => $item['tradeOrderPrintVos'][0]['weight'],
-                    'price'         => bcdiv((string)$item['payment'], '100', 2)
+                    'price'         => bcdiv((string)$item['payment'], '100', 2),
+                    'status'        => $status,
                 ];
             }
             
             // 保存到数据库
             (new FengsuShip())->saveAll($queue);
+            // 更新最后执行时间
+            CrontabLog::create([
+                'type_id' => 0,
+                'last_time' => date('Y-m-d H:i:s'),
+            ]);
         }
 
         // 指令输出
@@ -148,7 +172,7 @@ class Task extends Command
                 'doudian-event-id' => '1757940551000163',
                 'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 Edg/140.0.0.0',
                 'Accept' => 'application/json, text/plain, */*',
-                'platform' => 'tb',
+                'platform' => 'dy',
                 'Origin' => 'https://fx.fengsutb.com',
                 'Sec-Fetch-Site' => 'same-site',
                 'Sec-Fetch-Mode' => 'cors',
@@ -225,28 +249,4 @@ class Task extends Command
     }
 
 
-    /**
-     * 获取偏远地区加收费用
-     * @param string $express 快递公司名称
-     * @param string $area 省份
-     * @param float $weight 重量
-     * @param string $city 城市
-     * @return float
-     */
-    protected function getRemoteAreaFee(string $express, float $weight, string $area, string $city = ''){
-        $remote_area = config('app.remote_area_fee');
-        $fee = 0;
-        if($express == '顺丰快递'){
-            if(in_array($area, $remote_area[0])) {
-                if($weight >= 3.5) $fee = 5;
-                if($weight >= 4.5) $fee = 6;
-            };
-        }else{
-            //普通(广东省-深圳) -浙江-舟山
-            if(in_array($area, $remote_area[0])) $fee = 1.5;
-            if($area == '广东省' && $city == '深圳市') $fee = 1.5;
-            if($area == '浙江省' && $city == '舟山市') $fee = 1.5;
-        }
-        return $fee;
-    }
 }

+ 252 - 0
app/admin/command/TaskJd.php

@@ -0,0 +1,252 @@
+<?php
+/**
+ * ----------------------------------------------------------------------------
+ * 行到水穷处,坐看云起时
+ * 开发软件,找贵阳云起信息科技,官网地址:https://www.56q7.com/
+ * ----------------------------------------------------------------------------
+ * Author: 老成
+ * email:85556713@qq.com
+ */
+declare(strict_types=1);
+
+namespace app\admin\command;
+
+use app\common\model\FengsuShip;
+
+use think\console\Command;
+use think\console\Input;
+use think\console\Output;
+use GuzzleHttp\Client;
+use app\common\model\CrontabLog;
+use app\common\model\FengsuSku;
+use app\common\model\ShopList;
+use app\common\model\ProductConfig;
+use app\common\model\ShopDelivery;
+use app\common\model\CustomerSpec;
+use app\admin\service\FengsuService;
+use GuzzleHttp\Psr7\Request;
+
+//京东
+class TaskJd extends Command
+{
+    // 指令配置
+    protected function configure()
+    {
+        $this->setName('task:jd')->setDescription('the task command');
+    }
+
+    //根据shop_id
+    protected function execute(Input $input, Output $output)
+    {
+        $client = new Client([ 'verify' => false]);
+        $last_time = CrontabLog::getLastRunTime(0);
+        $body = '{
+        "goodType": 2,
+        "goodsFlag": 1,
+        "current": 1,
+        "size": 25,
+        "startTime": "'.$last_time.'",
+        "endTime": "'.date('Y-m-d H:i:s').'",
+        "skuOuterIdExact": false,
+        "skuPropExact": false,
+        "sort": "CONSIGN_TIME",
+        "sortAsc": false,
+        "timeType": 2,
+        "tradeStatus": 2
+        }';
+        $request = new Request('POST', $this->getUrl('dy'), $this->getHeaders('dy'), $body);
+        $res = $client->sendAsync($request)->wait();
+        if($res->getStatusCode() == 200) {
+            $data = json_decode($res->getBody()->getContents(), true);  
+            $list = $data['data']['list'];
+            if(empty($list)) {
+                $output->writeln('无数据');
+                return;
+            }
+            $queue = [];
+            $shopList = new ShopList();
+            $fengsuSku = new FengsuSku();
+            $productConfig = new ProductConfig();
+            $shopDelivery = new ShopDelivery();
+            $customerSpec = new CustomerSpec();
+            foreach($list as $item) {
+                $status = FengsuService::getAdditionalPrice( $shopList, $fengsuSku, $productConfig, $shopDelivery, $customerSpec, $item);
+                $queue[] = [
+                    'shop_id'       => $item['shopId'],
+                    'trade_from'    => $item['tradeFrom'],
+                    'province'      => $item['receiverProvince'],
+                    'city'          => $item['receiverCity'],
+                    'company_name'  => $item['tradeOrderPrintVos'][0]['companyName'],
+                    'waybill_no'    => $item['waybillNo'],
+                    'consign_time'  => $item['consignTime'],
+                    'goods_id'      => $item['tradeOrderPrintVos'][0]['goodsId'],
+                    'sku_id'        => $item['tradeOrderPrintVos'][0]['skuId'],
+                    'num'           => $item['tradeOrderPrintVos'][0]['total'],
+                    'goods_title'   => $item['tradeOrderPrintVos'][0]['goodsTitle'],
+                    'weigh'         => $item['tradeOrderPrintVos'][0]['weight'],
+                    'price'         => bcdiv((string)$item['payment'], '100', 2),
+                    'status'        => $status,
+                ];
+            }
+            
+            // 保存到数据库
+            (new FengsuShip())->saveAll($queue);
+            // 更新最后执行时间
+            CrontabLog::create([
+                'type_id' => 0,
+                'last_time' => date('Y-m-d H:i:s'),
+            ]);
+        }
+
+        // 指令输出
+        $output->writeln('ok');
+    }
+
+
+    //获取请求url
+    protected function getUrl(string $key):string
+    {
+        $url = [
+            'tb'  => 'https://fszntb.zhifeiyun.cn/amount/ship-list-new', //淘宝
+            'pdd' => 'https://fsfxpdd.fengsutb.com/amount/ship-list-new', //拼多多
+            'dy'  => 'https://fsdy2.fengsutb.com/amount/ship-list-new', //抖音
+            'ks'  => 'https://fsks.fengsutb.com/amount/ship-list-new',   //快手
+            'jd'  => 'https://fsjd.fengsutb.com/amount/ship-list-new', //京东
+            'xhs' => 'https://fsxpt.fengsutb.com/amount/ship-list-new', //小红书
+        ];
+        return $url[$key] ?? $url['tb'];
+    }
+
+    //获取头部
+    protected function getHeaders(string $key):array{
+        $header = [
+            'tb' =>[
+                'Accept'=> "application/json, text/plain, */*",
+                'Accept-Encoding'=> "gzip, deflate, br, zstd",
+                'Accept-Language'=> "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
+                "Authorization"=> "Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZmEiLCJuaWtlIjoi6Zi_5Y-R5rWL6YCfIiwiY3JlYXRlZCI6MTc1ODc5MDI4NDU3OSwiZHBJZCI6MTkxOTQwLCJleHAiOjE3NTkwNDk0ODQsImVuYWJsZWQiOnRydWUsImF1dGhvcml0aWVzIjpbInpodXlvbmdodSJdLCJkcEFjY291bnRJZCI6MTc4MzU3fQ.TuHvPz7Jf0vuYsbrxX9VpyZ2oOrtZ0YzLQJafoX_RV8up1PmtPLfPATBE93_v_1Ig39nODadaTb4aePy3b0hsA",
+                "Cache-Control"=> "no-cache",
+                "Content-Type"=> "application/json",
+                "Origin"=> "https://fx.fengsutb.com",
+                "platform" => "tb",
+                "Pragma"=> "no-cache",
+                "priority" => "u=1, i",
+                "Referer"=> "https://fx.fengsutb.com/",
+                "Sec-ch-ua" => '"Chromium";v="140", "Not=A?Brand";v="24", "Microsoft Edge";v="140"',
+                "Sec-ch-ua-Mobile"=> "?0",
+                "Sec-ch-ua-platform"=> "Windows",
+                "Sec-Fetch-Dest" => "empty",
+                "Sec-Fetch-Mode" => "cors",
+                "Sec-Fetch-Site" => "same-site",
+                "User-Agent" => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 Edg/140.0.0.0"
+            ],
+            'pdd' =>[
+                'Accept'=> "application/json, text/plain, */*",
+                'Accept-Encoding'=> "gzip, deflate, br, zstd",
+                'Accept-Language'=> "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
+                "Authorization"=> "Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZmEiLCJuaWtlIjoi6Zi_5Y-R5rWL6YCfIiwiY3JlYXRlZCI6MTc1ODc5MDI4NDU3OSwiZHBJZCI6MTkxOTQwLCJleHAiOjE3NTkwNDk0ODQsImVuYWJsZWQiOnRydWUsImF1dGhvcml0aWVzIjpbInpodXlvbmdodSJdLCJkcEFjY291bnRJZCI6MTc4MzU3fQ.TuHvPz7Jf0vuYsbrxX9VpyZ2oOrtZ0YzLQJafoX_RV8up1PmtPLfPATBE93_v_1Ig39nODadaTb4aePy3b0hsA",
+                "Cache-Control"=> "no-cache",
+                "Content-Type"=> "application/json",
+                "Origin"=> "https://fx.fengsutb.com",
+                "platform" => "pdd",
+                "Pragma"=> "no-cache",
+                "priority" => "u=1, i",
+                "Referer"=> "https://fx.fengsutb.com/",
+                "Sec-ch-ua" => '"Chromium";v="140", "Not=A?Brand";v="24", "Microsoft Edge";v="140"',
+                "Sec-ch-ua-Mobile"=> "?0",
+                "Sec-ch-ua-platform"=> "Windows",
+                "Sec-Fetch-Dest" => "empty",
+                "Sec-Fetch-Mode" => "cors",
+                "Sec-Fetch-Site" => "same-site",
+                "User-Agent" => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 Edg/140.0.0.0",
+                'X-Pdd-Pagecode' => '62f9d7a661b14717564e309aebbb4d47f8988f758f91',
+                'X-Pdd-Pati'     => 'D08NxRGxLLD5hYKZU1nqgE2b9IVrGjdv',
+            ],
+            'dy'=> [
+                'Host' => 'fsdy2.fengsutb.com',
+                'Connection' => 'keep-alive',
+                'sec-ch-ua-platform' => 'Windows',
+                'Authorization' => 'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZmEiLCJuaWtlIjoi6Zi_5Y-R5rWL6YCfIiwiY3JlYXRlZCI6MTc1ODcwMzg4MzMyMSwiZHBJZCI6MTkxOTQwLCJleHAiOjE3NTg5NjMwODMsImVuYWJsZWQiOnRydWUsImF1dGhvcml0aWVzIjpbInpodXlvbmdodSJdLCJkcEFjY291bnRJZCI6MTc4MzU3fQ.ZXaztcUDDlZDgepOqFwaQfzd4RcINNiIv54or0r-b7DJw9aKw7zjH8RmUIE7yqTcyQ_g6r7aGdpn9hf-hIukBg',
+                'sec-ch-ua' => '"Chromium";v="140", "Not=A?Brand";v="24", "Microsoft Edge";v="140"',
+                'sec-ch-ua-mobile' => '?0',
+                'doudian-event-id' => '1757940551000163',
+                'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 Edg/140.0.0.0',
+                'Accept' => 'application/json, text/plain, */*',
+                'platform' => 'dy',
+                'Origin' => 'https://fx.fengsutb.com',
+                'Sec-Fetch-Site' => 'same-site',
+                'Sec-Fetch-Mode' => 'cors',
+                'Sec-Fetch-Dest' => 'empty',
+                'Referer' => 'https://fx.fengsutb.com/',
+                'Accept-Language' => 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
+                'Content-Type' => 'application/json',
+            ],
+            'ks'=> [
+                'Accept'=> "application/json, text/plain, */*",
+                'Accept-Encoding'=> "gzip, deflate, br, zstd",
+                'Accept-Language'=> "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
+                "Authorization"=> "Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZmEiLCJuaWtlIjoi6Zi_5Y-R5rWL6YCfIiwiY3JlYXRlZCI6MTc1ODc5MDI4NDU3OSwiZHBJZCI6MTkxOTQwLCJleHAiOjE3NTkwNDk0ODQsImVuYWJsZWQiOnRydWUsImF1dGhvcml0aWVzIjpbInpodXlvbmdodSJdLCJkcEFjY291bnRJZCI6MTc4MzU3fQ.TuHvPz7Jf0vuYsbrxX9VpyZ2oOrtZ0YzLQJafoX_RV8up1PmtPLfPATBE93_v_1Ig39nODadaTb4aePy3b0hsA",
+                "Cache-Control"=> "no-cache",
+                'Connection'   => 'keep-alive',
+                "Content-Type"=> "application/json",
+                "Host"      => "fsks.fengsutb.com",
+                "Origin"    => "https://fx.fengsutb.com",
+                "platform" => "ks",
+                "Pragma"=> "no-cache",
+                "Referer"=> "https://fx.fengsutb.com/",
+                "Sec-ch-ua" => '"Chromium";v="140", "Not=A?Brand";v="24", "Microsoft Edge";v="140"',
+                "Sec-ch-ua-Mobile"=> "?0",
+                "Sec-ch-ua-platform"=> "Windows",
+                "Sec-Fetch-Dest" => "empty",
+                "Sec-Fetch-Mode" => "cors",
+                "Sec-Fetch-Site" => "same-site",
+                "User-Agent" => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 Edg/140.0.0.0"
+            ],
+            'jd'  => [
+                'Accept'=> "application/json, text/plain, */*",
+                'Accept-Encoding'=> "gzip, deflate, br, zstd",
+                'Accept-Language'=> "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
+                "Authorization"=> "Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZmEiLCJuaWtlIjoi6Zi_5Y-R5rWL6YCfIiwiY3JlYXRlZCI6MTc1ODc5MDI4NDU3OSwiZHBJZCI6MTkxOTQwLCJleHAiOjE3NTkwNDk0ODQsImVuYWJsZWQiOnRydWUsImF1dGhvcml0aWVzIjpbInpodXlvbmdodSJdLCJkcEFjY291bnRJZCI6MTc4MzU3fQ.TuHvPz7Jf0vuYsbrxX9VpyZ2oOrtZ0YzLQJafoX_RV8up1PmtPLfPATBE93_v_1Ig39nODadaTb4aePy3b0hsA",
+                "Cache-Control"=> "no-cache",
+                'Connection'   => 'keep-alive',
+                "Content-Type"=> "application/json",
+                "Host"      => "fsjd.fengsutb.com",
+                "Origin"    => "https://fx.fengsutb.com",
+                "platform" => "jd",
+                "Pragma"=> "no-cache",
+                "Referer"=> "https://fx.fengsutb.com/",
+                "Sec-ch-ua" => '"Chromium";v="140", "Not=A?Brand";v="24", "Microsoft Edge";v="140"',
+                "Sec-ch-ua-Mobile"=> "?0",
+                "Sec-ch-ua-platform"=> "Windows",
+                "Sec-Fetch-Dest" => "empty",
+                "Sec-Fetch-Mode" => "cors",
+                "Sec-Fetch-Site" => "same-site",
+                "User-Agent" => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 Edg/140.0.0.0"
+            ],
+            'xhs'  => [
+                'Accept'=> "application/json, text/plain, */*",
+                'Accept-Encoding'=> "gzip, deflate, br, zstd",
+                'Accept-Language'=> "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
+                "Authorization"=> "Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZmEiLCJuaWtlIjoi6Zi_5Y-R5rWL6YCfIiwiY3JlYXRlZCI6MTc1ODc5MDI4NDU3OSwiZHBJZCI6MTkxOTQwLCJleHAiOjE3NTkwNDk0ODQsImVuYWJsZWQiOnRydWUsImF1dGhvcml0aWVzIjpbInpodXlvbmdodSJdLCJkcEFjY291bnRJZCI6MTc4MzU3fQ.TuHvPz7Jf0vuYsbrxX9VpyZ2oOrtZ0YzLQJafoX_RV8up1PmtPLfPATBE93_v_1Ig39nODadaTb4aePy3b0hsA",
+                "Cache-Control"=> "no-cache",
+                'Connection'   => 'keep-alive',
+                "Content-Type"=> "application/json",
+                "Host"        => "fsxpt.fengsutb.com",
+                "Origin"      => "https://fx.fengsutb.com",
+                "platform"    => "xhs",
+                "Pragma"      => "no-cache",
+                "Referer"     => "https://fx.fengsutb.com/",
+                "Sec-ch-ua"   => '"Chromium";v="140", "Not=A?Brand";v="24", "Microsoft Edge";v="140"',
+                "Sec-ch-ua-Mobile"=> "?0",
+                "Sec-ch-ua-platform"=> "Windows",
+                "Sec-Fetch-Dest" => "empty",
+                "Sec-Fetch-Mode" => "cors",
+                "Sec-Fetch-Site" => "same-site",
+                "User-Agent" => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 Edg/140.0.0.0"
+            ]
+        ];
+        return $header[$key] ?? [];
+    }
+
+
+}

+ 252 - 0
app/admin/command/TaskKs.php

@@ -0,0 +1,252 @@
+<?php
+/**
+ * ----------------------------------------------------------------------------
+ * 行到水穷处,坐看云起时
+ * 开发软件,找贵阳云起信息科技,官网地址:https://www.56q7.com/
+ * ----------------------------------------------------------------------------
+ * Author: 老成
+ * email:85556713@qq.com
+ */
+declare(strict_types=1);
+
+namespace app\admin\command;
+
+use app\common\model\FengsuShip;
+
+use think\console\Command;
+use think\console\Input;
+use think\console\Output;
+use GuzzleHttp\Client;
+use app\common\model\CrontabLog;
+use app\common\model\FengsuSku;
+use app\common\model\ShopList;
+use app\common\model\ProductConfig;
+use app\common\model\ShopDelivery;
+use app\common\model\CustomerSpec;
+use app\admin\service\FengsuService;
+use GuzzleHttp\Psr7\Request;
+
+//快手
+class TaskKs extends Command
+{
+    // 指令配置
+    protected function configure()
+    {
+        $this->setName('task:ks')->setDescription('the task command');
+    }
+
+    //根据shop_id
+    protected function execute(Input $input, Output $output)
+    {
+        $client = new Client([ 'verify' => false]);
+        $last_time = CrontabLog::getLastRunTime(0);
+        $body = '{
+        "goodType": 2,
+        "goodsFlag": 1,
+        "current": 1,
+        "size": 25,
+        "startTime": "'.$last_time.'",
+        "endTime": "'.date('Y-m-d H:i:s').'",
+        "skuOuterIdExact": false,
+        "skuPropExact": false,
+        "sort": "CONSIGN_TIME",
+        "sortAsc": false,
+        "timeType": 2,
+        "tradeStatus": 2
+        }';
+        $request = new Request('POST', $this->getUrl('dy'), $this->getHeaders('dy'), $body);
+        $res = $client->sendAsync($request)->wait();
+        if($res->getStatusCode() == 200) {
+            $data = json_decode($res->getBody()->getContents(), true);  
+            $list = $data['data']['list'];
+            if(empty($list)) {
+                $output->writeln('无数据');
+                return;
+            }
+            $queue = [];
+            $shopList = new ShopList();
+            $fengsuSku = new FengsuSku();
+            $productConfig = new ProductConfig();
+            $shopDelivery = new ShopDelivery();
+            $customerSpec = new CustomerSpec();
+            foreach($list as $item) {
+                $status = FengsuService::getAdditionalPrice( $shopList, $fengsuSku, $productConfig, $shopDelivery, $customerSpec, $item);
+                $queue[] = [
+                    'shop_id'       => $item['shopId'],
+                    'trade_from'    => $item['tradeFrom'],
+                    'province'      => $item['receiverProvince'],
+                    'city'          => $item['receiverCity'],
+                    'company_name'  => $item['tradeOrderPrintVos'][0]['companyName'],
+                    'waybill_no'    => $item['waybillNo'],
+                    'consign_time'  => $item['consignTime'],
+                    'goods_id'      => $item['tradeOrderPrintVos'][0]['goodsId'],
+                    'sku_id'        => $item['tradeOrderPrintVos'][0]['skuId'],
+                    'num'           => $item['tradeOrderPrintVos'][0]['total'],
+                    'goods_title'   => $item['tradeOrderPrintVos'][0]['goodsTitle'],
+                    'weigh'         => $item['tradeOrderPrintVos'][0]['weight'],
+                    'price'         => bcdiv((string)$item['payment'], '100', 2),
+                    'status'        => $status,
+                ];
+            }
+            
+            // 保存到数据库
+            (new FengsuShip())->saveAll($queue);
+            // 更新最后执行时间
+            CrontabLog::create([
+                'type_id' => 0,
+                'last_time' => date('Y-m-d H:i:s'),
+            ]);
+        }
+
+        // 指令输出
+        $output->writeln('ok');
+    }
+
+
+    //获取请求url
+    protected function getUrl(string $key):string
+    {
+        $url = [
+            'tb'  => 'https://fszntb.zhifeiyun.cn/amount/ship-list-new', //淘宝
+            'pdd' => 'https://fsfxpdd.fengsutb.com/amount/ship-list-new', //拼多多
+            'dy'  => 'https://fsdy2.fengsutb.com/amount/ship-list-new', //抖音
+            'ks'  => 'https://fsks.fengsutb.com/amount/ship-list-new',   //快手
+            'jd'  => 'https://fsjd.fengsutb.com/amount/ship-list-new', //京东
+            'xhs' => 'https://fsxpt.fengsutb.com/amount/ship-list-new', //小红书
+        ];
+        return $url[$key] ?? $url['tb'];
+    }
+
+    //获取头部
+    protected function getHeaders(string $key):array{
+        $header = [
+            'tb' =>[
+                'Accept'=> "application/json, text/plain, */*",
+                'Accept-Encoding'=> "gzip, deflate, br, zstd",
+                'Accept-Language'=> "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
+                "Authorization"=> "Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZmEiLCJuaWtlIjoi6Zi_5Y-R5rWL6YCfIiwiY3JlYXRlZCI6MTc1ODc5MDI4NDU3OSwiZHBJZCI6MTkxOTQwLCJleHAiOjE3NTkwNDk0ODQsImVuYWJsZWQiOnRydWUsImF1dGhvcml0aWVzIjpbInpodXlvbmdodSJdLCJkcEFjY291bnRJZCI6MTc4MzU3fQ.TuHvPz7Jf0vuYsbrxX9VpyZ2oOrtZ0YzLQJafoX_RV8up1PmtPLfPATBE93_v_1Ig39nODadaTb4aePy3b0hsA",
+                "Cache-Control"=> "no-cache",
+                "Content-Type"=> "application/json",
+                "Origin"=> "https://fx.fengsutb.com",
+                "platform" => "tb",
+                "Pragma"=> "no-cache",
+                "priority" => "u=1, i",
+                "Referer"=> "https://fx.fengsutb.com/",
+                "Sec-ch-ua" => '"Chromium";v="140", "Not=A?Brand";v="24", "Microsoft Edge";v="140"',
+                "Sec-ch-ua-Mobile"=> "?0",
+                "Sec-ch-ua-platform"=> "Windows",
+                "Sec-Fetch-Dest" => "empty",
+                "Sec-Fetch-Mode" => "cors",
+                "Sec-Fetch-Site" => "same-site",
+                "User-Agent" => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 Edg/140.0.0.0"
+            ],
+            'pdd' =>[
+                'Accept'=> "application/json, text/plain, */*",
+                'Accept-Encoding'=> "gzip, deflate, br, zstd",
+                'Accept-Language'=> "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
+                "Authorization"=> "Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZmEiLCJuaWtlIjoi6Zi_5Y-R5rWL6YCfIiwiY3JlYXRlZCI6MTc1ODc5MDI4NDU3OSwiZHBJZCI6MTkxOTQwLCJleHAiOjE3NTkwNDk0ODQsImVuYWJsZWQiOnRydWUsImF1dGhvcml0aWVzIjpbInpodXlvbmdodSJdLCJkcEFjY291bnRJZCI6MTc4MzU3fQ.TuHvPz7Jf0vuYsbrxX9VpyZ2oOrtZ0YzLQJafoX_RV8up1PmtPLfPATBE93_v_1Ig39nODadaTb4aePy3b0hsA",
+                "Cache-Control"=> "no-cache",
+                "Content-Type"=> "application/json",
+                "Origin"=> "https://fx.fengsutb.com",
+                "platform" => "pdd",
+                "Pragma"=> "no-cache",
+                "priority" => "u=1, i",
+                "Referer"=> "https://fx.fengsutb.com/",
+                "Sec-ch-ua" => '"Chromium";v="140", "Not=A?Brand";v="24", "Microsoft Edge";v="140"',
+                "Sec-ch-ua-Mobile"=> "?0",
+                "Sec-ch-ua-platform"=> "Windows",
+                "Sec-Fetch-Dest" => "empty",
+                "Sec-Fetch-Mode" => "cors",
+                "Sec-Fetch-Site" => "same-site",
+                "User-Agent" => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 Edg/140.0.0.0",
+                'X-Pdd-Pagecode' => '62f9d7a661b14717564e309aebbb4d47f8988f758f91',
+                'X-Pdd-Pati'     => 'D08NxRGxLLD5hYKZU1nqgE2b9IVrGjdv',
+            ],
+            'dy'=> [
+                'Host' => 'fsdy2.fengsutb.com',
+                'Connection' => 'keep-alive',
+                'sec-ch-ua-platform' => 'Windows',
+                'Authorization' => 'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZmEiLCJuaWtlIjoi6Zi_5Y-R5rWL6YCfIiwiY3JlYXRlZCI6MTc1ODcwMzg4MzMyMSwiZHBJZCI6MTkxOTQwLCJleHAiOjE3NTg5NjMwODMsImVuYWJsZWQiOnRydWUsImF1dGhvcml0aWVzIjpbInpodXlvbmdodSJdLCJkcEFjY291bnRJZCI6MTc4MzU3fQ.ZXaztcUDDlZDgepOqFwaQfzd4RcINNiIv54or0r-b7DJw9aKw7zjH8RmUIE7yqTcyQ_g6r7aGdpn9hf-hIukBg',
+                'sec-ch-ua' => '"Chromium";v="140", "Not=A?Brand";v="24", "Microsoft Edge";v="140"',
+                'sec-ch-ua-mobile' => '?0',
+                'doudian-event-id' => '1757940551000163',
+                'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 Edg/140.0.0.0',
+                'Accept' => 'application/json, text/plain, */*',
+                'platform' => 'dy',
+                'Origin' => 'https://fx.fengsutb.com',
+                'Sec-Fetch-Site' => 'same-site',
+                'Sec-Fetch-Mode' => 'cors',
+                'Sec-Fetch-Dest' => 'empty',
+                'Referer' => 'https://fx.fengsutb.com/',
+                'Accept-Language' => 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
+                'Content-Type' => 'application/json',
+            ],
+            'ks'=> [
+                'Accept'=> "application/json, text/plain, */*",
+                'Accept-Encoding'=> "gzip, deflate, br, zstd",
+                'Accept-Language'=> "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
+                "Authorization"=> "Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZmEiLCJuaWtlIjoi6Zi_5Y-R5rWL6YCfIiwiY3JlYXRlZCI6MTc1ODc5MDI4NDU3OSwiZHBJZCI6MTkxOTQwLCJleHAiOjE3NTkwNDk0ODQsImVuYWJsZWQiOnRydWUsImF1dGhvcml0aWVzIjpbInpodXlvbmdodSJdLCJkcEFjY291bnRJZCI6MTc4MzU3fQ.TuHvPz7Jf0vuYsbrxX9VpyZ2oOrtZ0YzLQJafoX_RV8up1PmtPLfPATBE93_v_1Ig39nODadaTb4aePy3b0hsA",
+                "Cache-Control"=> "no-cache",
+                'Connection'   => 'keep-alive',
+                "Content-Type"=> "application/json",
+                "Host"      => "fsks.fengsutb.com",
+                "Origin"    => "https://fx.fengsutb.com",
+                "platform" => "ks",
+                "Pragma"=> "no-cache",
+                "Referer"=> "https://fx.fengsutb.com/",
+                "Sec-ch-ua" => '"Chromium";v="140", "Not=A?Brand";v="24", "Microsoft Edge";v="140"',
+                "Sec-ch-ua-Mobile"=> "?0",
+                "Sec-ch-ua-platform"=> "Windows",
+                "Sec-Fetch-Dest" => "empty",
+                "Sec-Fetch-Mode" => "cors",
+                "Sec-Fetch-Site" => "same-site",
+                "User-Agent" => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 Edg/140.0.0.0"
+            ],
+            'jd'  => [
+                'Accept'=> "application/json, text/plain, */*",
+                'Accept-Encoding'=> "gzip, deflate, br, zstd",
+                'Accept-Language'=> "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
+                "Authorization"=> "Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZmEiLCJuaWtlIjoi6Zi_5Y-R5rWL6YCfIiwiY3JlYXRlZCI6MTc1ODc5MDI4NDU3OSwiZHBJZCI6MTkxOTQwLCJleHAiOjE3NTkwNDk0ODQsImVuYWJsZWQiOnRydWUsImF1dGhvcml0aWVzIjpbInpodXlvbmdodSJdLCJkcEFjY291bnRJZCI6MTc4MzU3fQ.TuHvPz7Jf0vuYsbrxX9VpyZ2oOrtZ0YzLQJafoX_RV8up1PmtPLfPATBE93_v_1Ig39nODadaTb4aePy3b0hsA",
+                "Cache-Control"=> "no-cache",
+                'Connection'   => 'keep-alive',
+                "Content-Type"=> "application/json",
+                "Host"      => "fsjd.fengsutb.com",
+                "Origin"    => "https://fx.fengsutb.com",
+                "platform" => "jd",
+                "Pragma"=> "no-cache",
+                "Referer"=> "https://fx.fengsutb.com/",
+                "Sec-ch-ua" => '"Chromium";v="140", "Not=A?Brand";v="24", "Microsoft Edge";v="140"',
+                "Sec-ch-ua-Mobile"=> "?0",
+                "Sec-ch-ua-platform"=> "Windows",
+                "Sec-Fetch-Dest" => "empty",
+                "Sec-Fetch-Mode" => "cors",
+                "Sec-Fetch-Site" => "same-site",
+                "User-Agent" => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 Edg/140.0.0.0"
+            ],
+            'xhs'  => [
+                'Accept'=> "application/json, text/plain, */*",
+                'Accept-Encoding'=> "gzip, deflate, br, zstd",
+                'Accept-Language'=> "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
+                "Authorization"=> "Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZmEiLCJuaWtlIjoi6Zi_5Y-R5rWL6YCfIiwiY3JlYXRlZCI6MTc1ODc5MDI4NDU3OSwiZHBJZCI6MTkxOTQwLCJleHAiOjE3NTkwNDk0ODQsImVuYWJsZWQiOnRydWUsImF1dGhvcml0aWVzIjpbInpodXlvbmdodSJdLCJkcEFjY291bnRJZCI6MTc4MzU3fQ.TuHvPz7Jf0vuYsbrxX9VpyZ2oOrtZ0YzLQJafoX_RV8up1PmtPLfPATBE93_v_1Ig39nODadaTb4aePy3b0hsA",
+                "Cache-Control"=> "no-cache",
+                'Connection'   => 'keep-alive',
+                "Content-Type"=> "application/json",
+                "Host"        => "fsxpt.fengsutb.com",
+                "Origin"      => "https://fx.fengsutb.com",
+                "platform"    => "xhs",
+                "Pragma"      => "no-cache",
+                "Referer"     => "https://fx.fengsutb.com/",
+                "Sec-ch-ua"   => '"Chromium";v="140", "Not=A?Brand";v="24", "Microsoft Edge";v="140"',
+                "Sec-ch-ua-Mobile"=> "?0",
+                "Sec-ch-ua-platform"=> "Windows",
+                "Sec-Fetch-Dest" => "empty",
+                "Sec-Fetch-Mode" => "cors",
+                "Sec-Fetch-Site" => "same-site",
+                "User-Agent" => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 Edg/140.0.0.0"
+            ]
+        ];
+        return $header[$key] ?? [];
+    }
+
+
+}

+ 253 - 0
app/admin/command/TaskPdd.php

@@ -0,0 +1,253 @@
+<?php
+/**
+ * ----------------------------------------------------------------------------
+ * 行到水穷处,坐看云起时
+ * 开发软件,找贵阳云起信息科技,官网地址:https://www.56q7.com/
+ * ----------------------------------------------------------------------------
+ * Author: 老成
+ * email:85556713@qq.com
+ */
+declare(strict_types=1);
+
+namespace app\admin\command;
+
+use app\common\model\FengsuShip;
+
+use think\console\Command;
+use think\console\Input;
+use think\console\Output;
+use GuzzleHttp\Client;
+use app\common\model\CrontabLog;
+use app\common\model\FengsuSku;
+use app\common\model\ShopList;
+use app\common\model\ProductConfig;
+use app\common\model\ShopDelivery;
+use app\common\model\CustomerSpec;
+use app\admin\service\FengsuService;
+
+use GuzzleHttp\Psr7\Request;
+
+//拼多多
+class TaskPdd extends Command
+{
+    // 指令配置
+    protected function configure()
+    {
+        $this->setName('task:pdd')->setDescription('the task command');
+    }
+
+    //根据shop_id
+    protected function execute(Input $input, Output $output)
+    {
+        $client = new Client([ 'verify' => false]);
+        $last_time = CrontabLog::getLastRunTime(0);
+        $body = '{
+        "goodType": 2,
+        "goodsFlag": 1,
+        "current": 1,
+        "size": 25,
+        "startTime": "'.$last_time.'",
+        "endTime": "'.date('Y-m-d H:i:s').'",
+        "skuOuterIdExact": false,
+        "skuPropExact": false,
+        "sort": "CONSIGN_TIME",
+        "sortAsc": false,
+        "timeType": 2,
+        "tradeStatus": 2
+        }';
+        $request = new Request('POST', $this->getUrl('dy'), $this->getHeaders('dy'), $body);
+        $res = $client->sendAsync($request)->wait();
+        if($res->getStatusCode() == 200) {
+            $data = json_decode($res->getBody()->getContents(), true);  
+            $list = $data['data']['list'];
+            if(empty($list)) {
+                $output->writeln('无数据');
+                return;
+            }
+            $queue = [];
+            $shopList = new ShopList();
+            $fengsuSku = new FengsuSku();
+            $productConfig = new ProductConfig();
+            $shopDelivery = new ShopDelivery();
+            $customerSpec = new CustomerSpec();
+            foreach($list as $item) {
+                $status = FengsuService::getAdditionalPrice( $shopList, $fengsuSku, $productConfig, $shopDelivery, $customerSpec, $item);
+                $queue[] = [
+                    'shop_id'       => $item['shopId'],
+                    'trade_from'    => $item['tradeFrom'],
+                    'province'      => $item['receiverProvince'],
+                    'city'          => $item['receiverCity'],
+                    'company_name'  => $item['tradeOrderPrintVos'][0]['companyName'],
+                    'waybill_no'    => $item['waybillNo'],
+                    'consign_time'  => $item['consignTime'],
+                    'goods_id'      => $item['tradeOrderPrintVos'][0]['goodsId'],
+                    'sku_id'        => $item['tradeOrderPrintVos'][0]['skuId'],
+                    'num'           => $item['tradeOrderPrintVos'][0]['total'],
+                    'goods_title'   => $item['tradeOrderPrintVos'][0]['goodsTitle'],
+                    'weigh'         => $item['tradeOrderPrintVos'][0]['weight'],
+                    'price'         => bcdiv((string)$item['payment'], '100', 2),
+                    'status'        => $status,
+                ];
+            }
+            
+            // 保存到数据库
+            (new FengsuShip())->saveAll($queue);
+            // 更新最后执行时间
+            CrontabLog::create([
+                'type_id' => 0,
+                'last_time' => date('Y-m-d H:i:s'),
+            ]);
+        }
+
+        // 指令输出
+        $output->writeln('ok');
+    }
+
+
+    //获取请求url
+    protected function getUrl(string $key):string
+    {
+        $url = [
+            'tb'  => 'https://fszntb.zhifeiyun.cn/amount/ship-list-new', //淘宝
+            'pdd' => 'https://fsfxpdd.fengsutb.com/amount/ship-list-new', //拼多多
+            'dy'  => 'https://fsdy2.fengsutb.com/amount/ship-list-new', //抖音
+            'ks'  => 'https://fsks.fengsutb.com/amount/ship-list-new',   //快手
+            'jd'  => 'https://fsjd.fengsutb.com/amount/ship-list-new', //京东
+            'xhs' => 'https://fsxpt.fengsutb.com/amount/ship-list-new', //小红书
+        ];
+        return $url[$key] ?? $url['tb'];
+    }
+
+    //获取头部
+    protected function getHeaders(string $key):array{
+        $header = [
+            'tb' =>[
+                'Accept'=> "application/json, text/plain, */*",
+                'Accept-Encoding'=> "gzip, deflate, br, zstd",
+                'Accept-Language'=> "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
+                "Authorization"=> "Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZmEiLCJuaWtlIjoi6Zi_5Y-R5rWL6YCfIiwiY3JlYXRlZCI6MTc1ODc5MDI4NDU3OSwiZHBJZCI6MTkxOTQwLCJleHAiOjE3NTkwNDk0ODQsImVuYWJsZWQiOnRydWUsImF1dGhvcml0aWVzIjpbInpodXlvbmdodSJdLCJkcEFjY291bnRJZCI6MTc4MzU3fQ.TuHvPz7Jf0vuYsbrxX9VpyZ2oOrtZ0YzLQJafoX_RV8up1PmtPLfPATBE93_v_1Ig39nODadaTb4aePy3b0hsA",
+                "Cache-Control"=> "no-cache",
+                "Content-Type"=> "application/json",
+                "Origin"=> "https://fx.fengsutb.com",
+                "platform" => "tb",
+                "Pragma"=> "no-cache",
+                "priority" => "u=1, i",
+                "Referer"=> "https://fx.fengsutb.com/",
+                "Sec-ch-ua" => '"Chromium";v="140", "Not=A?Brand";v="24", "Microsoft Edge";v="140"',
+                "Sec-ch-ua-Mobile"=> "?0",
+                "Sec-ch-ua-platform"=> "Windows",
+                "Sec-Fetch-Dest" => "empty",
+                "Sec-Fetch-Mode" => "cors",
+                "Sec-Fetch-Site" => "same-site",
+                "User-Agent" => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 Edg/140.0.0.0"
+            ],
+            'pdd' =>[
+                'Accept'=> "application/json, text/plain, */*",
+                'Accept-Encoding'=> "gzip, deflate, br, zstd",
+                'Accept-Language'=> "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
+                "Authorization"=> "Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZmEiLCJuaWtlIjoi6Zi_5Y-R5rWL6YCfIiwiY3JlYXRlZCI6MTc1ODc5MDI4NDU3OSwiZHBJZCI6MTkxOTQwLCJleHAiOjE3NTkwNDk0ODQsImVuYWJsZWQiOnRydWUsImF1dGhvcml0aWVzIjpbInpodXlvbmdodSJdLCJkcEFjY291bnRJZCI6MTc4MzU3fQ.TuHvPz7Jf0vuYsbrxX9VpyZ2oOrtZ0YzLQJafoX_RV8up1PmtPLfPATBE93_v_1Ig39nODadaTb4aePy3b0hsA",
+                "Cache-Control"=> "no-cache",
+                "Content-Type"=> "application/json",
+                "Origin"=> "https://fx.fengsutb.com",
+                "platform" => "pdd",
+                "Pragma"=> "no-cache",
+                "priority" => "u=1, i",
+                "Referer"=> "https://fx.fengsutb.com/",
+                "Sec-ch-ua" => '"Chromium";v="140", "Not=A?Brand";v="24", "Microsoft Edge";v="140"',
+                "Sec-ch-ua-Mobile"=> "?0",
+                "Sec-ch-ua-platform"=> "Windows",
+                "Sec-Fetch-Dest" => "empty",
+                "Sec-Fetch-Mode" => "cors",
+                "Sec-Fetch-Site" => "same-site",
+                "User-Agent" => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 Edg/140.0.0.0",
+                'X-Pdd-Pagecode' => '62f9d7a661b14717564e309aebbb4d47f8988f758f91',
+                'X-Pdd-Pati'     => 'D08NxRGxLLD5hYKZU1nqgE2b9IVrGjdv',
+            ],
+            'dy'=> [
+                'Host' => 'fsdy2.fengsutb.com',
+                'Connection' => 'keep-alive',
+                'sec-ch-ua-platform' => 'Windows',
+                'Authorization' => 'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZmEiLCJuaWtlIjoi6Zi_5Y-R5rWL6YCfIiwiY3JlYXRlZCI6MTc1ODcwMzg4MzMyMSwiZHBJZCI6MTkxOTQwLCJleHAiOjE3NTg5NjMwODMsImVuYWJsZWQiOnRydWUsImF1dGhvcml0aWVzIjpbInpodXlvbmdodSJdLCJkcEFjY291bnRJZCI6MTc4MzU3fQ.ZXaztcUDDlZDgepOqFwaQfzd4RcINNiIv54or0r-b7DJw9aKw7zjH8RmUIE7yqTcyQ_g6r7aGdpn9hf-hIukBg',
+                'sec-ch-ua' => '"Chromium";v="140", "Not=A?Brand";v="24", "Microsoft Edge";v="140"',
+                'sec-ch-ua-mobile' => '?0',
+                'doudian-event-id' => '1757940551000163',
+                'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 Edg/140.0.0.0',
+                'Accept' => 'application/json, text/plain, */*',
+                'platform' => 'dy',
+                'Origin' => 'https://fx.fengsutb.com',
+                'Sec-Fetch-Site' => 'same-site',
+                'Sec-Fetch-Mode' => 'cors',
+                'Sec-Fetch-Dest' => 'empty',
+                'Referer' => 'https://fx.fengsutb.com/',
+                'Accept-Language' => 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
+                'Content-Type' => 'application/json',
+            ],
+            'ks'=> [
+                'Accept'=> "application/json, text/plain, */*",
+                'Accept-Encoding'=> "gzip, deflate, br, zstd",
+                'Accept-Language'=> "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
+                "Authorization"=> "Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZmEiLCJuaWtlIjoi6Zi_5Y-R5rWL6YCfIiwiY3JlYXRlZCI6MTc1ODc5MDI4NDU3OSwiZHBJZCI6MTkxOTQwLCJleHAiOjE3NTkwNDk0ODQsImVuYWJsZWQiOnRydWUsImF1dGhvcml0aWVzIjpbInpodXlvbmdodSJdLCJkcEFjY291bnRJZCI6MTc4MzU3fQ.TuHvPz7Jf0vuYsbrxX9VpyZ2oOrtZ0YzLQJafoX_RV8up1PmtPLfPATBE93_v_1Ig39nODadaTb4aePy3b0hsA",
+                "Cache-Control"=> "no-cache",
+                'Connection'   => 'keep-alive',
+                "Content-Type"=> "application/json",
+                "Host"      => "fsks.fengsutb.com",
+                "Origin"    => "https://fx.fengsutb.com",
+                "platform" => "ks",
+                "Pragma"=> "no-cache",
+                "Referer"=> "https://fx.fengsutb.com/",
+                "Sec-ch-ua" => '"Chromium";v="140", "Not=A?Brand";v="24", "Microsoft Edge";v="140"',
+                "Sec-ch-ua-Mobile"=> "?0",
+                "Sec-ch-ua-platform"=> "Windows",
+                "Sec-Fetch-Dest" => "empty",
+                "Sec-Fetch-Mode" => "cors",
+                "Sec-Fetch-Site" => "same-site",
+                "User-Agent" => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 Edg/140.0.0.0"
+            ],
+            'jd'  => [
+                'Accept'=> "application/json, text/plain, */*",
+                'Accept-Encoding'=> "gzip, deflate, br, zstd",
+                'Accept-Language'=> "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
+                "Authorization"=> "Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZmEiLCJuaWtlIjoi6Zi_5Y-R5rWL6YCfIiwiY3JlYXRlZCI6MTc1ODc5MDI4NDU3OSwiZHBJZCI6MTkxOTQwLCJleHAiOjE3NTkwNDk0ODQsImVuYWJsZWQiOnRydWUsImF1dGhvcml0aWVzIjpbInpodXlvbmdodSJdLCJkcEFjY291bnRJZCI6MTc4MzU3fQ.TuHvPz7Jf0vuYsbrxX9VpyZ2oOrtZ0YzLQJafoX_RV8up1PmtPLfPATBE93_v_1Ig39nODadaTb4aePy3b0hsA",
+                "Cache-Control"=> "no-cache",
+                'Connection'   => 'keep-alive',
+                "Content-Type"=> "application/json",
+                "Host"      => "fsjd.fengsutb.com",
+                "Origin"    => "https://fx.fengsutb.com",
+                "platform" => "jd",
+                "Pragma"=> "no-cache",
+                "Referer"=> "https://fx.fengsutb.com/",
+                "Sec-ch-ua" => '"Chromium";v="140", "Not=A?Brand";v="24", "Microsoft Edge";v="140"',
+                "Sec-ch-ua-Mobile"=> "?0",
+                "Sec-ch-ua-platform"=> "Windows",
+                "Sec-Fetch-Dest" => "empty",
+                "Sec-Fetch-Mode" => "cors",
+                "Sec-Fetch-Site" => "same-site",
+                "User-Agent" => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 Edg/140.0.0.0"
+            ],
+            'xhs'  => [
+                'Accept'=> "application/json, text/plain, */*",
+                'Accept-Encoding'=> "gzip, deflate, br, zstd",
+                'Accept-Language'=> "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
+                "Authorization"=> "Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZmEiLCJuaWtlIjoi6Zi_5Y-R5rWL6YCfIiwiY3JlYXRlZCI6MTc1ODc5MDI4NDU3OSwiZHBJZCI6MTkxOTQwLCJleHAiOjE3NTkwNDk0ODQsImVuYWJsZWQiOnRydWUsImF1dGhvcml0aWVzIjpbInpodXlvbmdodSJdLCJkcEFjY291bnRJZCI6MTc4MzU3fQ.TuHvPz7Jf0vuYsbrxX9VpyZ2oOrtZ0YzLQJafoX_RV8up1PmtPLfPATBE93_v_1Ig39nODadaTb4aePy3b0hsA",
+                "Cache-Control"=> "no-cache",
+                'Connection'   => 'keep-alive',
+                "Content-Type"=> "application/json",
+                "Host"        => "fsxpt.fengsutb.com",
+                "Origin"      => "https://fx.fengsutb.com",
+                "platform"    => "xhs",
+                "Pragma"      => "no-cache",
+                "Referer"     => "https://fx.fengsutb.com/",
+                "Sec-ch-ua"   => '"Chromium";v="140", "Not=A?Brand";v="24", "Microsoft Edge";v="140"',
+                "Sec-ch-ua-Mobile"=> "?0",
+                "Sec-ch-ua-platform"=> "Windows",
+                "Sec-Fetch-Dest" => "empty",
+                "Sec-Fetch-Mode" => "cors",
+                "Sec-Fetch-Site" => "same-site",
+                "User-Agent" => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 Edg/140.0.0.0"
+            ]
+        ];
+        return $header[$key] ?? [];
+    }
+
+
+}

+ 252 - 0
app/admin/command/TaskTb.php

@@ -0,0 +1,252 @@
+<?php
+/**
+ * ----------------------------------------------------------------------------
+ * 行到水穷处,坐看云起时
+ * 开发软件,找贵阳云起信息科技,官网地址:https://www.56q7.com/
+ * ----------------------------------------------------------------------------
+ * Author: 老成
+ * email:85556713@qq.com
+ */
+declare(strict_types=1);
+
+namespace app\admin\command;
+
+use app\common\model\FengsuShip;
+
+use think\console\Command;
+use think\console\Input;
+use think\console\Output;
+use GuzzleHttp\Client;
+use app\common\model\CrontabLog;
+use app\common\model\FengsuSku;
+use app\common\model\ShopList;
+use app\common\model\ProductConfig;
+use app\common\model\ShopDelivery;
+use app\common\model\CustomerSpec;
+use app\admin\service\FengsuService;
+use GuzzleHttp\Psr7\Request;
+
+//淘宝
+class TaskTb extends Command
+{
+    // 指令配置
+    protected function configure()
+    {
+        $this->setName('task:tb')->setDescription('the task command');
+    }
+
+    //根据shop_id
+    protected function execute(Input $input, Output $output)
+    {
+        $client = new Client([ 'verify' => false]);
+        $last_time = CrontabLog::getLastRunTime(0);
+        $body = '{
+        "goodType": 2,
+        "goodsFlag": 1,
+        "current": 1,
+        "size": 25,
+        "startTime": "'.$last_time.'",
+        "endTime": "'.date('Y-m-d H:i:s').'",
+        "skuOuterIdExact": false,
+        "skuPropExact": false,
+        "sort": "CONSIGN_TIME",
+        "sortAsc": false,
+        "timeType": 2,
+        "tradeStatus": 2
+        }';
+        $request = new Request('POST', $this->getUrl('dy'), $this->getHeaders('dy'), $body);
+        $res = $client->sendAsync($request)->wait();
+        if($res->getStatusCode() == 200) {
+            $data = json_decode($res->getBody()->getContents(), true);  
+            $list = $data['data']['list'];
+            if(empty($list)) {
+                $output->writeln('无数据');
+                return;
+            }
+            $queue = [];
+            $shopList = new ShopList();
+            $fengsuSku = new FengsuSku();
+            $productConfig = new ProductConfig();
+            $shopDelivery = new ShopDelivery();
+            $customerSpec = new CustomerSpec();
+            foreach($list as $item) {
+                $status = FengsuService::getAdditionalPrice( $shopList, $fengsuSku, $productConfig, $shopDelivery, $customerSpec, $item);
+                $queue[] = [
+                    'shop_id'       => $item['shopId'],
+                    'trade_from'    => $item['tradeFrom'],
+                    'province'      => $item['receiverProvince'],
+                    'city'          => $item['receiverCity'],
+                    'company_name'  => $item['tradeOrderPrintVos'][0]['companyName'],
+                    'waybill_no'    => $item['waybillNo'],
+                    'consign_time'  => $item['consignTime'],
+                    'goods_id'      => $item['tradeOrderPrintVos'][0]['goodsId'],
+                    'sku_id'        => $item['tradeOrderPrintVos'][0]['skuId'],
+                    'num'           => $item['tradeOrderPrintVos'][0]['total'],
+                    'goods_title'   => $item['tradeOrderPrintVos'][0]['goodsTitle'],
+                    'weigh'         => $item['tradeOrderPrintVos'][0]['weight'],
+                    'price'         => bcdiv((string)$item['payment'], '100', 2),
+                    'status'        => $status,
+                ];
+            }
+            
+            // 保存到数据库
+            (new FengsuShip())->saveAll($queue);
+            // 更新最后执行时间
+            CrontabLog::create([
+                'type_id' => 0,
+                'last_time' => date('Y-m-d H:i:s'),
+            ]);
+        }
+
+        // 指令输出
+        $output->writeln('ok');
+    }
+
+
+    //获取请求url
+    protected function getUrl(string $key):string
+    {
+        $url = [
+            'tb'  => 'https://fszntb.zhifeiyun.cn/amount/ship-list-new', //淘宝
+            'pdd' => 'https://fsfxpdd.fengsutb.com/amount/ship-list-new', //拼多多
+            'dy'  => 'https://fsdy2.fengsutb.com/amount/ship-list-new', //抖音
+            'ks'  => 'https://fsks.fengsutb.com/amount/ship-list-new',   //快手
+            'jd'  => 'https://fsjd.fengsutb.com/amount/ship-list-new', //京东
+            'xhs' => 'https://fsxpt.fengsutb.com/amount/ship-list-new', //小红书
+        ];
+        return $url[$key] ?? $url['tb'];
+    }
+
+    //获取头部
+    protected function getHeaders(string $key):array{
+        $header = [
+            'tb' =>[
+                'Accept'=> "application/json, text/plain, */*",
+                'Accept-Encoding'=> "gzip, deflate, br, zstd",
+                'Accept-Language'=> "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
+                "Authorization"=> "Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZmEiLCJuaWtlIjoi6Zi_5Y-R5rWL6YCfIiwiY3JlYXRlZCI6MTc1ODc5MDI4NDU3OSwiZHBJZCI6MTkxOTQwLCJleHAiOjE3NTkwNDk0ODQsImVuYWJsZWQiOnRydWUsImF1dGhvcml0aWVzIjpbInpodXlvbmdodSJdLCJkcEFjY291bnRJZCI6MTc4MzU3fQ.TuHvPz7Jf0vuYsbrxX9VpyZ2oOrtZ0YzLQJafoX_RV8up1PmtPLfPATBE93_v_1Ig39nODadaTb4aePy3b0hsA",
+                "Cache-Control"=> "no-cache",
+                "Content-Type"=> "application/json",
+                "Origin"=> "https://fx.fengsutb.com",
+                "platform" => "tb",
+                "Pragma"=> "no-cache",
+                "priority" => "u=1, i",
+                "Referer"=> "https://fx.fengsutb.com/",
+                "Sec-ch-ua" => '"Chromium";v="140", "Not=A?Brand";v="24", "Microsoft Edge";v="140"',
+                "Sec-ch-ua-Mobile"=> "?0",
+                "Sec-ch-ua-platform"=> "Windows",
+                "Sec-Fetch-Dest" => "empty",
+                "Sec-Fetch-Mode" => "cors",
+                "Sec-Fetch-Site" => "same-site",
+                "User-Agent" => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 Edg/140.0.0.0"
+            ],
+            'pdd' =>[
+                'Accept'=> "application/json, text/plain, */*",
+                'Accept-Encoding'=> "gzip, deflate, br, zstd",
+                'Accept-Language'=> "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
+                "Authorization"=> "Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZmEiLCJuaWtlIjoi6Zi_5Y-R5rWL6YCfIiwiY3JlYXRlZCI6MTc1ODc5MDI4NDU3OSwiZHBJZCI6MTkxOTQwLCJleHAiOjE3NTkwNDk0ODQsImVuYWJsZWQiOnRydWUsImF1dGhvcml0aWVzIjpbInpodXlvbmdodSJdLCJkcEFjY291bnRJZCI6MTc4MzU3fQ.TuHvPz7Jf0vuYsbrxX9VpyZ2oOrtZ0YzLQJafoX_RV8up1PmtPLfPATBE93_v_1Ig39nODadaTb4aePy3b0hsA",
+                "Cache-Control"=> "no-cache",
+                "Content-Type"=> "application/json",
+                "Origin"=> "https://fx.fengsutb.com",
+                "platform" => "pdd",
+                "Pragma"=> "no-cache",
+                "priority" => "u=1, i",
+                "Referer"=> "https://fx.fengsutb.com/",
+                "Sec-ch-ua" => '"Chromium";v="140", "Not=A?Brand";v="24", "Microsoft Edge";v="140"',
+                "Sec-ch-ua-Mobile"=> "?0",
+                "Sec-ch-ua-platform"=> "Windows",
+                "Sec-Fetch-Dest" => "empty",
+                "Sec-Fetch-Mode" => "cors",
+                "Sec-Fetch-Site" => "same-site",
+                "User-Agent" => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 Edg/140.0.0.0",
+                'X-Pdd-Pagecode' => '62f9d7a661b14717564e309aebbb4d47f8988f758f91',
+                'X-Pdd-Pati'     => 'D08NxRGxLLD5hYKZU1nqgE2b9IVrGjdv',
+            ],
+            'dy'=> [
+                'Host' => 'fsdy2.fengsutb.com',
+                'Connection' => 'keep-alive',
+                'sec-ch-ua-platform' => 'Windows',
+                'Authorization' => 'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZmEiLCJuaWtlIjoi6Zi_5Y-R5rWL6YCfIiwiY3JlYXRlZCI6MTc1ODcwMzg4MzMyMSwiZHBJZCI6MTkxOTQwLCJleHAiOjE3NTg5NjMwODMsImVuYWJsZWQiOnRydWUsImF1dGhvcml0aWVzIjpbInpodXlvbmdodSJdLCJkcEFjY291bnRJZCI6MTc4MzU3fQ.ZXaztcUDDlZDgepOqFwaQfzd4RcINNiIv54or0r-b7DJw9aKw7zjH8RmUIE7yqTcyQ_g6r7aGdpn9hf-hIukBg',
+                'sec-ch-ua' => '"Chromium";v="140", "Not=A?Brand";v="24", "Microsoft Edge";v="140"',
+                'sec-ch-ua-mobile' => '?0',
+                'doudian-event-id' => '1757940551000163',
+                'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 Edg/140.0.0.0',
+                'Accept' => 'application/json, text/plain, */*',
+                'platform' => 'dy',
+                'Origin' => 'https://fx.fengsutb.com',
+                'Sec-Fetch-Site' => 'same-site',
+                'Sec-Fetch-Mode' => 'cors',
+                'Sec-Fetch-Dest' => 'empty',
+                'Referer' => 'https://fx.fengsutb.com/',
+                'Accept-Language' => 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
+                'Content-Type' => 'application/json',
+            ],
+            'ks'=> [
+                'Accept'=> "application/json, text/plain, */*",
+                'Accept-Encoding'=> "gzip, deflate, br, zstd",
+                'Accept-Language'=> "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
+                "Authorization"=> "Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZmEiLCJuaWtlIjoi6Zi_5Y-R5rWL6YCfIiwiY3JlYXRlZCI6MTc1ODc5MDI4NDU3OSwiZHBJZCI6MTkxOTQwLCJleHAiOjE3NTkwNDk0ODQsImVuYWJsZWQiOnRydWUsImF1dGhvcml0aWVzIjpbInpodXlvbmdodSJdLCJkcEFjY291bnRJZCI6MTc4MzU3fQ.TuHvPz7Jf0vuYsbrxX9VpyZ2oOrtZ0YzLQJafoX_RV8up1PmtPLfPATBE93_v_1Ig39nODadaTb4aePy3b0hsA",
+                "Cache-Control"=> "no-cache",
+                'Connection'   => 'keep-alive',
+                "Content-Type"=> "application/json",
+                "Host"      => "fsks.fengsutb.com",
+                "Origin"    => "https://fx.fengsutb.com",
+                "platform" => "ks",
+                "Pragma"=> "no-cache",
+                "Referer"=> "https://fx.fengsutb.com/",
+                "Sec-ch-ua" => '"Chromium";v="140", "Not=A?Brand";v="24", "Microsoft Edge";v="140"',
+                "Sec-ch-ua-Mobile"=> "?0",
+                "Sec-ch-ua-platform"=> "Windows",
+                "Sec-Fetch-Dest" => "empty",
+                "Sec-Fetch-Mode" => "cors",
+                "Sec-Fetch-Site" => "same-site",
+                "User-Agent" => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 Edg/140.0.0.0"
+            ],
+            'jd'  => [
+                'Accept'=> "application/json, text/plain, */*",
+                'Accept-Encoding'=> "gzip, deflate, br, zstd",
+                'Accept-Language'=> "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
+                "Authorization"=> "Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZmEiLCJuaWtlIjoi6Zi_5Y-R5rWL6YCfIiwiY3JlYXRlZCI6MTc1ODc5MDI4NDU3OSwiZHBJZCI6MTkxOTQwLCJleHAiOjE3NTkwNDk0ODQsImVuYWJsZWQiOnRydWUsImF1dGhvcml0aWVzIjpbInpodXlvbmdodSJdLCJkcEFjY291bnRJZCI6MTc4MzU3fQ.TuHvPz7Jf0vuYsbrxX9VpyZ2oOrtZ0YzLQJafoX_RV8up1PmtPLfPATBE93_v_1Ig39nODadaTb4aePy3b0hsA",
+                "Cache-Control"=> "no-cache",
+                'Connection'   => 'keep-alive',
+                "Content-Type"=> "application/json",
+                "Host"      => "fsjd.fengsutb.com",
+                "Origin"    => "https://fx.fengsutb.com",
+                "platform" => "jd",
+                "Pragma"=> "no-cache",
+                "Referer"=> "https://fx.fengsutb.com/",
+                "Sec-ch-ua" => '"Chromium";v="140", "Not=A?Brand";v="24", "Microsoft Edge";v="140"',
+                "Sec-ch-ua-Mobile"=> "?0",
+                "Sec-ch-ua-platform"=> "Windows",
+                "Sec-Fetch-Dest" => "empty",
+                "Sec-Fetch-Mode" => "cors",
+                "Sec-Fetch-Site" => "same-site",
+                "User-Agent" => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 Edg/140.0.0.0"
+            ],
+            'xhs'  => [
+                'Accept'=> "application/json, text/plain, */*",
+                'Accept-Encoding'=> "gzip, deflate, br, zstd",
+                'Accept-Language'=> "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
+                "Authorization"=> "Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZmEiLCJuaWtlIjoi6Zi_5Y-R5rWL6YCfIiwiY3JlYXRlZCI6MTc1ODc5MDI4NDU3OSwiZHBJZCI6MTkxOTQwLCJleHAiOjE3NTkwNDk0ODQsImVuYWJsZWQiOnRydWUsImF1dGhvcml0aWVzIjpbInpodXlvbmdodSJdLCJkcEFjY291bnRJZCI6MTc4MzU3fQ.TuHvPz7Jf0vuYsbrxX9VpyZ2oOrtZ0YzLQJafoX_RV8up1PmtPLfPATBE93_v_1Ig39nODadaTb4aePy3b0hsA",
+                "Cache-Control"=> "no-cache",
+                'Connection'   => 'keep-alive',
+                "Content-Type"=> "application/json",
+                "Host"        => "fsxpt.fengsutb.com",
+                "Origin"      => "https://fx.fengsutb.com",
+                "platform"    => "xhs",
+                "Pragma"      => "no-cache",
+                "Referer"     => "https://fx.fengsutb.com/",
+                "Sec-ch-ua"   => '"Chromium";v="140", "Not=A?Brand";v="24", "Microsoft Edge";v="140"',
+                "Sec-ch-ua-Mobile"=> "?0",
+                "Sec-ch-ua-platform"=> "Windows",
+                "Sec-Fetch-Dest" => "empty",
+                "Sec-Fetch-Mode" => "cors",
+                "Sec-Fetch-Site" => "same-site",
+                "User-Agent" => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 Edg/140.0.0.0"
+            ]
+        ];
+        return $header[$key] ?? [];
+    }
+
+
+}

+ 253 - 0
app/admin/command/TaskXhs.php

@@ -0,0 +1,253 @@
+<?php
+/**
+ * ----------------------------------------------------------------------------
+ * 行到水穷处,坐看云起时
+ * 开发软件,找贵阳云起信息科技,官网地址:https://www.56q7.com/
+ * ----------------------------------------------------------------------------
+ * Author: 老成
+ * email:85556713@qq.com
+ */
+declare(strict_types=1);
+
+namespace app\admin\command;
+
+use app\common\model\FengsuShip;
+
+use think\console\Command;
+use think\console\Input;
+use think\console\Output;
+use GuzzleHttp\Client;
+use app\common\model\CrontabLog;
+use app\common\model\FengsuSku;
+use app\common\model\ShopList;
+use app\common\model\ProductConfig;
+use app\common\model\ShopDelivery;
+use app\common\model\CustomerSpec;
+use app\admin\service\FengsuService;
+
+use GuzzleHttp\Psr7\Request;
+
+// 小红书
+class TaskXhs extends Command
+{
+    // 指令配置
+    protected function configure()
+    {
+        $this->setName('task:xhs')->setDescription('the task command');
+    }
+
+    //根据shop_id
+    protected function execute(Input $input, Output $output)
+    {
+        $client = new Client([ 'verify' => false]);
+        $last_time = CrontabLog::getLastRunTime(0);
+        $body = '{
+        "goodType": 2,
+        "goodsFlag": 1,
+        "current": 1,
+        "size": 25,
+        "startTime": "'.$last_time.'",
+        "endTime": "'.date('Y-m-d H:i:s').'",
+        "skuOuterIdExact": false,
+        "skuPropExact": false,
+        "sort": "CONSIGN_TIME",
+        "sortAsc": false,
+        "timeType": 2,
+        "tradeStatus": 2
+        }';
+        $request = new Request('POST', $this->getUrl('dy'), $this->getHeaders('dy'), $body);
+        $res = $client->sendAsync($request)->wait();
+        if($res->getStatusCode() == 200) {
+            $data = json_decode($res->getBody()->getContents(), true);  
+            $list = $data['data']['list'];
+            if(empty($list)) {
+                $output->writeln('无数据');
+                return;
+            }
+            $queue = [];
+            $shopList = new ShopList();
+            $fengsuSku = new FengsuSku();
+            $productConfig = new ProductConfig();
+            $shopDelivery = new ShopDelivery();
+            $customerSpec = new CustomerSpec();
+            foreach($list as $item) {
+                $status = FengsuService::getAdditionalPrice( $shopList, $fengsuSku, $productConfig, $shopDelivery, $customerSpec, $item);
+                $queue[] = [
+                    'shop_id'       => $item['shopId'],
+                    'trade_from'    => $item['tradeFrom'],
+                    'province'      => $item['receiverProvince'],
+                    'city'          => $item['receiverCity'],
+                    'company_name'  => $item['tradeOrderPrintVos'][0]['companyName'],
+                    'waybill_no'    => $item['waybillNo'],
+                    'consign_time'  => $item['consignTime'],
+                    'goods_id'      => $item['tradeOrderPrintVos'][0]['goodsId'],
+                    'sku_id'        => $item['tradeOrderPrintVos'][0]['skuId'],
+                    'num'           => $item['tradeOrderPrintVos'][0]['total'],
+                    'goods_title'   => $item['tradeOrderPrintVos'][0]['goodsTitle'],
+                    'weigh'         => $item['tradeOrderPrintVos'][0]['weight'],
+                    'price'         => bcdiv((string)$item['payment'], '100', 2),
+                    'status'        => $status,
+                ];
+            }
+            
+            // 保存到数据库
+            (new FengsuShip())->saveAll($queue);
+            // 更新最后执行时间
+            CrontabLog::create([
+                'type_id' => 0,
+                'last_time' => date('Y-m-d H:i:s'),
+            ]);
+        }
+
+        // 指令输出
+        $output->writeln('ok');
+    }
+
+
+    //获取请求url
+    protected function getUrl(string $key):string
+    {
+        $url = [
+            'tb'  => 'https://fszntb.zhifeiyun.cn/amount/ship-list-new', //淘宝
+            'pdd' => 'https://fsfxpdd.fengsutb.com/amount/ship-list-new', //拼多多
+            'dy'  => 'https://fsdy2.fengsutb.com/amount/ship-list-new', //抖音
+            'ks'  => 'https://fsks.fengsutb.com/amount/ship-list-new',   //快手
+            'jd'  => 'https://fsjd.fengsutb.com/amount/ship-list-new', //京东
+            'xhs' => 'https://fsxpt.fengsutb.com/amount/ship-list-new', //小红书
+        ];
+        return $url[$key] ?? $url['tb'];
+    }
+
+    //获取头部
+    protected function getHeaders(string $key):array{
+        $header = [
+            'tb' =>[
+                'Accept'=> "application/json, text/plain, */*",
+                'Accept-Encoding'=> "gzip, deflate, br, zstd",
+                'Accept-Language'=> "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
+                "Authorization"=> "Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZmEiLCJuaWtlIjoi6Zi_5Y-R5rWL6YCfIiwiY3JlYXRlZCI6MTc1ODc5MDI4NDU3OSwiZHBJZCI6MTkxOTQwLCJleHAiOjE3NTkwNDk0ODQsImVuYWJsZWQiOnRydWUsImF1dGhvcml0aWVzIjpbInpodXlvbmdodSJdLCJkcEFjY291bnRJZCI6MTc4MzU3fQ.TuHvPz7Jf0vuYsbrxX9VpyZ2oOrtZ0YzLQJafoX_RV8up1PmtPLfPATBE93_v_1Ig39nODadaTb4aePy3b0hsA",
+                "Cache-Control"=> "no-cache",
+                "Content-Type"=> "application/json",
+                "Origin"=> "https://fx.fengsutb.com",
+                "platform" => "tb",
+                "Pragma"=> "no-cache",
+                "priority" => "u=1, i",
+                "Referer"=> "https://fx.fengsutb.com/",
+                "Sec-ch-ua" => '"Chromium";v="140", "Not=A?Brand";v="24", "Microsoft Edge";v="140"',
+                "Sec-ch-ua-Mobile"=> "?0",
+                "Sec-ch-ua-platform"=> "Windows",
+                "Sec-Fetch-Dest" => "empty",
+                "Sec-Fetch-Mode" => "cors",
+                "Sec-Fetch-Site" => "same-site",
+                "User-Agent" => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 Edg/140.0.0.0"
+            ],
+            'pdd' =>[
+                'Accept'=> "application/json, text/plain, */*",
+                'Accept-Encoding'=> "gzip, deflate, br, zstd",
+                'Accept-Language'=> "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
+                "Authorization"=> "Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZmEiLCJuaWtlIjoi6Zi_5Y-R5rWL6YCfIiwiY3JlYXRlZCI6MTc1ODc5MDI4NDU3OSwiZHBJZCI6MTkxOTQwLCJleHAiOjE3NTkwNDk0ODQsImVuYWJsZWQiOnRydWUsImF1dGhvcml0aWVzIjpbInpodXlvbmdodSJdLCJkcEFjY291bnRJZCI6MTc4MzU3fQ.TuHvPz7Jf0vuYsbrxX9VpyZ2oOrtZ0YzLQJafoX_RV8up1PmtPLfPATBE93_v_1Ig39nODadaTb4aePy3b0hsA",
+                "Cache-Control"=> "no-cache",
+                "Content-Type"=> "application/json",
+                "Origin"=> "https://fx.fengsutb.com",
+                "platform" => "pdd",
+                "Pragma"=> "no-cache",
+                "priority" => "u=1, i",
+                "Referer"=> "https://fx.fengsutb.com/",
+                "Sec-ch-ua" => '"Chromium";v="140", "Not=A?Brand";v="24", "Microsoft Edge";v="140"',
+                "Sec-ch-ua-Mobile"=> "?0",
+                "Sec-ch-ua-platform"=> "Windows",
+                "Sec-Fetch-Dest" => "empty",
+                "Sec-Fetch-Mode" => "cors",
+                "Sec-Fetch-Site" => "same-site",
+                "User-Agent" => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 Edg/140.0.0.0",
+                'X-Pdd-Pagecode' => '62f9d7a661b14717564e309aebbb4d47f8988f758f91',
+                'X-Pdd-Pati'     => 'D08NxRGxLLD5hYKZU1nqgE2b9IVrGjdv',
+            ],
+            'dy'=> [
+                'Host' => 'fsdy2.fengsutb.com',
+                'Connection' => 'keep-alive',
+                'sec-ch-ua-platform' => 'Windows',
+                'Authorization' => 'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZmEiLCJuaWtlIjoi6Zi_5Y-R5rWL6YCfIiwiY3JlYXRlZCI6MTc1ODcwMzg4MzMyMSwiZHBJZCI6MTkxOTQwLCJleHAiOjE3NTg5NjMwODMsImVuYWJsZWQiOnRydWUsImF1dGhvcml0aWVzIjpbInpodXlvbmdodSJdLCJkcEFjY291bnRJZCI6MTc4MzU3fQ.ZXaztcUDDlZDgepOqFwaQfzd4RcINNiIv54or0r-b7DJw9aKw7zjH8RmUIE7yqTcyQ_g6r7aGdpn9hf-hIukBg',
+                'sec-ch-ua' => '"Chromium";v="140", "Not=A?Brand";v="24", "Microsoft Edge";v="140"',
+                'sec-ch-ua-mobile' => '?0',
+                'doudian-event-id' => '1757940551000163',
+                'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 Edg/140.0.0.0',
+                'Accept' => 'application/json, text/plain, */*',
+                'platform' => 'dy',
+                'Origin' => 'https://fx.fengsutb.com',
+                'Sec-Fetch-Site' => 'same-site',
+                'Sec-Fetch-Mode' => 'cors',
+                'Sec-Fetch-Dest' => 'empty',
+                'Referer' => 'https://fx.fengsutb.com/',
+                'Accept-Language' => 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
+                'Content-Type' => 'application/json',
+            ],
+            'ks'=> [
+                'Accept'=> "application/json, text/plain, */*",
+                'Accept-Encoding'=> "gzip, deflate, br, zstd",
+                'Accept-Language'=> "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
+                "Authorization"=> "Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZmEiLCJuaWtlIjoi6Zi_5Y-R5rWL6YCfIiwiY3JlYXRlZCI6MTc1ODc5MDI4NDU3OSwiZHBJZCI6MTkxOTQwLCJleHAiOjE3NTkwNDk0ODQsImVuYWJsZWQiOnRydWUsImF1dGhvcml0aWVzIjpbInpodXlvbmdodSJdLCJkcEFjY291bnRJZCI6MTc4MzU3fQ.TuHvPz7Jf0vuYsbrxX9VpyZ2oOrtZ0YzLQJafoX_RV8up1PmtPLfPATBE93_v_1Ig39nODadaTb4aePy3b0hsA",
+                "Cache-Control"=> "no-cache",
+                'Connection'   => 'keep-alive',
+                "Content-Type"=> "application/json",
+                "Host"      => "fsks.fengsutb.com",
+                "Origin"    => "https://fx.fengsutb.com",
+                "platform" => "ks",
+                "Pragma"=> "no-cache",
+                "Referer"=> "https://fx.fengsutb.com/",
+                "Sec-ch-ua" => '"Chromium";v="140", "Not=A?Brand";v="24", "Microsoft Edge";v="140"',
+                "Sec-ch-ua-Mobile"=> "?0",
+                "Sec-ch-ua-platform"=> "Windows",
+                "Sec-Fetch-Dest" => "empty",
+                "Sec-Fetch-Mode" => "cors",
+                "Sec-Fetch-Site" => "same-site",
+                "User-Agent" => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 Edg/140.0.0.0"
+            ],
+            'jd'  => [
+                'Accept'=> "application/json, text/plain, */*",
+                'Accept-Encoding'=> "gzip, deflate, br, zstd",
+                'Accept-Language'=> "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
+                "Authorization"=> "Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZmEiLCJuaWtlIjoi6Zi_5Y-R5rWL6YCfIiwiY3JlYXRlZCI6MTc1ODc5MDI4NDU3OSwiZHBJZCI6MTkxOTQwLCJleHAiOjE3NTkwNDk0ODQsImVuYWJsZWQiOnRydWUsImF1dGhvcml0aWVzIjpbInpodXlvbmdodSJdLCJkcEFjY291bnRJZCI6MTc4MzU3fQ.TuHvPz7Jf0vuYsbrxX9VpyZ2oOrtZ0YzLQJafoX_RV8up1PmtPLfPATBE93_v_1Ig39nODadaTb4aePy3b0hsA",
+                "Cache-Control"=> "no-cache",
+                'Connection'   => 'keep-alive',
+                "Content-Type"=> "application/json",
+                "Host"      => "fsjd.fengsutb.com",
+                "Origin"    => "https://fx.fengsutb.com",
+                "platform" => "jd",
+                "Pragma"=> "no-cache",
+                "Referer"=> "https://fx.fengsutb.com/",
+                "Sec-ch-ua" => '"Chromium";v="140", "Not=A?Brand";v="24", "Microsoft Edge";v="140"',
+                "Sec-ch-ua-Mobile"=> "?0",
+                "Sec-ch-ua-platform"=> "Windows",
+                "Sec-Fetch-Dest" => "empty",
+                "Sec-Fetch-Mode" => "cors",
+                "Sec-Fetch-Site" => "same-site",
+                "User-Agent" => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 Edg/140.0.0.0"
+            ],
+            'xhs'  => [
+                'Accept'=> "application/json, text/plain, */*",
+                'Accept-Encoding'=> "gzip, deflate, br, zstd",
+                'Accept-Language'=> "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
+                "Authorization"=> "Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZmEiLCJuaWtlIjoi6Zi_5Y-R5rWL6YCfIiwiY3JlYXRlZCI6MTc1ODc5MDI4NDU3OSwiZHBJZCI6MTkxOTQwLCJleHAiOjE3NTkwNDk0ODQsImVuYWJsZWQiOnRydWUsImF1dGhvcml0aWVzIjpbInpodXlvbmdodSJdLCJkcEFjY291bnRJZCI6MTc4MzU3fQ.TuHvPz7Jf0vuYsbrxX9VpyZ2oOrtZ0YzLQJafoX_RV8up1PmtPLfPATBE93_v_1Ig39nODadaTb4aePy3b0hsA",
+                "Cache-Control"=> "no-cache",
+                'Connection'   => 'keep-alive',
+                "Content-Type"=> "application/json",
+                "Host"        => "fsxpt.fengsutb.com",
+                "Origin"      => "https://fx.fengsutb.com",
+                "platform"    => "xhs",
+                "Pragma"      => "no-cache",
+                "Referer"     => "https://fx.fengsutb.com/",
+                "Sec-ch-ua"   => '"Chromium";v="140", "Not=A?Brand";v="24", "Microsoft Edge";v="140"',
+                "Sec-ch-ua-Mobile"=> "?0",
+                "Sec-ch-ua-platform"=> "Windows",
+                "Sec-Fetch-Dest" => "empty",
+                "Sec-Fetch-Mode" => "cors",
+                "Sec-Fetch-Site" => "same-site",
+                "User-Agent" => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 Edg/140.0.0.0"
+            ]
+        ];
+        return $header[$key] ?? [];
+    }
+
+
+}

+ 111 - 28
app/admin/controller/goods/FengsuShip.php

@@ -7,6 +7,10 @@ use app\common\controller\Backend;
 use app\admin\traits\Actions;
 use think\annotation\route\Group;
 use think\annotation\route\Route;
+use think\facade\Db;
+use app\common\model\ShopList;
+use app\common\model\StockConfig;
+
 use app\common\model\FengsuShip as FengsuShipModel;
 
 #[Group("goods/fengsu_ship")]
@@ -15,16 +19,16 @@ class FengsuShip extends Backend
     //app\admin\controller\goods\FengsuShip
     use Actions{
         index as private _index;
-        add as private _add;
-        edit as private _edit;
         del as private _del;
-        multi as private _multi;
     }
 
     protected function _initialize()
     {
         parent::_initialize();
         $this->model = new FengsuShipModel();
+        $this->assign('shopList', ShopList::where('status', 1)->where('shop_id', '')->column('name','id'));
+        $this->assign('typeList',  StockConfig::where('type_id', 'variety_name')->order('sort desc')->column('title','id'));
+        $this->assign('packingList', StockConfig::where('type_id', 'packing_box')->column('title','id'));
     }
 
     //查看
@@ -34,28 +38,116 @@ class FengsuShip extends Backend
         return $this->_index();
     }
 
-    //添加
-    #[Route("GET,POST","add")]
-    public function add()
+    /**
+     * 关联店铺
+     */
+    #[Route('GET,POST','shops')]
+    public function shops()
     {
-        //通过定义postParams来增加或覆盖post提交的表单
-        $this->postParams=[];
-        //通过定义callback回调函数来执行添加后的操作
-        $this->callback=function ($model){};
-        return $this->_add();
+        if (false === $this->request->isPost()) {
+            $ids =$this->request->get('ids/s', '');
+            return $this->fetch();
+        }
+        $params = array_merge($this->request->post("row/a"),$this->postParams);
+        if (empty($params)) {
+            $this->error(__('提交的参数不能为空'));
+        }
+        if(!$this->request->checkToken('__token__',['__token__'=>$this->request->post('__token__')])){
+            $this->error(__('token错误,请刷新页面重试'));
+        }
+        foreach ($params as &$value){
+            if(is_array($value)){
+                $value=implode(',',$value);
+            }
+            if($value===''){
+                $value=null;
+            }
+        }
+        $ids =$this->request->get('ids/s', '');
+        if(empty($params['shop_id'])) $this->error(__('请选择店铺'));
+        $result = false;
+        Db::startTrans();
+        try {
+            //更新店铺
+            ShopList::where('id', $params['shop_id'])->update(['shop_id' => $ids]);
+            //更新状态
+            $result = $this->model->where('shop_id', $ids)->update(['status' => 2]);
+            if($this->callback){
+                $callback=$this->callback;
+                $callback($this->model);
+            }
+            Db::commit();
+        } catch (\Exception $e) {
+            Db::rollback();
+            $this->error($e->getMessage());
+        }
+        if ($result === false) {
+            $this->error(__('没有新增任何数据'));
+        }
+        $this->success();
     }
 
-    //修改
-    #[Route("GET,POST","edit")]
-    public function edit()
+    /**
+     * 关联规格
+     */
+    #[Route('GET,POST','specs')]
+    public function specs(mixed $row=null)
     {
-        //通过定义postParams来增加或覆盖post提交的表单
-        $this->postParams=[];
-        //通过定义callback回调函数来执行修改后的操作
-        $this->callback=function ($model){};
-        return $this->_edit();
+        $ids = $this->request->get('ids');
+        if(!$row || is_array($row)){
+            $row = $this->model->find($ids);
+        }
+        if (!$row) {
+            $this->error(__('没有找到记录'));
+        }
+        if(count($this->volidateFields)>0){
+            foreach ($this->volidateFields as $field=>$value){
+                if($row[$field]!=$value){
+                    $this->error(__('没有操作权限'));
+                }
+            }
+        }
+        if (false === $this->request->isPost()) {
+            $this->assign('row', $row);
+            return $this->fetch();
+        }
+        $params = array_merge($this->request->post("row/a"),$this->postParams);
+        if (empty($params)) {
+            $this->error(__('提交的参数不能为空'));
+        }
+        if(!$this->request->checkToken('__token__',['__token__'=>$this->request->post('__token__')])){
+            $this->error(__('token错误,请刷新页面重试'));
+        }
+        foreach ($params as &$value){
+            if(is_array($value)){
+                $value=implode(',',$value);
+            }
+            if($value===''){
+                $value=null;
+            }
+        }
+        if($params['account_term'] == 2 && empty($params['cycle'])) $this->error(__('请选择周结日期'));
+        $result = false;
+        Db::startTrans();
+        try {
+            $result = $row->save($params);
+            if($this->callback){
+                $callback=$this->callback;
+                $callback($row);
+            }
+            Db::commit();
+        } catch (\Exception $e) {
+            Db::rollback();
+            $this->error($e->getMessage());
+        }
+        if (false === $result) {
+            $this->error(__('没有数据被更新'));
+        }
+        $this->success();
     }
 
+   
+
     //删除
     #[Route("GET,POST","del")]
     public function del()
@@ -65,13 +157,4 @@ class FengsuShip extends Backend
         return $this->_del();
     }
 
-    //更新
-    #[Route("GET,POST","multi")]
-    public function multi()
-    {
-        //通过定义callback回调函数来执行更新后的操作
-        $this->callback=function ($ids,$field,$value){};
-        return $this->_multi();
-    }
-
 }

+ 0 - 6
app/admin/controller/shop/CustomerSpec.php

@@ -7,11 +7,9 @@ use app\common\controller\Backend;
 use app\admin\traits\Actions;
 use think\annotation\route\Group;
 use think\annotation\route\Route;
-use app\common\model\Customer;
 use app\common\model\StockConfig;
 use think\facade\Db;
 use app\common\model\ProductConfig;
-use app\api\service\SpecService;
 use app\common\model\CustomerSpec as CustomerSpecModel;
 
 #[Group("shop/customer_spec")]
@@ -89,11 +87,8 @@ class CustomerSpec extends Backend
                     $row->status  = 1;
                     $row->save();
                     $result++;
-
                 }
-
             }
-
             if($this->callback){
                 $callback=$this->callback;
                 $callback($this->model);
@@ -103,7 +98,6 @@ class CustomerSpec extends Backend
             Db::rollback();
             $this->error($e->getMessage());
         }
-      
         return resp_json(200,'操作成功');
     }
 

+ 93 - 0
app/admin/service/FengsuService.php

@@ -0,0 +1,93 @@
+<?php
+/**
+ * ----------------------------------------------------------------------------
+ * 行到水穷处,坐看云起时
+ * 开发软件,找贵阳云起信息科技,官网地址:https://www.56q7.com/
+ * ----------------------------------------------------------------------------
+ * Author: 老成
+ * email:85556713@qq.com
+ */
+declare(strict_types=1);
+namespace app\admin\service;
+
+
+
+class FengsuService {
+
+    /** 加收价格 
+     * 1.先判断店铺
+     * 2.在判断店铺下面的规格
+     * @param array $item
+     * @return int
+     */
+    public static function getAdditionalPrice(object $shopList, object $fengsuSku, object $productConfig, object $shopDelivery, object $customerSpec, array $item):int
+    {
+        $status = 1;
+        //判断是否存在店铺
+        $shops = $shopList::getSpecsIdByShopId($item['shopId']);
+        if(!$shops->isEmpty()){
+            //判断是否存在规格-获取重量
+            $specs = $fengsuSku::getSpecsIdByShopId($shops->shop_id, $item['tradeOrderPrintVos'][0]['skuId']);
+            if(!$specs->isEmpty()) {
+                //根据规格重量获取,加收价格
+                $weight = $productConfig::getWeight($specs->spec_id);
+                $status = 3;
+                if($weight){
+                    $other_price = self::getRemoteAreaFee($item['tradeOrderPrintVos'][0]['companyName'],  $weight, $item['receiverProvince'], $item['receiverCity']);
+                    //获取包装箱
+                    $box = $customerSpec::getBoxId($shops->customer_id, $specs->variety_id, $specs->spec_id);
+                    $shopDelivery::create([
+                        'customer_id' => $shops->customer_id,
+                        'shop_id' => $shops->id,
+                        'plat_id' => $shops->platform,
+                        'variety_id'    => $specs->variety_id,
+                        'spec_id'       => $specs->spec_id,
+                        'spec_name'     => $specs->spec_name,
+                        'box_id'        => $box->id??0,
+                        'box_name'      => $box->box_name??'',
+                        'variety_name'  => $box->variety_name,
+                        'num'           => $item['tradeOrderPrintVos'][0]['total'],
+                        'weigh'         => $weight,
+                        'price'         => $box->price??0,
+                        'total_price'   => bcmul($box->price, (string)$item['tradeOrderPrintVos'][0]['total'], 2),
+                        'company_name'  => $item['tradeOrderPrintVos'][0]['companyName'],
+                        'waybill_no'    => $item['waybillNo'],
+                        'region'        => $item['receiverProvince'].' '.$item['receiverCity'],
+                        'other_price'   => $other_price,
+                        'ship_date'     => substr($item['consignTime'], 0, 10),
+                    ]);
+                }
+            }else{
+                $status = 2;
+            }
+        }
+        return $status;
+    }
+
+
+    /**
+     * 获取偏远地区加收费用
+     * @param string $express 快递公司名称
+     * @param string $area 省份
+     * @param float $weight 重量
+     * @param string $city 城市
+     * @return float
+     */
+    protected static function getRemoteAreaFee(string $express, string $weight, string $area, string $city = ''){
+        $remote_area = config('app.remote_area');
+        $fee = 0;
+        if($express == '顺丰快递'){
+            if(in_array($area, $remote_area[1])) {
+                if($weight >= 3.5) $fee = 5;
+                if($weight >= 4.5) $fee = 6;
+            };
+        }else{
+            //普通(广东省-深圳) -浙江-舟山
+            if(in_array($area, $remote_area[0])) $fee = 1.5;
+            if($area == '广东省' && $city == '深圳市') $fee = 1.5;
+            if($area == '浙江省' && $city == '舟山市') $fee = 1.5;
+        }
+        return $fee;
+    }
+
+}

+ 14 - 44
app/admin/view/goods/fengsu_ship/index.html

@@ -6,10 +6,9 @@
                 @render="onTableRender"
                 toolbar="refresh,del"
                 :auth="{
-                    add:{:$auth->check('app\\admin\\controller\\goods\\FengsuShip','add')},
-                    edit:{:$auth->check('app\\admin\\controller\\goods\\FengsuShip','edit')},
+               
                     del:{:$auth->check('app\\admin\\controller\\goods\\FengsuShip','del')},
-                    multi:{:$auth->check('app\\admin\\controller\\goods\\FengsuShip','multi')},
+         
                 }"
                 :extend="extend">
         </yun-table>
@@ -35,17 +34,17 @@ export default{
             {field:"id",title:"ID",operate:false},
             {field:"shop_id",title:"店铺ID"},
             {field:"trade_from",title:"平台"},
-            {field:"province",title:"省份",operate: false},
-            {field:"city",title:"城市",operate: false},
-            {field:"company_name",title:"快递名称"},
-            {field:"waybill_no",title:"快递单号"},
-            {field:"goods_title",title:"产品名称"},
+            // {field:"province",title:"省份",operate: false},
+            // {field:"city",title:"城市",operate: false},
+            // {field:"company_name",title:"快递名称"},
+            // {field:"waybill_no",title:"快递单号"},
+            // {field:"goods_title",title:"产品名称"},
             {field:"sku_id",title:"规格id"},
-            {field:"num",title:"件数",operate: false},
-            {field:"price",title:"实付价格",operate: false},
-            {field:"consign_time",title:"发货时间",operate:"daterange",formatter:Yunqi.formatter.datetime},
-            {field:"status",title:"状态",operate:"select",searchList:{1:"无店铺", 2:"无Sku", 3:"正常"},formatter:Yunqi.formatter.tags},
-            {field:"user_id",title:"录入人",operate: false},
+            // {field:"num",title:"件数",operate: false},
+            // {field:"price",title:"实付价格",operate: false},
+            // {field:"consign_time",title:"发货时间",operate:"daterange",formatter:Yunqi.formatter.datetime},
+            // {field:"status",title:"状态",operate:"select",searchList:{1:"无店铺", 2:"无Sku", 3:"正常"},formatter:Yunqi.formatter.tags},
+            // {field:"user_id",title:"录入人",operate: false},
             {field:"createtime",title:"创建时间",operate: false,formatter:Yunqi.formatter.datetime},
             {field:"updatetime",title:"修改时间",visible:false,operate: false,formatter:Yunqi.formatter.datetime},
             {
@@ -59,9 +58,6 @@ export default{
                             type:'success',
                             text:__('关联店铺'),
                             method:'shops',
-                            visible:function(row,index){
-                                return row.status == 1;
-                            }
                         },
                         specs:{
                             tooltip:true,
@@ -77,27 +73,11 @@ export default{
                     }
             }
         ]
-    },
-    //页面加载完成时执行
-    onLoad:function(query){
-        console.log(query);
-    },
-    //页面初始显示或在框架内显示时执行
-    onShow:function(){
-
-    },
-    //页面在框架内隐藏时执行
-    onHide:function(){
-
-    },
-    //页面在框架内关闭时执行
-    onUnload:function(){
-
     },
     methods: {
         shops:function (row){
             Yunqi.api.open({
-                url:'goods/fengsu_ship/shops?ids='+row.id,
+                url:'goods/fengsu_ship/shops?ids='+row.shop_id,
                 width:1000,
                 title:__('关联店铺'),
                 icon:'fa fa-list'
@@ -111,17 +91,7 @@ export default{
                 icon:'fa fa-list'
             });
         },
-        onTableRender:function(list){
-            //表格渲染完成后执行
-            /**
-             * table常用方法
-             * this.$refs.yuntable.reset();//重新渲染整个组件,当columns修改时,需要重新渲染表格才能生效,可以执行该方法。
-             * this.$refs.yuntable.reload();//保持当前的page,重新获取数据
-             * this.$refs.yuntable.submit();//返回第一页,重新获取数据
-             * this.$refs.yuntable.expandAllTree();//树形表格展开所有节点
-             * this.$refs.yuntable.expandTree(topid);//树形表格展开指定节点
-             */
-        }
+  
     }
 }
 </script>

+ 1 - 17
app/admin/view/goods/fengsu_ship/shops.html

@@ -24,23 +24,7 @@ export default{
     data:{
         columns:[
             {field:"id",title:"ID",edit:"hidden"},
-            {field:"shop_id",title:"店铺ID",edit:"text",rules:"required"},
-            {field:"trade_from",title:"平台",edit:"text",rules:"required"},
-            {field:"province",title:"省份",edit:"text",rules:"required"},
-            {field:"city",title:"城市",edit:"text",rules:"required"},
-            {field:"company_name",title:"快递名称",edit:"text",rules:"required"},
-            {field:"waybill_no",title:"快递单号",edit:"text",rules:"required"},
-            {field:"goods_id",title:"产品ID",edit:"text",rules:"required"},
-            {field:"goods_title",title:"产品名称",edit:"text",rules:"required"},
-            {field:"sku_id",title:"规格id",edit:"text",rules:"required"},
-            {field:"num",title:"件数",edit:"number"},
-            {field:"price",title:"实际付款价格",edit:"text",rules:"required"},
-            {field:"weigh",title:"重量(斤)",edit:"text",rules:"required"},
-            {field:"consign_time",title:"发货时间",edit:"text",rules:"required"},
-            {field:"status",title:"结算状态: 1无店铺, 2无Sku 3正常",edit:"switch",searchList:{normal:"正常",hidden:"隐藏"}},
-            {field:"user_id",title:"录入人",edit:"number"},
-            {field:"createtime",title:"创建时间"},
-            {field:"updatetime",title:"修改时间"},
+            {field:"shop_id",title:"店铺名称",searchList:Yunqi.data.shopList,edit: 'select',rules:'required'},
         ],
         row:Yunqi.data.row || {}
     },

+ 186 - 1
app/admin/view/goods/fengsu_ship/specs.html

@@ -1 +1,186 @@
-{include vue="fengsu_ship/add" /}
+<template>
+    <el-card shadow="never" style="min-height: 450px; max-height: 450px; overflow: auto;">
+        <el-tabs tab-position="left" style="height: 100%; overflow: auto;" v-model="tabValue" @tab-click="handleClick">
+            <el-tab-pane v-for="(item,index) in tabData" :label="item.label" :name="item.value">
+            </el-tab-pane>
+            <el-table :data="tableData" style="width: 100%" border :ref="'multipleTable_' + tabValue" stripe
+                @select="handleSelectionChange" @select-all="handleAllSelect">
+                <el-table-column type="selection" width="55">
+                </el-table-column>
+                <el-table-column prop="name" label="规格" align="center">
+                </el-table-column>
+                <el-table-column prop="packet" label="包装箱" align="center">
+                    <template #default="{row}">
+                        <span>{{options[row.box_id]}}</span>
+                    </template>
+                </el-table-column>
+                <el-table-column prop="price" label="发货价" align="center" ></el-table-column>
+                    
+            </el-table>
+        </el-tabs>
+    </el-card>
+    <div style="width: 100%;display: flex; align-items: center; justify-content: center; position: fixed; bottom: 6px;">
+        <el-button type="primary" @click="onSubmit">立即创建</el-button>
+        <el-button>取消</el-button>
+    </div>
+</template>
+<script>
+    import table from "@components/Table.js";
+
+    export default {
+        components: { 'YunTable': table },
+        data: {
+            extend: {
+                index_url: 'general/category/index',
+            },
+            row: Yunqi.data.row,
+            tabData: Object.entries(Yunqi.data.typeList).map(([value, label]) => ({ label, value })),
+            tableData: [],
+            value: "",
+            form: {
+                nameValue: null,
+            },
+            options: Yunqi.data.packingList,//品种
+            tabValue: Object.entries(Yunqi.data.typeList).map(([value, label]) => ({ label, value }))[0].value, //选中的品种 获取到品种数据后要给他默认赋值第一个
+
+            chooseSpec: [], // 当前分类选中的规格  
+
+            allData: {},
+            type: 1, // 1编辑 0新增
+        },
+        methods: {
+            onSubmit() {
+
+                if (this.allData == "") return;
+                let arr = Object.values(this.allData).flat(Infinity)
+
+                Yunqi.ajax.post('shop/shop_list/specs', { ids: Yunqi.data.ids, all_data: arr }, false, false, true).then(res => {
+                    if (res.code == 200) {
+                        this.$message.success(__('设置成功'));
+                        //倒计时刷新窗口
+                        setTimeout(() => {
+                            Yunqi.api.closelayer(Yunqi.app.window.id, true);
+                        }, 1000);
+                    } else {
+                        Yunqi.alert(__('请填写发货价格'), __('温馨提示'), { type: 'error' });
+                    }
+                });
+
+            },
+            handleAllSelect(e){
+                this.allData[this.tabValue] = e || []
+            },
+            handleSelectionChange(e) {
+                //console.log(e,"选中的数据")
+                // if (e.length > 0) {
+                    this.allData[this.tabValue] = e || []
+                // }
+            },
+            handleClick(data, row) {
+                // 品种切换事件 可以在这里请求规格接口
+                this.tabValue = data.props.name
+                this.tabName = data.props.label
+                this.tableData = [];
+                this.getSpecData()
+            },
+            getSpecData() {
+
+                //获取规格 ;
+                Yunqi.ajax.get('shop/shop_list/get_box', { ids: Yunqi.data.ids, type_id: this.tabValue }, false, false, true).then(res => {
+                    //编辑数据
+                    if (res.length > 0) {
+                        for (var key in Object(res)) {
+                            let index = this.tableData.findIndex(item => item.value == res[key]['id']);
+                            if (index != -1) {
+                                this.tableData.splice(index, 1)
+                            } else {
+                                this.tableData.push({name: res[key]['title'], value: res[key]['product_id'], price: res[key]['price'], box_id: res[key]['box_id'],box_name: res[key]['box_name'], type_name: res[key]['type_name'], type_id: this.tabValue });
+                            }
+                        }
+                        this.$nextTick(() => {
+                            const tableRef = this.$refs['multipleTable_' + this.tabValue];
+                            if (this.type == 0 && this.allData[this.tabValue]?.length > 0 && tableRef) {
+                                this.tableData.forEach((item, index) => {
+                                    const matched = this.allData[this.tabValue].find(row => {
+                                        return row.value == item.value
+                                    });
+
+                                    if (matched) {
+                                        this.tableData[index] = matched
+                                    }
+                                })
+                                this.allData[this.tabValue].forEach(selected => {
+                                    const matched = this.tableData.find(row => row.value === selected.value);
+                                    if (matched) {
+                                        this.$refs['multipleTable_' + this.tabValue].toggleRowSelection(matched, true); // 勾选
+                                    }
+                                });
+                            }
+                            else if (this.type == 1 && this.allData[Number(this.tabValue)]) {
+                                this.tableData.forEach((item, index) => {
+                                    const matched = this.allData[Number(this.tabValue)].find(row => {
+                                        if (row.product_id) {
+                                            return row.product_id == item.value
+                                        } else {
+                                            return row.value == item.value
+                                        }
+
+                                    });
+
+                                    if (matched) {
+                                        // this.tableData[index] = { name: 'kam', value: 3, price: '111', type_id: '4', packet: '3' }
+                                        if (matched.product_id) {
+                                            this.tableData[index].name = matched.name
+                                            this.tableData[index].box_name = matched.box_name
+                                            this.tableData[index].type_name = matched.type_name
+                                            this.tableData[index].price = matched.price
+                                            this.tableData[index].packet = matched.box_id != 0 ? matched?.box_id.toString() : ""
+                                        } else {
+                                            this.tableData[index] = matched
+                                        }
+                                    }
+                                })
+                                this.allData[Number(this.tabValue)].forEach(selected => {
+                                    const matched = this.tableData.find(row => {
+                                        if (selected.product_id) {
+                                            return selected.product_id == row.value
+                                        } else {
+                                            return row.value === selected.value
+                                        }
+                                    });
+                                    if (matched) {
+                                        this.$refs['multipleTable_' + this.tabValue].toggleRowSelection(matched, true); // 勾选
+                                    }
+                                });
+                                // this.type = 0
+                            }
+                        });
+                    }
+                });
+            }
+
+        },
+        onLoad: function (query) {
+            let row = Yunqi.data.row;
+            if (row) {
+                this.type = 1
+                const grouped = JSON.parse(row).reduce((acc, item) => {
+                    const key = item.type_id;
+                    if (!acc[key]) {
+                        acc[key] = [];
+                    }
+
+                    acc[key].push(item);
+                    return acc;
+                }, {});
+                this.allData = JSON.parse(JSON.stringify(grouped))
+            } else {
+                this.type = 0
+            }
+            //你只需要保存规格是吧, 是你末尾加了个row
+            this.getSpecData()
+        },
+    }
+</script>
+<style>
+</style>

+ 22 - 0
app/common/model/CrontabLog.php

@@ -0,0 +1,22 @@
+<?php
+declare(strict_types=1);
+
+namespace app\common\model;
+
+use think\Model;
+
+//定时任务日志
+class CrontabLog Extends Model
+{
+    // 自动写入时间戳字段
+    protected $autoWriteTimestamp = false;
+  
+
+    //  最后执行时间
+    //  0淘宝 1拼多多 2抖音 3快手 4京东 5小红书
+    public static function getLastRunTime(int $type_id): string
+    {
+        $last_time = self::where('type_id', $type_id)->value('last_time');
+        return $last_time ? $last_time : date('Y-m-d H:i:s') ;
+    }
+}

+ 11 - 0
app/common/model/CustomerSpec.php

@@ -15,4 +15,15 @@ class CustomerSpec Extends Model
       {
             return $this->hasOne(Customer::class,'id','customer_id');
       }
+
+      //获取客户规格
+      public static function getBoxId(int $customer_id, int $type_id, int $spec_id): object
+      {
+            return self::alias('a')
+            ->leftjoin('stock_config b', 'a.box_id = b.id')
+            ->leftjoin('stock_config c', 'a.type_id = c.id')
+            ->where('a.customer_id', $customer_id)->where('a.type_id', $type_id)->where('a.product_id', $spec_id)
+            ->field('a.price,b.id,b.title as box_name,c.title as variety_name')
+            ->findOrEmpty();
+      }
 }

+ 5 - 4
app/common/model/FengsuShip.php

@@ -17,9 +17,10 @@ class FengsuShip Extends Model
         'updatetime'     =>  'timestamp:Y-m-d H:i',
     ];
 
-    public static function onAfterInsert($data)
+    
+    //获取最后一条记录
+    public static function getLastRecord()
     {
-        $data->weigh=1000-$data->id;
-        $data->save();
+        return self::order('id','desc')->getByName('createtime');
     }
-}
+} 

+ 6 - 10
app/common/model/ShippingLog.php → app/common/model/FengsuSku.php

@@ -6,7 +6,7 @@ namespace app\common\model;
 use think\Model;
 
 //风速-发货记录
-class FengsuShip Extends Model
+class FengsuSku Extends Model
 {
     // 自动写入时间戳字段
     protected $autoWriteTimestamp = true;
@@ -19,18 +19,14 @@ class FengsuShip Extends Model
     ];
 
 
-    //获取最后一条记录
-    public static function getLastRecord()
-    {
-        return self::order('id','desc')->getByName('createtime');
-    }
-
-
-
-
     public function stockconfig()
     {
         return $this->hasOne(StockConfig::class,'id','variety_id')->field('id,title');
     }
     
+    //获取店铺下规格
+    public static function getSpecsIdByShopId(string $shop_id,  string $spec_id): object
+    {
+        return self::where('shop_id', $shop_id)->where('sku_id', $spec_id)->findOrEmpty();
+    }
 }

+ 9 - 0
app/common/model/ProductConfig.php

@@ -8,4 +8,13 @@ use app\common\model\base\BaseModel;
 class ProductConfig extends BaseModel
 {
 
+
+      //获取规格重量
+      public static function getWeight(int $id): float|string|null
+      {
+          return self::where('id', $id)->value('weight');
+      }
+
+      
+
 }

+ 6 - 1
app/common/model/ShopList.php

@@ -9,7 +9,6 @@ class ShopList Extends Model
 {
 
 
-
       //客户
       public function customer()
       {
@@ -23,6 +22,12 @@ class ShopList Extends Model
       }
 
 
+      //获取店铺,规格id
+      public static function getSpecsIdByShopId(string $shop_id): object
+      {     
+            return self::where('shop_id', $shop_id)->findOrEmpty();
+      }
+
 
       //获取店铺客户信息
       public static function getCustomerByShopId(int $shop_id): object

+ 7 - 1
config/console.php

@@ -6,6 +6,12 @@ return [
     // 指令定义
     'commands' => [
         'Queue' => 'app\admin\command\Queue',
-        'Task' => 'app\admin\command\Task',
+        
+        'Tasktb' => 'app\admin\command\TaskTb', // 淘宝
+        'Taskpdd' => 'app\admin\command\TaskPdd', // 拼多多
+        'Taskdy' => 'app\admin\command\TaskDy', // 抖音
+        'Taskks' => 'app\admin\command\TaskKs', // 快手
+        'Taskjd' => 'app\admin\command\TaskJd', // 京东
+        'Taskxhs' => 'app\admin\command\TaskXhs', // 小红书
     ],
 ];