Procházet zdrojové kódy

全局改写:setInc->myInc setDec->myDec

萤火科技 před 1 rokem
rodič
revize
2e4072bb3f

+ 1 - 1
app/api/model/Article.php

@@ -70,7 +70,7 @@ class Article extends ArticleModel
      */
     private static function setIncActualViews(int $articleId): void
     {
-        (new static)->setInc($articleId, 'actual_views', 1);
+        (new static)->myInc($articleId, 'actual_views', 1);
     }
 
     /**

+ 1 - 1
app/common/model/Coupon.php

@@ -161,6 +161,6 @@ class Coupon extends BaseModel
      */
     public static function setIncReceiveNum(int $couponId)
     {
-        return (new static)->setInc($couponId, 'receive_num', 1);
+        return (new static)->myInc($couponId, 'receive_num', 1);
     }
 }

+ 6 - 6
app/common/model/User.php

@@ -107,7 +107,7 @@ class User extends BaseModel
      */
     public static function setIncUserExpend(int $userId, float $expendMoney)
     {
-        return (new static)->setInc($userId, 'expend_money', $expendMoney);
+        return (new static)->myInc($userId, 'expend_money', $expendMoney);
     }
 
     /**
@@ -118,7 +118,7 @@ class User extends BaseModel
      */
     public static function setIncBalance(int $userId, float $money)
     {
-        return (new static)->setInc($userId, 'balance', $money);
+        return (new static)->myInc($userId, 'balance', $money);
     }
 
     /**
@@ -129,7 +129,7 @@ class User extends BaseModel
      */
     public static function setDecBalance(int $userId, float $money)
     {
-        return (new static)->setDec([['user_id', '=', $userId]], 'balance', $money);
+        return (new static)->myDec([['user_id', '=', $userId]], 'balance', $money);
     }
 
     /**
@@ -166,7 +166,7 @@ class User extends BaseModel
      */
     public static function setIncPayMoney(int $userId, float $money)
     {
-        return (new static)->setInc($userId, 'pay_money', $money);
+        return (new static)->myInc($userId, 'pay_money', $money);
     }
 
     /**
@@ -190,7 +190,7 @@ class User extends BaseModel
     public function onBatchIncPoints(array $data): bool
     {
         foreach ($data as $userId => $value) {
-            $this->setInc($userId, 'points', $value);
+            $this->myInc($userId, 'points', $value);
         }
         return true;
     }
@@ -213,6 +213,6 @@ class User extends BaseModel
             'store_id' => $storeId ?: static::$storeId
         ]);
         // 更新用户可用积分
-        return (new static)->setInc($userId, 'points', $points);
+        return (new static)->myInc($userId, 'points', $points);
     }
 }

+ 2 - 2
app/store/model/User.php

@@ -214,7 +214,7 @@ class User extends UserModel
         // 更新记录
         $this->transaction(function () use ($storeUserName, $data, $diffMoney) {
             // 更新账户积分
-            $this->setInc($this['user_id'], 'points', $diffMoney);
+            $this->myInc($this['user_id'], 'points', $diffMoney);
             // 新增积分变动记录
             PointsLogModel::add([
                 'user_id' => $this['user_id'],
@@ -260,6 +260,6 @@ class User extends UserModel
      */
     public function setDecUserExpend(int $userId, float $expendMoney)
     {
-        return $this->setDec(['user_id' => $userId], 'expend_money', $expendMoney);
+        return $this->myDec(['user_id' => $userId], 'expend_money', $expendMoney);
     }
 }

+ 2 - 2
cores/BaseModel.php

@@ -203,7 +203,7 @@ abstract class BaseModel extends Model
      * @param float $step
      * @return mixed
      */
-    protected function setInc($where, string $field, float $step = 1)
+    protected function myInc($where, string $field, float $step = 1)
     {
         if (is_numeric($where)) {
             $where = [$this->getPk() => (int)$where];
@@ -218,7 +218,7 @@ abstract class BaseModel extends Model
      * @param float $step
      * @return mixed
      */
-    protected function setDec($where, string $field, float $step = 1)
+    protected function myDec($where, string $field, float $step = 1)
     {
         if (is_numeric($where)) {
             $where = [$this->getPk() => (int)$where];