Browse Source

teac转账

afa 4 months ago
parent
commit
2dc13888c2
2 changed files with 5 additions and 13 deletions
  1. 4 9
      application/api/controller/Ledger.php
  2. 1 4
      application/config.php

+ 4 - 9
application/api/controller/Ledger.php

@@ -118,7 +118,6 @@ class Ledger extends Api
     {
         $amount = $this->request->post('amount'); // 茶宝
         $account= $this->request->post('account', ''); // 账号
-        $type    = (strlen($account) > 11)? 0: 1;    // type: 0地址 1uid
         if(empty($amount) || empty($account)){
             $this->error(__('Parameter error'));
         }
@@ -127,7 +126,7 @@ class Ledger extends Api
         Db::startTrans();
         try {
 
-            $user = (empty($type))? $userModel->getByAddress($account): $userModel->getById($account); 
+            $user = (substr($account, 0, 2) == '0x')? $userModel->getByAddress($account): $userModel->getByUid($account); 
             if(empty($user)) throw new Exception(__("赠送用户不存在"));    
             if($user['id'] == $this->auth->id) throw new Exception(__("赠送用户不能是自己"));
 
@@ -169,8 +168,7 @@ class Ledger extends Api
     public function chabaoGift(UserModel $userModel,  LedgerWalletModel $ledgerWalletModel)
     {
         $amount = $this->request->post('amount'); // 茶宝
-        $account= $this->request->post('account', ''); // 账号
-        $type    = (strlen($account) > 11)? 0: 1;    // type: 0地址 1uid
+        $account= $this->request->post('account', ''); // 账号 
         if(empty($amount) || empty($account)){
             $this->error(__('Parameter error'));
         }
@@ -178,8 +176,7 @@ class Ledger extends Api
         // 启动事务
         Db::startTrans();
         try {
-
-            $user = (empty($type))? $userModel->getByAddress($account): $userModel->getById($account); 
+            $user = (substr($account, 0, 2) == '0x')? $userModel->getByAddress($account): $userModel->getByUid($account); 
             if(empty($user)) throw new Exception(__("赠送用户不存在"));    
             if($user['id'] == $this->auth->id) throw new Exception(__("赠送用户不能是自己"));  
             $chabao = $ledgerWalletModel::getWalletChaBao($this->auth->id);
@@ -207,7 +204,6 @@ class Ledger extends Api
     {
         $amount = $this->request->post('amount'); // 茶宝
         $account= $this->request->post('account', ''); // 账号
-        $type    = (strlen($account) > 11)? 0: 1;    // type: 0地址 1uid
         if(empty($amount) || empty($account)){
             $this->error(__('Parameter error'));
         }
@@ -215,8 +211,7 @@ class Ledger extends Api
         // 启动事务
         Db::startTrans();
         try {
-
-            $user = (empty($type))? $userModel->getByAddress($account): $userModel->getById($account); 
+            $user = (substr($account, 0, 2) == '0x')? $userModel->getByAddress($account): $userModel->getByUid($account); 
             if(empty($user)) throw new Exception(__("赠送用户不存在"));    
             if($user['id'] == $this->auth->id) throw new Exception(__("赠送用户不能是自己"));  
             $chabao = $ledgerWalletModel::getWalletChaBao($this->auth->id);

+ 1 - 4
application/config.php

@@ -365,10 +365,7 @@ return [
     ],
     //teac转账
     'teac_giveaway' => 0.01, //转账手续费
-    'teac_giveaway_txt' => [
-        0 => "1.请务必核实接收方的地址,转账操作一旦完成不可撤回。",
-        1 => "2.转账收取 1% 网络费,对方将收到你转账数额的 99%。"
-    ],
+    'teac_giveaway_txt' => "1.请务必核实接收方的地址,转账操作一旦完成不可撤回。</br>\r\n2.转账收取 1% 网络费,对方将收到你转账数额的 99%。",
     //生态节点推广
     'ecology' => [
         'product_id'    => [17],//购买指定产品