Ver código fonte

添加风速同步

jason 10 horas atrás
pai
commit
628080143b

+ 311 - 0
app/admin/command/FengSu.php

@@ -0,0 +1,311 @@
+<?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 FengSu extends Command
+{
+    
+    //抖音请求地址
+    protected $url = 'https://fsdy2.fengsutb.com/amount/ship-list-new';
+
+    //抖音请求头部
+    protected $headers = [
+        'Host' => 'fsdy2.fengsutb.com',
+        'Accept' => 'application/json, text/plain, */*',
+        'Authorization' => 'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIxODYwNTQ1MTExNSIsImRhdGFfcGVybWlzc2lvbiI6InByb2R1Y3RDb3N0IiwibmlrZSI6IjE4NjA1NDUxMTE1IiwiY3JlYXRlZCI6MTc2NDEyNTQwMzQ0OSwiZHBJZCI6MTAwNjczLCJleHAiOjE3NjQ3MzAyMDMsImVuYWJsZWQiOnRydWUsImF1dGhvcml0aWVzIjpbInpodXlvbmdodSJdLCJkcEFjY291bnRJZCI6MTAwNjczfQ.ihv6NRfD2hzU1NQoqttTaZ-mPxqAEXIUICM8MuxVx2tVLEPW9j-uPhHoFz4T3-lH07wTt2ORf1k_SPOQP4PuQg',
+        'Content-Type' => 'application/json',
+        'platform' => 'dy',
+    ];
+
+    // 指令配置
+    protected function configure()
+    {
+        $this->setName('feng_su')->setDescription('the task command');
+    }
+
+    //根据shop_id
+    protected function execute(Input $input, Output $output)
+    {
+        $output->writeln('开始同步订单');
+
+        $resquet = $this->getOrderList('dy');
+        if($resquet['code'] == 0){
+            if($resquet['data']['total'] > 0){
+                $list = $resquet['data']['list'];
+                $this->insertOrder($list);
+                //dump($resquet);
+            }else{
+                $output->writeln('没有数据');
+            }
+        }else{
+            $output->writeln('接口错误: ' .$resquet['message']);
+        }
+
+        $output->writeln('ok');
+    }
+
+    public function getOrderList($platform = 'dy')
+    {
+        $client = new \GuzzleHttp\Client([
+            'verify' => false,
+            // 或指定证书路径
+            // 'verify' => '/path/to/cacert.pem'
+        ]);
+
+        $headers = [
+            'Accept' => ' application/json, text/plain, */*',
+            'Authorization' => 'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIxODYwNTQ1MTExNSIsImRhdGFfcGVybWlzc2lvbiI6InByb2R1Y3RDb3N0IiwibmlrZSI6IjE4NjA1NDUxMTE1IiwiY3JlYXRlZCI6MTc2NDEyNTQwMzQ0OSwiZHBJZCI6MTAwNjczLCJleHAiOjE3NjQ3MzAyMDMsImVuYWJsZWQiOnRydWUsImF1dGhvcml0aWVzIjpbInpodXlvbmdodSJdLCJkcEFjY291bnRJZCI6MTAwNjczfQ.ihv6NRfD2hzU1NQoqttTaZ-mPxqAEXIUICM8MuxVx2tVLEPW9j-uPhHoFz4T3-lH07wTt2ORf1k_SPOQP4PuQg',
+            'Host' => ' fsdy2.fengsutb.com',
+            'platform' => $platform,
+            'Content-Type' => ' application/json'
+        ];
+        $body = '{
+                "sort": "CONSIGN_TIME",
+                "sortAsc": false,
+                "current": 1,
+                "size": 100,
+                "tradeStatus": 2,
+                "fromAccountId": [],
+                "goodType": 3,
+                "goodsFlag": 1
+        }';
+        $request = new Request('POST', 'https://fsdy2.fengsutb.com/amount/ship-list-new', $headers, $body);
+        $res = $client->sendAsync($request)->wait();
+        $json = [];
+        if($res->getStatusCode() == 200) {
+            $json = json_decode($res->getBody()->getContents(), true);
+        }else{
+            dump($res->getStatusCode(), '接口返回结果');
+        }
+        return $json;
+    }
+    public function insertOrder($order_list)
+    {
+        if(!(count($order_list) > 0)){
+            return false;
+        }
+        $queue = [];
+        $shopList = new ShopList();
+        $fengsuSku = new FengsuSku();
+        $productConfig = new ProductConfig();
+        $shopDelivery = new ShopDelivery();
+        $customerSpec = new CustomerSpec();
+        foreach($order_list as $item) {
+            dump($item['shopId'], '店铺id');
+            $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' => 2,'last_time' => date('Y-m-d H:i:s')]);
+    }
+}
+//风速接口返回格式
+//            {
+//                "shopId": "DY117939700",
+//                "sysNum": "3908161982177974",
+//                "groupId": "g3908162034664709",
+//                "tradeFrom": "dy",
+//                "tid": "6948414820472788426",
+//                "fromAccountId": 0,
+//                "createTime": "2025-11-26 21:27:53",
+//                "payTime": "2025-11-26 21:27:55",
+//                "inserTime": "2025-11-27 15:11:27",
+//                "inventoryPrintTime": null,
+//                "consignTime": "2025-11-27 15:11:27",
+//                "refunding": 0,
+//                "buyerId": "1@#MhctHqbGY6MptrPvaPcNSU6JEPT1RwM+zhPxvrsCvBSVf2u9/qsla+xb9Fu81aUBMmCH",
+//                "buyerNick": null,
+//                "buyerMessage": "",
+//                "sellerFlag": 0,
+//                "localFlag": 0,
+//                "sellerMemo": null,
+//                "localMemo": null,
+//                "offlineMemo": null,
+//                "offlineFlag": null,
+//                "receiverProvince": "黑龙江省",
+//                "receiverCity": "哈尔滨市",
+//                "receiverDistrict": "依兰县",
+//                "receiverTown": "依兰镇",
+//                "desensitizationName": "昕*",
+//                "desensitizationPhone": null,
+//                "desensitizationAddress": "*******",
+//                "desensitizationMobile": "1**********",
+//                "modifyAddr": 0,
+//                "invoiceType": null,
+//                "invoiceTitle": null,
+//                "invoiceTaxId": null,
+//                "promiseShipTime": "2025-12-01 21:27:56",
+//                "tradeStatus": "WAIT_CONFIRM",
+//                "payment": 9440,
+//                "receiptAmount": 9440,
+//                "postFee": 0,
+//                "splitType": 1,
+//                "packageNum": 1,
+//                "dpAccountId": 100673,
+//                "bizDpAccountId": 100673,
+//                "uid": "117939700",
+//                "bizShopId": "DY117939700",
+//                "companyName": "中通快递",
+//                "waybillNo": null,
+//                "companyId": 3,
+//                "templateId": 145375,
+//                "printSize": 1,
+//                "mergeHash": "6BC35CF08C74762098670BB71B38F77C387FB374",
+//                "mergeHash2": "AC9CEFB7FD89A32A1AA235A9E09BD69FE838D08D",
+//                "mergeable": 0,
+//                "handDeliverFlag": 0,
+//                "tradeAttr": "{\"promise_type\":1,\"recommend_logistics_list\":\"[]\"}",
+//                "localAttr": null,
+//                "senderAddressEntity": null,
+//                "outChannel": null,
+//                "tradeFlag": null,
+//                "link": "",
+//                "roleFlg": true,
+//                "shopFlg": true,
+//                "saleFlg": true,
+//                "picUrlFlag": true,
+//                "preSale": 1,
+//                "preSaleTime": null,
+//                "splitFailReason": null,
+//                "businessTag": 0,
+//                "locked": 0,
+//                "tradeOrderPrintVos": [
+//                    {
+//                        "distTime": null,
+//                        "orderStatus": "WAIT_CONFIRM",
+//                        "goodsTitle": "田与薯云南圆圆果·榴莲蜜薯软糯蜜甜新鲜高原黄心番薯地瓜粗粮",
+//                        "goodsId": "3665081518029678296",
+//                        "skuProp": "{\"65\":\"小糖豆(50g-150g)\",\"66\":\"5斤(精品装(带箱5斤))\",\"67\":\"5天内发货\"}",
+//                        "companyName": "中通快递",
+//                        "waybillNo": "76767227765924",
+//                        "outerId": null,
+//                        "refundStatus": null,
+//                        "picUrl": "https://p3-aio.ecombdimg.com/obj/ecom-shop-material/jpeg_m_e379a8d857f16246745a757892497184_sx_320989_www1668-1668",
+//                        "total": 1,
+//                        "price": 3980,
+//                        "payment": 3780,
+//                        "receiptAmount": null,
+//                        "orderType": 0,
+//                        "consignTime": "2025-11-27 15:11:27",
+//                        "signTime": null,
+//                        "weight": 0,
+//                        "goodShortName": null,
+//                        "skuShortName": null,
+//                        "oid": "6948414820472788426",
+//                        "packageNum": 1,
+//                        "splitType": 1,
+//                        "companyId": 3,
+//                        "templateId": 145375,
+//                        "outerSkuId": "LFT-LLSPK-4.5-SC-CX",
+//                        "skuId": "3617103894193922",
+//                        "printSize": 1,
+//                        "printTime": "2025-11-27 15:11:22",
+//                        "roleType": 1,
+//                        "roleName": "田与薯官方旗舰店",
+//                        "lastFactoryId": 100673,
+//                        "inventoryPrintSize": 0,
+//                        "inventoryPrintTime": null,
+//                        "platCode": "ZJ",
+//                        "purchaseAttr": null,
+//                        "shelfPosition": "",
+//                        "pushTime": null,
+//                        "orderAttr": "{\"author_name\":\"田与薯官方旗舰店\",\"order_goods_type\":0,\"order_biz\":2,\"pre_sale_label\":\"全款预售\",\"compensate_for_rotten_platform_guarantee\":\"坏了包退官方保障\",\"quick_refund_label\":\"极速退\",\"unsupport_7days_refund\":\"不支持7天\",\"c_biz_self_sell\":\"小店自卖\",\"compass_source_not_ad_mark\":\"非广告\",\"compass_source_content_type_live\":\"直播\",\"afterSaleType\":\"refund\",\"source_platform\":\"\",\"period_purchase_info\":{},\"pack_id\":\"147242304405974025\"}",
+//                        "freeze": 0,
+//                        "freezeReason": null,
+//                        "auditStatus": 2,
+//                        "payStatus": null,
+//                        "settleStatus": null,
+//                        "settleRefundStatus": null,
+//                        "settleAmount": null,
+//                        "templateType": "1",
+//                        "productSkuName": null,
+//                        "productSkuCode": null
+//                    }
+//                ],
+//                "tradePrintList": null,
+//                "platCode": "ZJ",
+//                "purchaseId": null,
+//                "purchaseStatus": null,
+//                "supplierName": null,
+//                "supplierId": null,
+//                "purchaseName": null,
+//                "offerId": null,
+//                "specId": null,
+//                "tradeClassify": "NORMAL",
+//                "payType": "NORMAL",
+//                "expressType": "NORMAL",
+//                "msgTradeAttr": null,
+//                "logisticsNames": null,
+//                "logisticsTag": 0,
+//                "tradeSource": null,
+//                "printBatch": null,
+//                "printBatchSn": 0,
+//                "assignDeliveryId": null,
+//                "factoryId": 100673,
+//                "prepareShipGroupId": null,
+//                "prepareShipDeliverStatus": null,
+//                "prepareShipErrorMsg": null,
+//                "prepareShipStatus": 0,
+//                "prepareShipCreateTime": null,
+//                "prepareShipUpdateTime": null,
+//                "waybillEntities": [
+//                    {
+//                        "id": 7671095,
+//                        "dpAccountId": 100673,
+//                        "relationId": 3909499998804122,
+//                        "deliveryId": 3,
+//                        "waybillNo": "76767227765924",
+//                        "createdTime": "2025-11-27 15:11:27",
+//                        "recycleFlag": 0
+//                    }
+//                ],
+//                "relationId": 3909499998804122,
+//                "optType": 0,
+//                "obsStatus": 0,
+//                "obsTime": null,
+//                "obsReason": null,
+//                "printFailReason": null
+//            },

+ 9 - 17
app/admin/command/TaskDy.php

@@ -36,27 +36,12 @@ class TaskDy extends Command
     //抖音请求头部
     protected $headers = [
         'Host' => 'fsdy2.fengsutb.com',
-        'Connection' => 'keep-alive',
-        'sec-ch-ua-platform' => 'Windows',
-        'Authorization' => 'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZmEiLCJuaWtlIjoi6Zi_5Y-R5rWL6YCfIiwiY3JlYXRlZCI6MTc1ODk2NjM3NjU5MywiZHBJZCI6MTkxOTQwLCJleHAiOjE3NTkyMjU1NzYsImVuYWJsZWQiOnRydWUsImF1dGhvcml0aWVzIjpbInpodXlvbmdodSJdLCJkcEFjY291bnRJZCI6MTc4MzU3fQ.S37D56hG2SwttUYy7OBFet-GOeG5wW6U7j1d2NF7UoFzHWlSpSA4IjwZU1d9Z33xD44Zyiib4zGa_QRxCO2imw',
-        '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',
+        'Authorization' => 'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIxODYwNTQ1MTExNSIsImRhdGFfcGVybWlzc2lvbiI6InByb2R1Y3RDb3N0IiwibmlrZSI6IjE4NjA1NDUxMTE1IiwiY3JlYXRlZCI6MTc2NDEyNTQwMzQ0OSwiZHBJZCI6MTAwNjczLCJleHAiOjE3NjQ3MzAyMDMsImVuYWJsZWQiOnRydWUsImF1dGhvcml0aWVzIjpbInpodXlvbmdodSJdLCJkcEFjY291bnRJZCI6MTAwNjczfQ.ihv6NRfD2hzU1NQoqttTaZ-mPxqAEXIUICM8MuxVx2tVLEPW9j-uPhHoFz4T3-lH07wTt2ORf1k_SPOQP4PuQg',
         'Content-Type' => 'application/json',
+        'platform' => 'dy',
     ];
 
-    
-    
-    
     // 指令配置
     protected function configure()
     {
@@ -66,6 +51,7 @@ class TaskDy extends Command
     //根据shop_id
     protected function execute(Input $input, Output $output)
     {
+        dump($this->url);
         $client = new Client([ 'verify' => false]);
         $last_time = CrontabLog::getLastRunTime(2);
         $body = '{
@@ -83,8 +69,14 @@ class TaskDy extends Command
         "tradeStatus": 2
         }';
         //获取Token
+
         $this->headers['Authorization'] = site_config('addonsd.authorization_token');
+        dump($this->headers['Authorization']);
         $request = new Request('POST', $this->url, $this->headers, $body);
+
+        dump($request);
+
+
         $res = $client->sendAsync($request)->wait();
         if($res->getStatusCode() == 200) {
             $data = json_decode($res->getBody()->getContents(), true);  

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

@@ -22,17 +22,27 @@ class FengsuService {
      */
     public static function getAdditionalPrice(object $shopList, object $fengsuSku, object $productConfig, object $shopDelivery, object $customerSpec, array $item):int
     {
+        dump('店铺0');
+
         $status = 1;
         //判断是否存在店铺
         $shops = $shopList::getSpecsIdByShopId($item['shopId']);
+        dump('店铺00');
+
         if(!$shops->isEmpty()){
+            dump('店铺1');
+
             //判断是否存在规格-获取重量
             $specs = $fengsuSku::getSpecsIdByShopId($shops->shop_id, $item['tradeOrderPrintVos'][0]['skuId']);
             if(!$specs->isEmpty()) {
+                dump('店铺2');
+
                 //根据规格重量获取,加收价格
                 $weight = $productConfig::getWeight($specs->spec_id);
                 $status = 3;
                 if($weight){
+                    dump('店铺3');
+
                     $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);

+ 2 - 1
composer.json

@@ -32,7 +32,8 @@
         "topthink/think-captcha": "^3.0",
         "topthink/think-cors": "^1.0",
         "predis/predis": "^3.0",
-        "guzzlehttp/guzzle": "^7.9"
+        "guzzlehttp/guzzle": "^7.9",
+      "ext-curl": "*"
     },
     "require-dev": {
         "symfony/var-dumper": ">=4.2"

+ 9 - 8
composer.lock

@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "8a81a8a747134abf7ecf353bb4daa9c9",
+    "content-hash": "5e5ec956fa0d8d25b58e72551da31828",
     "packages": [
         {
             "name": "composer/pcre",
@@ -1032,16 +1032,16 @@
         },
         {
             "name": "predis/predis",
-            "version": "v3.2.0",
+            "version": "v3.3.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/predis/predis.git",
-                "reference": "9e9deec4dfd3ebf65d32eb368f498c646ba2ecd8"
+                "reference": "153097374b39a2f737fe700ebcd725642526cdec"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/predis/predis/zipball/9e9deec4dfd3ebf65d32eb368f498c646ba2ecd8",
-                "reference": "9e9deec4dfd3ebf65d32eb368f498c646ba2ecd8",
+                "url": "https://api.github.com/repos/predis/predis/zipball/153097374b39a2f737fe700ebcd725642526cdec",
+                "reference": "153097374b39a2f737fe700ebcd725642526cdec",
                 "shasum": ""
             },
             "require": {
@@ -1083,7 +1083,7 @@
             ],
             "support": {
                 "issues": "https://github.com/predis/predis/issues",
-                "source": "https://github.com/predis/predis/tree/v3.2.0"
+                "source": "https://github.com/predis/predis/tree/v3.3.0"
             },
             "funding": [
                 {
@@ -1091,7 +1091,7 @@
                     "type": "github"
                 }
             ],
-            "time": "2025-08-06T06:41:24+00:00"
+            "time": "2025-11-24T17:48:50+00:00"
         },
         {
             "name": "psr/cache",
@@ -2506,7 +2506,8 @@
     "prefer-stable": false,
     "prefer-lowest": false,
     "platform": {
-        "php": ">=8.0.0"
+        "php": ">=8.0.0",
+        "ext-curl": "*"
     },
     "platform-dev": [],
     "plugin-api-version": "2.6.0"

+ 3 - 1
config/console.php

@@ -6,7 +6,9 @@ return [
     // 指令定义
     'commands' => [
         'Queue' => 'app\admin\command\Queue',
-        
+
+        'feng_su' => 'app\admin\command\FengSu',
+
         'Tasktb' => 'app\admin\command\TaskTb', // 淘宝
         'Taskpdd' => 'app\admin\command\TaskPdd', // 拼多多
         'Taskdy' => 'app\admin\command\TaskDy', // 抖音