afa 11 сар өмнө
parent
commit
cb96c2e9d9

+ 18 - 26
application/api/controller/User.php

@@ -31,7 +31,6 @@ class User extends Api
     {
         parent::_initialize();
         $this->lan = $this->request->getLan();
-       
     }
 
     /**
@@ -106,7 +105,7 @@ class User extends Api
         } catch (Exception $e) {
             // 回滚事务
             Db::rollback();
-            $this->error('提交失败:' . $e->getMessage());
+            $this->error($e->getMessage());
         }
 
         $this->success('',  $list);
@@ -129,38 +128,31 @@ class User extends Api
                     ->paginate($this->pageSize);
         $this->success('', $list);
     }
+
     /**
-     * 报单算力互转信息
+     * 修改个人信息
      * @return void
      */
-    public function declarationInfo()
+    public function setUserInfo(UserModel $userModel)
     {
-        $user = $this->auth->getUser();
-        if (empty($user)) {
-            $this->error('用户信息不存在');
-        }
-
-        $resp = [
-            'declaration_min_amount'     => 10, // 最低互转数量
-            'tips'           => "", //提现提示信息
-        ];
-
-        $wallet = (new LedgerWalletModel())->getWallet($user['id']);
-        if (!empty($wallet)) {
-            $resp['declaration'] = $wallet['declaration'];
-        }
-
-        $config = (new ParametersModel)
-            ->where('name', '=', 'declarationMinAmount')
-            ->find();
-        if(empty($config)){
-            $this->error('报单算力互转最低数量参数');
+        // 启动事务
+        Db::startTrans();
+        try {
+            $param = $this->request->post();
+            if(!isset($param['name']) && !isset($param['nickname']) && !isset($param['phone'])) throw new Exception(__("Invalid parameters"));
+            $resp = $userModel::where('id', $this->auth->id)->update($param);
+            // 提交事务
+            Db::commit();
+        } catch (Exception $e) {
+            // 回滚事务
+            Db::rollback();
+            $this->error( $e->getMessage());
         }
-        $resp['declaration_min_amount'] = $config['value'];
-        $resp['tips'] = $config['tip'];
         $this->success('', $resp);
     }
 
+
+
     /**
      * 报单算力互转
      * @return void