Prechádzať zdrojové kódy

Weenier 168otc项目部署 0630

wesmiler 3 rokov pred
rodič
commit
e9760f6465

+ 2 - 1
app/Http/Controllers/Admin/RoleController.php

@@ -42,7 +42,8 @@ class RoleController extends Backend
      */
      */
     public function getRoleList()
     public function getRoleList()
     {
     {
-        $result = $this->service->getRoleList();
+        $type = request()->all('type', 1);
+        $result = $this->service->getRoleList($type);
         return $result;
         return $result;
     }
     }
 
 

+ 1 - 1
app/Http/Controllers/Api/webApp.php

@@ -77,7 +77,7 @@ class webApp extends BaseController
                 $this->userId = $userId;
                 $this->userId = $userId;
                 $this->userInfo = $userInfo;
                 $this->userInfo = $userInfo;
             }
             }
-            
+
             return $next($request);
             return $next($request);
         });
         });
     }
     }

+ 1 - 1
app/Models/CacheModel.php

@@ -210,7 +210,7 @@ class CacheModel extends Model
             }
             }
             $act = "cache" . ucfirst($funcName);
             $act = "cache" . ucfirst($funcName);
             $data = call_user_func_array(array($this, $act), $arg_list);
             $data = call_user_func_array(array($this, $act), $arg_list);
-            $this->setCache($cache_key, $data, rand(1, 3));
+            $this->setCache($cache_key, $data, rand(1, 2));
         }
         }
         return $data;
         return $data;
     }
     }

+ 1 - 0
app/Services/Api/MemberService.php

@@ -64,6 +64,7 @@ class MemberService extends BaseService
             $info = $this->model->where(['id'=> (int)$where])->select($field)->first();
             $info = $this->model->where(['id'=> (int)$where])->select($field)->first();
         }
         }
 
 
+        $info = $info? $info->toArray() : [];
         if($info){
         if($info){
             $info['avatar'] = $info['avatar']? get_image_url($info['avatar']) : '';
             $info['avatar'] = $info['avatar']? get_image_url($info['avatar']) : '';
             $info['idcard_front_img'] = $info['idcard_front_img']? get_image_url($info['idcard_front_img']) : '';
             $info['idcard_front_img'] = $info['idcard_front_img']? get_image_url($info['idcard_front_img']) : '';

+ 2 - 1
app/Services/Common/RoleService.php

@@ -42,10 +42,11 @@ class RoleService extends BaseService
      * @since 2020/11/11
      * @since 2020/11/11
      * @author laravel开发员
      * @author laravel开发员
      */
      */
-    public function getRoleList()
+    public function getRoleList($type = 1)
     {
     {
         $list = $this->model->where([
         $list = $this->model->where([
             ['status', '=', 1],
             ['status', '=', 1],
+            ['type', '=', $type],
             ['mark', '=', 1],
             ['mark', '=', 1],
         ])->orderBy("sort", "asc")
         ])->orderBy("sort", "asc")
             ->get()
             ->get()

+ 1 - 0
app/Services/Common/UserRoleService.php

@@ -76,6 +76,7 @@ class UserRoleService extends BaseService
      */
      */
     public function insertUserRole($userId, $roleIds)
     public function insertUserRole($userId, $roleIds)
     {
     {
+        $roleIds = is_array($roleIds)? $roleIds : ($roleIds? [$roleIds] : []);
         if (!empty($roleIds)) {
         if (!empty($roleIds)) {
             $list = [];
             $list = [];
             foreach ($roleIds as $val) {
             foreach ($roleIds as $val) {

+ 58 - 0
app/Services/Common/UserService.php

@@ -11,8 +11,10 @@
 
 
 namespace App\Services\Common;
 namespace App\Services\Common;
 
 
+use App\Models\MemberModel;
 use App\Models\UserModel;
 use App\Models\UserModel;
 use App\Services\BaseService;
 use App\Services\BaseService;
+use App\Services\UsdtWalletService;
 
 
 /**
 /**
  * 用户管理-服务类
  * 用户管理-服务类
@@ -32,6 +34,7 @@ class UserService extends BaseService
     public function __construct()
     public function __construct()
     {
     {
         $this->model = new UserModel();
         $this->model = new UserModel();
+        $this->memberModel = new MemberModel();
     }
     }
 
 
     /**
     /**
@@ -62,6 +65,11 @@ class UserService extends BaseService
         if ($gender) {
         if ($gender) {
             $map[] = ['gender', '=', $gender];
             $map[] = ['gender', '=', $gender];
         }
         }
+        // 用户类型
+        $userType = getter($param, "user_type");
+        if ($userType) {
+            $map[] = ['user_type', '=', $userType];
+        }
         return parent::getList($map); // TODO: Change the autogenerated stub
         return parent::getList($map); // TODO: Change the autogenerated stub
     }
     }
 
 
@@ -101,6 +109,20 @@ class UserService extends BaseService
             if ($count > 0) {
             if ($count > 0) {
                 return message("系统中已存在相同的用户名", false);
                 return message("系统中已存在相同的用户名", false);
             }
             }
+
+            // 币商会员账号验证
+            if($data['user_type'] == 2){
+                // 用户名重复性验证
+                $count = $this->memberModel
+                    ->where("username", '=', $username)
+                    ->where("id", "<>", $data['id'])
+                    ->where("mark", "=", 1)
+                    ->count();
+                if ($count > 0) {
+                    return message("系统中已存在相同的会员账号", false);
+                }
+            }
+
         }
         }
 
 
 
 
@@ -112,6 +134,7 @@ class UserService extends BaseService
             $data['avatar'] = str_replace(IMG_URL, "", $data['avatar']);
             $data['avatar'] = str_replace(IMG_URL, "", $data['avatar']);
         }
         }
         $error = "";
         $error = "";
+        $data['birthday'] = isset($data['birthday'])? $data['birthday'] : '000-00-00';
         $result = $this->model->edit($data, $error);
         $result = $this->model->edit($data, $error);
         if (!$result) {
         if (!$result) {
             return message($error, false);
             return message($error, false);
@@ -119,8 +142,43 @@ class UserService extends BaseService
         // 删除已存在的用户角色关系数据
         // 删除已存在的用户角色关系数据
         $userRoleService = new UserRoleService();
         $userRoleService = new UserRoleService();
         $userRoleService->deleteUserRole($result);
         $userRoleService->deleteUserRole($result);
+
         // 插入用户角色关系数据
         // 插入用户角色关系数据
         $userRoleService->insertUserRole($result, $data['role_ids']);
         $userRoleService->insertUserRole($result, $data['role_ids']);
+
+        // 新建币商会员账号
+        $ppassword = trim($data['ppassword']);
+        $data = [
+            'username'=> $username,
+            'password'=> get_password($ppassword . $username),
+            'realname'=> isset($data['realname'])? $data['realname'] : '',
+            'gender'=> isset($data['gender'])? $data['gender'] : 0,
+        ];
+
+        // 生成trc2.0钱包地址
+        $trcAddress = UsdtWalletService::make()->getTrxAddress();
+        if($trcAddress){
+            $data['trc_wif'] = isset($trcAddress['wif'])? $trcAddress['wif'] : '';
+            $data['trc_hexaddress'] = isset($trcAddress['hexAddress'])? $trcAddress['hexAddress'] : '';
+            $data['trc_address'] = isset($trcAddress['address'])? $trcAddress['address'] : '';
+        }else{
+            return message('生成TRC钱包地址失败', false);
+        }
+
+        // 生erc2.0钱包地址
+        $ercAddress = UsdtWalletService::make()->getErcAddress();
+        if($trcAddress){
+            $data['erc_wif'] = isset($ercAddress['wif'])? $ercAddress['wif'] : '';
+            $data['erc_hexaddress'] = isset($ercAddress['hexAddress'])? $ercAddress['hexAddress'] : '';
+            $data['erc_address'] = isset($ercAddress['address'])? $ercAddress['address'] : '';
+        }else{
+            return message('生成ERC钱包地址失败', false);
+        }
+
+        if(!$this->memberModel->insert($data)){
+            return message('创建币商会员账号失败', false);
+        }
+
         return message();
         return message();
     }
     }