Browse Source

钱包bug

lizhen_gitee 2 ngày trước cách đây
mục cha
commit
aad8f86640
1 tập tin đã thay đổi với 6 bổ sung7 xóa
  1. 6 7
      application/common/business/ShopWalletBusiness.php

+ 6 - 7
application/common/business/ShopWalletBusiness.php

@@ -48,11 +48,10 @@ class ShopWalletBusiness extends BusinessResult
         'money' => '余额',
     ];
 
-    protected int    $userId    = 0;
-    protected string $tableName = '';
+    protected string $walletName = '';
 
-    public function __construct($tableName) {
-        $this->tableName = $tableName;
+    public function __construct($orderName) {
+        $this->walletName = self::WALLET_TABLE[$orderName];
     }
 
     //获取钱包名称
@@ -94,7 +93,7 @@ class ShopWalletBusiness extends BusinessResult
         }
 
         //检测
-        if (!$wallet = Db::name($this->tableName)->lock(true)->where(['shop_id' => $shop_id])->find()) {
+        if (!$wallet = Db::name($this->walletName)->lock(true)->where(['shop_id' => $shop_id])->find()) {
             return $this->error('不存在的用户');
         }
 
@@ -116,11 +115,11 @@ class ShopWalletBusiness extends BusinessResult
             'updatetime'   => time(),
         ];
         //新的方式
-        $upWallet = Db::name($this->tableName)->where(['shop_id' => $shop_id])->update([$accountType => $data['remain']]);
+        $upWallet = Db::name($this->walletName)->where(['shop_id' => $shop_id])->update([$accountType => $data['remain']]);
         if ($upWallet === false) {
             return $this->error("更新账户余额失败!");
         }
-        $logTableName = self::LOG_TABLE[$this->tableName];
+        $logTableName = self::LOG_TABLE[$this->walletName];
         if (!Db::name($logTableName)->insertGetId($data)) {
             return $this->error("更新财务记录失败!");
         }