Bladeren bron

formatting

joe 3 jaren geleden
bovenliggende
commit
b6f9753a0a

+ 2 - 2
app/admin/controller/widget/Images.php

@@ -3,7 +3,6 @@
 namespace app\admin\controller\widget;
 
 use app\admin\controller\AuthController;
-use app\admin\controller\store\StoreProduct;
 use think\facade\Route as Url;
 use app\admin\model\system\{
     SystemAttachment as SystemAttachmentModel,
@@ -46,7 +45,8 @@ class Images extends AuthController
         return $this->fetch('widget/images');
     }
 
-    /**@api {get} widget.images/get_image_list/pid/:pid/page/:page/limit/:limit 获取图片列表
+    /**
+     * @api {get} widget.images/get_image_list/pid/:pid/page/:page/limit/:limit 获取图片列表
      *
      */
     public function get_image_list()

+ 15 - 9
tw/async/activities/ClearanceCalc.php

@@ -17,25 +17,30 @@ use think\facade\Config;
  * Class ClearanceCalc
  * @package crmeb\services\async
  */
-class ClearanceCalc extends ActivityCalc{
+class ClearanceCalc extends ActivityCalc
+{
 
     // 活动代号
     protected static $NAME = 'clr';
 
-    protected function getId() {
+    protected function getId()
+    {
         return Config::get('activity.clearance_cate_id');
     }
 
-    protected function getName() {
+    protected function getName()
+    {
         return self::$NAME;
     }
 
-    protected function getNameCN() {
+    protected function getNameCN()
+    {
         return '神抢手';
     }
 
     // 赔款比例, 为利润的比例
-    protected function repRate() {
+    protected function repRate()
+    {
         return 0.3;
     }
 
@@ -44,7 +49,8 @@ class ClearanceCalc extends ActivityCalc{
         return 1;
     }
 
-    protected function getResult($leftwin=true) {
+    protected function getResult($leftwin = true)
+    {
         return 0;
     }
 
@@ -52,8 +58,8 @@ class ClearanceCalc extends ActivityCalc{
      * 分边函数,返回 true 分到左边
      * 
      */
-    protected function leaningJudge($index, $product, $attr) {
+    protected function leaningJudge($index, $product, $attr)
+    {
         return $index % 2 != 0;
     }
-
-}
+}

+ 11 - 6
tw/async/activities/LuckyExtACalc.php

@@ -4,22 +4,27 @@ namespace tw\async\activities;
 
 use think\facade\Config;
 
-class LuckyExtACalc extends LuckyCalc {
+class LuckyExtACalc extends LuckyCalc
+{
     protected static $NAME = 'lucky_a';
 
-    protected function getId() {
+    protected function getId()
+    {
         return Config::get('activity.lucky_a_cate_id');
     }
 
-    protected function getName() {
+    protected function getName()
+    {
         return self::$NAME;
     }
 
-    protected function getNameCN() {
+    protected function getNameCN()
+    {
         return '番外A';
     }
 
-    protected function repRate() {
+    protected function repRate()
+    {
         return 0.5;
     }
-}
+}

+ 11 - 6
tw/async/activities/LuckyExtBCalc.php

@@ -4,22 +4,27 @@ namespace tw\async\activities;
 
 use think\facade\Config;
 
-class LuckyExtBCalc extends LuckyCalc {
+class LuckyExtBCalc extends LuckyCalc
+{
     protected static $NAME = 'lucky_b';
 
-    protected function getId() {
+    protected function getId()
+    {
         return Config::get('activity.lucky_b_cate_id');
     }
 
-    protected function getName() {
+    protected function getName()
+    {
         return self::$NAME;
     }
 
-    protected function getNameCN() {
+    protected function getNameCN()
+    {
         return '番外B';
     }
 
-    protected function repRate() {
+    protected function repRate()
+    {
         return 0.5;
     }
-}
+}

+ 4 - 3
tw/async/tasks/AsyncClass.php

@@ -1,11 +1,12 @@
 <?php
+
 namespace tw\async\tasks;
 
 use ReflectionClass;
 
-class AsyncClass extends Task 
+class AsyncClass extends Task
 {
-    public function getCmd():string
+    public function getCmd(): string
     {
         return 'async_class';
     }
@@ -45,4 +46,4 @@ class AsyncClass extends Task
             'methodArgs' => $methodArgs,
         ]);
     }
-}
+}

+ 4 - 4
tw/async/tasks/AsyncSms.php

@@ -7,9 +7,9 @@ use crmeb\repositories\ShortLetterRepositories;
 /**
  * 异步发短信
  */
-class AsyncSms extends Task {
-
-    public function getCmd():string
+class AsyncSms extends Task
+{
+    public function getCmd(): string
     {
         return 'sms';
     }
@@ -36,4 +36,4 @@ class AsyncSms extends Task {
             'template' => $template,
         ]);
     }
-}
+}

+ 4 - 3
tw/async/tasks/Task.php

@@ -37,13 +37,14 @@ use think\facade\Config;
  * 
  * 增加任务到 beanstalkd 代码
  */
-abstract class Task {
+abstract class Task
+{
     /**
      * 虚函数。返回任务 cmd 标识, 任务类别
      * 
      * @return string
      */
-    abstract public function getCmd() : string;
+    abstract public function getCmd(): string;
 
     /**
      * 虚函数。执行从 beanstalkd 中取出的任务数据 $task.
@@ -115,4 +116,4 @@ abstract class Task {
         }
         return true;
     }
-}
+}

+ 15 - 11
tw/async/tasks/UserTaskClass.php

@@ -1,4 +1,5 @@
-<?php 
+<?php
+
 namespace tw\async\tasks;
 
 use app\admin\model\system\SystemAttachment;
@@ -11,7 +12,8 @@ use app\models\user\User;
 /**
  * 和用户相关的异步任务,采用 AsyncClass 的执行方法 
  */
-class UserTaskClass {
+class UserTaskClass
+{
     const QINIU_PATH = 'user_share_qrcode'; // 海报保存在七牛目录的子路径
 
     /**
@@ -22,7 +24,7 @@ class UserTaskClass {
      * @param $is_promoter
      * @return string
      */
-    public static function generate_user_poster_filename($uid, $posterId, $is_promoter=true) : string
+    public static function generate_user_poster_filename($uid, $posterId, $is_promoter = true): string
     {
         return $uid . '_' . $is_promoter . '_' . $posterId . '_user_routine_poster.jpg';
     }
@@ -34,7 +36,7 @@ class UserTaskClass {
      * @param $is_promoter
      * @return string
      */
-    public static function generate_user_share_qrcode_filename($uid, $is_promoter=true) : string
+    public static function generate_user_share_qrcode_filename($uid, $is_promoter = true): string
     {
         return $uid . '_' . $is_promoter . '_user_routine.jpg';
     }
@@ -47,12 +49,12 @@ class UserTaskClass {
      * @param $type
      * @return array: [bool, str] : 表示是否成功,错误描述
      */
-    public static function generate_user_poster(int $uid, bool $siteSsl=true, int $type=1) : array
+    public static function generate_user_poster(int $uid, bool $siteSsl = true, int $type = 1): array
     {
         $rootPath = app()->getRootPath();
         try {
-            $resRoutine = true;//小程序
-            $resWap = true;//公众号
+            $resRoutine = true; //小程序
+            $resWap = true; //公众号
             $siteUrl = sys_config('site_url');
             // 配置的海报背景模板
             $routineSpreadBanner = sys_data('routine_spread_banner');
@@ -101,9 +103,11 @@ class UserTaskClass {
                 $imageInfo = SystemAttachment::getInfo($name, 'name');
                 //检测远程文件是否存在
                 // 20210722 注释掉,太卡
-                if (isset($imageInfo['att_dir']) && 
-                    strstr($imageInfo['att_dir'], 'http') !== false && 
-                    curl_file_exist($imageInfo['att_dir']) === false) {
+                if (
+                    isset($imageInfo['att_dir']) &&
+                    strstr($imageInfo['att_dir'], 'http') !== false &&
+                    curl_file_exist($imageInfo['att_dir']) === false
+                ) {
                     $imageInfo = null;
                     SystemAttachment::where(['name' => $name])->delete();
                 }
@@ -226,4 +230,4 @@ class UserTaskClass {
             return [false, '生成图片时,系统错误:' . $e->getMessage()];
         }
     }
-}
+}

+ 4 - 4
tw/async/tasks/WechatNotify.php

@@ -29,7 +29,7 @@ class WechatNotify extends Task
         ]);
     }
 
-    public function getCmd():string
+    public function getCmd(): string
     {
         return 'wechat';
     }
@@ -67,7 +67,7 @@ class WechatNotify extends Task
             . "> 描述:" . $desc;
         QyWeixinService::instance()->key($key)
             ->markdown($md)->post();
-            
+
         return true;
-    }//
-}
+    } //
+}

+ 2 - 2
tw/redis/ActivityPool.php

@@ -16,8 +16,8 @@ class ActivityPool extends Base
 {
     use HashTrait;
 
-    protected function key($whatever=false) : string
+    protected function key($whatever = false): string
     {
         return 'activity:pool';
     }
-}
+}

+ 3 - 3
tw/redis/Base.php

@@ -19,6 +19,6 @@ abstract class Base
      * 虚函数,返回键
      * @param integer|string $word: 组成键的关键部分
      * @return string
-     */ 
-    abstract protected function key($word=false) : string;
-}
+     */
+    abstract protected function key($word = false): string;
+}

+ 3 - 3
tw/redis/BoardRds.php

@@ -7,15 +7,15 @@ use tw\redis\traits\StringTrait;
 /**
  * 排行榜
  */
-class BoardRds extends Base 
+class BoardRds extends Base
 {
     use StringTrait;
 
     const DAILY = 1;
     const WEEKLY = 2;
 
-    protected function key($type=false) : string
+    protected function key($type = false): string
     {
         return 'tmp:board:' . $type;
     }
-}
+}

+ 2 - 2
tw/redis/ProductCategoryRds.php

@@ -8,8 +8,8 @@ class ProductCategoryRds extends Base
 {
     use HashTrait;
 
-    protected function key($cate_id=false) : string
+    protected function key($cate_id = false): string
     {
         return 'store:category:' . $cate_id;
     }
-}
+}

+ 3 - 3
tw/redis/ProductRds.php

@@ -4,12 +4,12 @@ namespace tw\redis;
 
 use tw\redis\traits\HashTrait;
 
-class ProductRds extends Base 
+class ProductRds extends Base
 {
     use HashTrait;
 
-    protected function key($pid=false) : string
+    protected function key($pid = false): string
     {
         return 'store:product:' . $pid;
     }
-}
+}

+ 5 - 4
tw/redis/TwRedis.php

@@ -1,4 +1,5 @@
 <?php
+
 namespace tw\redis;
 
 use think\facade\Config;
@@ -6,7 +7,8 @@ use think\facade\Config;
 /**
  * 另一个 Redis 客户端,另一个是 Cache 使用
  */
-class TwRedis {
+class TwRedis
+{
 
     protected static $inst;
 
@@ -28,7 +30,6 @@ class TwRedis {
             if (0 != $options['select']) {
                 $this->handle->select($options['select']);
             }
-            
         } else {
             throw new \BadFunctionCallException('not support: redis');
         }
@@ -36,7 +37,7 @@ class TwRedis {
 
     public static function instance()
     {
-        if ( is_null(self::$inst) ) {
+        if (is_null(self::$inst)) {
             $options = Config::get('redis', []);
             self::$inst = new static($options);
         }
@@ -47,4 +48,4 @@ class TwRedis {
     {
         return self::instance()->handle->{$name}(...$arguments);
     }
-}
+}

+ 2 - 2
tw/redis/UserRds.php

@@ -29,8 +29,8 @@ class UserRds extends Base
     const FIELD_LASTREFRESH = 'last_refresh';   // 上次登录刷新
 
 
-    protected function key($uid=false) : string
+    protected function key($uid = false): string
     {
         return 'user:' . $uid;
     }
-}
+}

+ 16 - 15
tw/redis/traits/HashTrait.php

@@ -1,4 +1,5 @@
 <?php
+
 namespace tw\redis\traits;
 
 use tw\redis\TwRedis;
@@ -7,7 +8,7 @@ use tw\redis\TwRedis;
  * 支持 redis hash key 操作的函数, 必须 use 到 Base 的子类中, 因为内部调用了 Base 的虚函数
  * 
  */
-trait HashTrait 
+trait HashTrait
 {
     /**
      * 获取 hash attr
@@ -16,12 +17,12 @@ trait HashTrait
      * @param string $attr
      * @return string
      */
-    public function get($word, string $attr) : string
+    public function get($word, string $attr): string
     {
         return TwRedis::hGet($this->key($word), $attr);
     }
 
-    public function gets($word, array $attrs) : array
+    public function gets($word, array $attrs): array
     {
         return TwRedis::hMGet($this->key($word), $attrs);
     }
@@ -29,7 +30,7 @@ trait HashTrait
     /**
      * set hash attr
      */
-    public function set($word, string $attr, $value) : bool
+    public function set($word, string $attr, $value): bool
     {
         return TwRedis::hSet($this->key($word), $attr, $value);
     }
@@ -40,7 +41,7 @@ trait HashTrait
      * @param array $attrs: ['attr1'=>'value1', 'attr2' => 'value2']
      * @return bool
      */
-    public function sets($word, array $attrs) : bool
+    public function sets($word, array $attrs): bool
     {
         return TwRedis::hMSet($this->key($word), $attrs);
     }
@@ -48,40 +49,40 @@ trait HashTrait
     /**
      * setup hash value if the attr not exists
      */
-    public function hsetnx($word, $attr, $val) : bool
+    public function hsetnx($word, $attr, $val): bool
     {
         return TwRedis::hSetNx($this->key($word), $attr, $val);
     }
-    
+
     /**
      * hash 的 attr 是否存在
      */
-    public function hexists($word, string $attr) : bool
+    public function hexists($word, string $attr): bool
     {
         return TwRedis::hExists($this->key($word), $attr);
     }
 
-    public function hincr_by($word, string $attr, int $step) : int
+    public function hincr_by($word, string $attr, int $step): int
     {
         return TwRedis::hIncrBy($this->key($word), $attr, $step);
     }
 
-    public function hincr_by_float($word, string $attr, float $f) : float
+    public function hincr_by_float($word, string $attr, float $f): float
     {
         return TwRedis::hIncrByFloat($this->key($word), $attr, $f);
     }
 
-    public function hkeys($word) : array
+    public function hkeys($word): array
     {
         return TwRedis::hKeys($this->key($word));
     }
 
-    public function hvals($word) : array
+    public function hvals($word): array
     {
         return TwRedis::hVals($this->key($word));
     }
 
-    public function dels($word, $attrs) : int
+    public function dels($word, $attrs): int
     {
         if (is_string($attrs)) {
             return TwRedis::hDel($this->key($word), $attrs);
@@ -90,8 +91,8 @@ trait HashTrait
         }
     }
 
-    public function getAll($word) : array
+    public function getAll($word): array
     {
         return TwRedis::hGetAll($this->key($word));
     }
-}
+}

+ 7 - 7
tw/redis/traits/KeyTrait.php

@@ -1,16 +1,17 @@
 <?php
+
 namespace tw\redis\traits;
 
 use tw\redis\TwRedis;
 
 trait KeyTrait
 {
-    public function keys(string $pattern) : array
+    public function keys(string $pattern): array
     {
         return TwRedis::keys($pattern);
     }
 
-    public function expire($word, int $secs) : bool
+    public function expire($word, int $secs): bool
     {
         return TwRedis::expire($this->key($word), $secs);
     }
@@ -18,12 +19,12 @@ trait KeyTrait
     /**
      * 设置超时时间戳,到达该时间戳后,key 失效
      */
-    public function expire_at($word, int $ts) : bool
+    public function expire_at($word, int $ts): bool
     {
         return TwRedis::expireAt($this->key($word), $ts);
     }
 
-    public function del($word) : int
+    public function del($word): int
     {
         return TwRedis::del($this->key($word));
     }
@@ -33,9 +34,8 @@ trait KeyTrait
         return TwRedis::type($this->key($word));
     }
 
-    public function exists($word) : int
+    public function exists($word): int
     {
         return TwRedis::exists($this->key($word));
     }
-
-}
+}

+ 14 - 13
tw/redis/traits/SortedSetTrait.php

@@ -1,10 +1,12 @@
 <?php
+
 namespace tw\redis\traits;
 
 use tw\redis\TwRedis;
 
-trait SortedSetTrait {
-    
+trait SortedSetTrait
+{
+
     /**
      * 添加/更新一个元素
      * 
@@ -12,7 +14,7 @@ trait SortedSetTrait {
      * @param float $score
      * @return int 0|1 1代表新增
      */
-    public function zadd($word, $val, $score) : int
+    public function zadd($word, $val, $score): int
     {
         return TwRedis::zAdd($this->key($word), $score, $val);
     }
@@ -20,14 +22,13 @@ trait SortedSetTrait {
     /**
      * 删除 1 个或多个元素
      */
-    public function zrem($word, $members) : int
+    public function zrem($word, $members): int
     {
         if (is_array($members)) {
             return TwRedis::zRem($this->key($word), ...$members);
         } else {
             return TwRedis::zRem($this->key($word), $members);
         }
-        
     }
 
     /**
@@ -47,7 +48,7 @@ trait SortedSetTrait {
      * @param string $member
      * @return float 名次
      */
-    public function zrank($word, $member) : float
+    public function zrank($word, $member): float
     {
         return TwRedis::zRank($this->key($word), $member);
     }
@@ -55,7 +56,7 @@ trait SortedSetTrait {
     /**
      * 求 zset 的基数
      */
-    public function zcard($word) : int
+    public function zcard($word): int
     {
         return TwRedis::zCard($this->key($word));
     }
@@ -66,7 +67,7 @@ trait SortedSetTrait {
      * @param float|string $start,$end: 也可以包括 +inf -inf 表示正负无穷
      * @return 
      */
-    public function zcount($word, $start, $end) : int
+    public function zcount($word, $start, $end): int
     {
         return TwRedis::zCount($this->key($word), $start, $end);
     }
@@ -74,7 +75,7 @@ trait SortedSetTrait {
     /**
      * 增加指定元素的分数
      */
-    public function zincr_by($word, $member, $by) : float
+    public function zincr_by($word, $member, $by): float
     {
         return TwRedis::zIncrBy($this->key($word), $by, $member);
     }
@@ -82,7 +83,7 @@ trait SortedSetTrait {
     /**
      * 弹出分数最大的几个
      */
-    public function zpop_max($word, $num) : array
+    public function zpop_max($word, $num): array
     {
         return TwRedis::zPopMax($this->key($word), $num);
     }
@@ -90,7 +91,7 @@ trait SortedSetTrait {
     /**
      * 弹出分数最小的几个
      */
-    public function zpop_min($word, $num) : array
+    public function zpop_min($word, $num): array
     {
         return TwRedis::zPopMin($this->key($word), $num);
     }
@@ -104,7 +105,7 @@ trait SortedSetTrait {
      * ['withscores' => TRUE, 'limit' => [1, 1]]
      * @return
      */
-    public function zrange_by_score($word, $start, $end, $options) : array
+    public function zrange_by_score($word, $start, $end, $options): array
     {
         return TwRedis::zRangeByScore($this->key($word), $start, $end, $options);
     }
@@ -118,4 +119,4 @@ trait SortedSetTrait {
     {
         return TwRedis::zRemRangeByScore($this->key($word), $start, $end);
     }
-}
+}

+ 2 - 1
tw/redis/traits/StringTrait.php

@@ -1,4 +1,5 @@
 <?php
+
 namespace tw\redis\traits;
 
 use tw\redis\TwRedis;
@@ -50,4 +51,4 @@ trait StringTrait
     {
         return TwRedis::decrBy($this->key($word), $step);
     }
-}
+}

+ 1 - 3
tw/services/auth/ThirdPartyLogin.php

@@ -14,11 +14,9 @@ class ThirdPartyLogin
 
     public static function auth_app_wx()
     {
-
     }
 
     public static function auth_mp_wx()
     {
-
     }
-}
+}

+ 2 - 1
tw/services/payment/Alipay.php

@@ -1,2 +1,3 @@
 <?php
-namespace tw\services;
+
+namespace tw\services;

+ 2 - 1
tw/services/payment/WechatPay.php

@@ -1,2 +1,3 @@
 <?php
-namespace tw\services;
+
+namespace tw\services;