Parcourir la source

refactor: 统一代码风格

runphp il y a 2 semaines
Parent
commit
36a3203dfd

+ 2 - 1
config.php

@@ -1,4 +1,5 @@
 <?php
+
 declare(strict_types=1);
 
 return json_decode(<<<'JSON'
@@ -43,4 +44,4 @@ return json_decode(<<<'JSON'
     "_fc_drag_tag": "input"
   }
 ]
-JSON, true);
+JSON, true);

+ 44 - 43
database/migrations/20250727172015_wuliu.php

@@ -1,4 +1,5 @@
 <?php
+
 declare(strict_types=1);
 
 use Phinx\Migration\AbstractMigration;
@@ -29,49 +30,49 @@ class Wuliu extends AbstractMigration
     public function change()
     {
 
-//        {
-//            "status": "0",/* status 0:正常查询 201:快递单号错误 203:快递公司不存在 204:快递公司识别失败 205:没有信息 207:该单号被限制,错误单号 */
-//	"msg": "ok",
-//	"result": {
-//            "number": "780098068058",
-//		"type": "zto",
-//		"list": [{
-//                "time": "2018-03-09 11:59:26",
-//			"status": "【石家庄市】快件已在【长安三部】 签收,签收人: 本人,感谢使用中通快递,期待再次为您服务!"
-//		}, {
-//                "time": "2018-03-09 09:03:10",
-//			"status": "【石家庄市】 快件已到达 【长安三部】(0311-85344265),业务员 容晓光(15908220064) 正在第1次派件, 请保持电话畅通,并耐心等待"
-//		}, {
-//                "time": "2018-03-08 23:43:44",
-//			"status": "【石家庄市】 快件离开 【石家庄】 发往 【长安三部】"
-//		}, {
-//                "time": "2018-03-08 21:00:44",
-//			"status": "【石家庄市】 快件到达 【石家庄】"
-//		}, {
-//                "time": "2018-03-07 01:38:45",
-//			"status": "【广州市】 快件离开 【广州中心】 发往 【石家庄】"
-//		}, {
-//                "time": "2018-03-07 01:36:53",
-//			"status": "【广州市】 快件到达 【广州中心】"
-//		}, {
-//                "time": "2018-03-07 00:40:57",
-//			"status": "【广州市】 快件离开 【广州花都】 发往 【石家庄中转】"
-//		}, {
-//                "time": "2018-03-07 00:01:55",
-//			"status": "【广州市】 【广州花都】(020-37738523) 的 马溪 (18998345739) 已揽收"
-//		}],
-//		"deliverystatus": "3", /* 0:快递收件(揽件)1.在途中 2.正在派件 3.已签收 4.派送失败 5.疑难件 6.退件签收  */
-//		"issign": "1",                      /*  1.是否签收                  */
-//		"expName": "中通快递",              /*  快递公司名称                */
-//		"expSite": "www.zto.com",           /*  快递公司官网                */
-//		"expPhone": "95311",                /*  快递公司电话                */
-//		"courier": "容晓光",                /*  快递员 或 快递站(没有则为空)*/
-//        "courierPhone":"15908220064",       /*  快递员电话 (没有则为空)     */
-//        "updateTime":"2019-08-27 13:56:19", /*  快递轨迹信息最新时间        */
-//        "takeTime":"2天20小时14分",         /*  发货到收货消耗时长 (截止最新轨迹)  */
-//        "logo":"https://img3.fegine.com/express/zto.jpg" /* 快递公司LOGO */
-//	}
-//}
+        //        {
+        //            "status": "0",/* status 0:正常查询 201:快递单号错误 203:快递公司不存在 204:快递公司识别失败 205:没有信息 207:该单号被限制,错误单号 */
+        //	"msg": "ok",
+        //	"result": {
+        //            "number": "780098068058",
+        //		"type": "zto",
+        //		"list": [{
+        //                "time": "2018-03-09 11:59:26",
+        //			"status": "【石家庄市】快件已在【长安三部】 签收,签收人: 本人,感谢使用中通快递,期待再次为您服务!"
+        //		}, {
+        //                "time": "2018-03-09 09:03:10",
+        //			"status": "【石家庄市】 快件已到达 【长安三部】(0311-85344265),业务员 容晓光(15908220064) 正在第1次派件, 请保持电话畅通,并耐心等待"
+        //		}, {
+        //                "time": "2018-03-08 23:43:44",
+        //			"status": "【石家庄市】 快件离开 【石家庄】 发往 【长安三部】"
+        //		}, {
+        //                "time": "2018-03-08 21:00:44",
+        //			"status": "【石家庄市】 快件到达 【石家庄】"
+        //		}, {
+        //                "time": "2018-03-07 01:38:45",
+        //			"status": "【广州市】 快件离开 【广州中心】 发往 【石家庄】"
+        //		}, {
+        //                "time": "2018-03-07 01:36:53",
+        //			"status": "【广州市】 快件到达 【广州中心】"
+        //		}, {
+        //                "time": "2018-03-07 00:40:57",
+        //			"status": "【广州市】 快件离开 【广州花都】 发往 【石家庄中转】"
+        //		}, {
+        //                "time": "2018-03-07 00:01:55",
+        //			"status": "【广州市】 【广州花都】(020-37738523) 的 马溪 (18998345739) 已揽收"
+        //		}],
+        //		"deliverystatus": "3", /* 0:快递收件(揽件)1.在途中 2.正在派件 3.已签收 4.派送失败 5.疑难件 6.退件签收  */
+        //		"issign": "1",                      /*  1.是否签收                  */
+        //		"expName": "中通快递",              /*  快递公司名称                */
+        //		"expSite": "www.zto.com",           /*  快递公司官网                */
+        //		"expPhone": "95311",                /*  快递公司电话                */
+        //		"courier": "容晓光",                /*  快递员 或 快递站(没有则为空)*/
+        //        "courierPhone":"15908220064",       /*  快递员电话 (没有则为空)     */
+        //        "updateTime":"2019-08-27 13:56:19", /*  快递轨迹信息最新时间        */
+        //        "takeTime":"2天20小时14分",         /*  发货到收货消耗时长 (截止最新轨迹)  */
+        //        "logo":"https://img3.fegine.com/express/zto.jpg" /* 快递公司LOGO */
+        //	}
+        //}
 
         $table = $this->table('extension_wuliu', ['comment' => '物流数据']);
         $table

+ 1 - 0
info.php

@@ -1,4 +1,5 @@
 <?php
+
 declare(strict_types=1);
 return [
   'id' => 'aliyun_wuliu',

+ 2 - 1
route/api.php

@@ -1,7 +1,8 @@
 <?php
+
 declare(strict_types=1);
 
 use SixShop\AliyunWuliu\Controller\IndexController;
 use think\facade\Route;
 
-Route::get('',  [IndexController::class, 'index'])->middleware(['auth']);
+Route::get('', [IndexController::class, 'index'])->middleware(['auth']);

+ 2 - 1
src/Config.php

@@ -1,4 +1,5 @@
 <?php
+
 declare(strict_types=1);
 
 namespace SixShop\AliyunWuliu;
@@ -18,4 +19,4 @@ class Config
     {
         return Extension::EXTENSION_ID;
     }
-}
+}

+ 6 - 3
src/Controller/IndexController.php

@@ -1,9 +1,12 @@
 <?php
+
 declare(strict_types=1);
+
 namespace SixShop\AliyunWuliu\Controller;
 
 use SixShop\AliyunWuliu\Entity\ExtensionWuLiuEntity;
 use SixShop\Core\Request;
+
 use function SixShop\Core\success_response;
 
 class IndexController
@@ -14,10 +17,10 @@ class IndexController
             'no/s',
             'type/s' => ''
         ]);
-        validate( [
+        validate([
             'no' => 'require|alphaNum',
             'type' => 'alphaNum'
         ])->check($params);
-        return success_response($entity->getWuliuInfo((int)$request->userID,$params['no'], $params['type']));
+        return success_response($entity->getWuliuInfo((int)$request->userID, $params['no'], $params['type']));
     }
-}
+}

+ 3 - 4
src/Entity/ExtensionWuLiuEntity.php

@@ -1,15 +1,14 @@
 <?php
+
 declare(strict_types=1);
 
 namespace SixShop\AliyunWuliu\Entity;
 
-use SixShop\AliyunWuliu\Extension;
 use SixShop\AliyunWuliu\Facade\WuLiuClient;
-use SixShop\Core\Contracts\LogisticsInformationResponse;
-use SixShop\Core\Contracts\LogisticsInterface;
 use SixShop\Core\Entity\BaseEntity;
 use think\facade\Cache;
 use think\Model;
+
 use function SixShop\Core\throw_logic_exception;
 
 class ExtensionWuLiuEntity extends BaseEntity
@@ -51,4 +50,4 @@ class ExtensionWuLiuEntity extends BaseEntity
         $entity->save();
         return $entity;
     }
-}
+}

+ 1 - 2
src/Extension.php

@@ -1,14 +1,13 @@
 <?php
+
 declare(strict_types=1);
 
 namespace SixShop\AliyunWuliu;
 
-use SixShop\AliyunWuliu\Entity\ExtensionWuLiuEntity;
 use SixShop\AliyunWuliu\Service\LogisticsService;
 use SixShop\Core\Contracts\LogisticsInterface;
 use SixShop\Core\ExtensionAbstract;
 use think\App;
-use think\facade\Log;
 
 class Extension extends ExtensionAbstract
 {

+ 3 - 1
src/Facade/WuLiuClient.php

@@ -1,5 +1,7 @@
 <?php
+
 declare(strict_types=1);
+
 namespace SixShop\AliyunWuliu\Facade;
 
 use think\Facade;
@@ -14,4 +16,4 @@ class WuLiuClient extends Facade
     {
         return \SixShop\AliyunWuliu\WuLiuClient::class;
     }
-}
+}

+ 3 - 1
src/Model/ExtensionWuLiuExpressModel.php

@@ -1,5 +1,7 @@
 <?php
+
 declare(strict_types=1);
+
 namespace SixShop\AliyunWuliu\Model;
 
 use think\Model;
@@ -12,4 +14,4 @@ class ExtensionWuLiuExpressModel extends Model
             'name' => 'extension_wuliu_express',
         ];
     }
-}
+}

+ 3 - 1
src/Model/ExtensionWuLiuModel.php

@@ -1,5 +1,7 @@
 <?php
+
 declare(strict_types=1);
+
 namespace SixShop\AliyunWuliu\Model;
 
 use think\Model;
@@ -15,4 +17,4 @@ class ExtensionWuLiuModel extends Model
             ],
         ];
     }
-}
+}

+ 4 - 2
src/Service/LogisticsService.php

@@ -1,5 +1,7 @@
 <?php
+
 declare(strict_types=1);
+
 namespace SixShop\AliyunWuliu\Service;
 
 use SixShop\AliyunWuliu\Entity\ExtensionWuLiuEntity;
@@ -19,7 +21,7 @@ class LogisticsService implements LogisticsInterface
         $entity = $this->extensionWuLiuEntity->where('number', $number)->when($type, function (Model $query, $type) {
             $query->where('type', $type);
         })->findOrEmpty();
-        if (!$entity->isEmpty() && ($entity->is_sign == 1 || strtotime( $entity->update_time) > time() - 600)) {
+        if (!$entity->isEmpty() && ($entity->is_sign == 1 || strtotime($entity->update_time) > time() - 600)) {
             // 已签收或10分钟内更新过,直接返回
         } else {
             $entity = $this->extensionWuLiuEntity->queryLogistics($number, $type, $entity);
@@ -31,4 +33,4 @@ class LogisticsService implements LogisticsInterface
             $entity->toArray()
         );
     }
-}
+}

+ 3 - 2
src/WuLiuClient.php

@@ -1,15 +1,16 @@
 <?php
+
 declare(strict_types=1);
 
 namespace SixShop\AliyunWuliu;
 
 use Symfony\Component\HttpClient\HttpClient;
 use Symfony\Contracts\HttpClient\HttpClientInterface;
+
 use function SixShop\Core\throw_logic_exception;
 
 class WuLiuClient
 {
-
     private const string GATEWAY = 'https://wuliu.market.alicloudapi.com/';
 
     private HttpClientInterface $httpClient;
@@ -59,4 +60,4 @@ class WuLiuClient
             throw_logic_exception($result->msg);
         }
     }
-}
+}

+ 3 - 1
test/WuLiuClientTest.php

@@ -1,5 +1,7 @@
 <?php
+
 declare(strict_types=1);
+
 namespace SixShop\AliyunWuliu;
 
 use PHPUnit\Framework\TestCase;
@@ -24,4 +26,4 @@ class WuLiuClientTest extends TestCase
         $result = $this->client->getExpressList();
         dump($result);
     }
-}
+}