Browse Source

酒店餐厅活动线下混合支付

Panda 2 weeks ago
parent
commit
9619f6b363
2 changed files with 13 additions and 30 deletions
  1. 2 2
      application/common/business/PaymentBusiness.php
  2. 11 28
      application/common/model/Wallet.php

+ 2 - 2
application/common/business/PaymentBusiness.php

@@ -59,7 +59,7 @@ class PaymentBusiness extends BusinessResult
                 break;
         }
 
-        if (!$model->where('id', $bill_id)->update($update)){
+        if (!$model->where('order_no', $bill_order_no)->update($update)){
             return $this->error('订单支付失败');
         }
         if (!Db::name($bill['table_name'])->where('id', $bill['table_id'])->update(['is_pay'=>1,'pay_time'=>time()])){
@@ -80,7 +80,7 @@ class PaymentBusiness extends BusinessResult
         $this->userId    = $userId;
         $this->orderNo   = $orderNo;
         $this->tableName = $tableName;
-        if (!$this->{$tableName}) {
+        if (!$this->$tableName()) {
             return $this->error($this->getMessage(), $this->getData());
         }
         return $this->success($this->getMessage(), $this->getData());

+ 11 - 28
application/common/model/Wallet.php

@@ -87,9 +87,18 @@ class Wallet extends BaseModel
         }
     }
 
-    public function getWallet($user_id = 0, $wallet_name = 'money')
+    public function getWallet($user_id = 0, $wallet_name = '')
     {
-        return Db::name('user')->where('id',$user_id)->value($wallet_name);
+        //所有钱包余额
+        if (!$wallet = Db::name('user_wallet')->where(['user_id' => $user_id])->find()) {
+            abort(500, '钱包余额获取失败');
+        }
+
+        if ($wallet_name) { //返回指定钱包
+            return isset($wallet[$wallet_name]) ? $wallet[$wallet_name] : 0;
+        } else { //返回所有钱包
+            return $wallet;
+        }
     }
 
 
@@ -261,30 +270,4 @@ class Wallet extends BaseModel
 
         return $this->success("账户余额已更新!");
     }
-
-    protected function success($message = '', $data = [])
-    {
-        $this->message = $message;
-        $this->data    = $data;
-        return true;
-    }
-
-    protected function error($message = '', $data = [])
-    {
-        $this->message = $message;
-        $this->data    = $data;
-        return false;
-    }
-
-    public function getMessage()
-    {
-        return $this->message;
-    }
-
-    public function getData($name = null)
-    {
-        $data = $this->data;
-        !empty($name) && $data = $this->data[$name];
-        return $data;
-    }
 }