Просмотр исходного кода

Weenier 168otc项目部署 0630

wesmiler 3 лет назад
Родитель
Сommit
0be799a8cd

+ 24 - 0
app/Helpers/common.php

@@ -1150,6 +1150,30 @@ if (!function_exists('message')) {
 }
 
 
+if (!function_exists('returnJson')) {
+
+    /**
+     * 消息数组
+     * @param string $msg 提示文字
+     * @param bool $success 是否成功true或false
+     * @param array $data 结果数据
+     * @param int $code 编码
+     * @return array 返回结果
+     * @author laravel开发员
+     * @date 2019/5/28
+     */
+    function returnJson($msg = "1002", $success = true, $data = [], $code = 0)
+    {
+        $result = ['success' => $success, 'msg' => lang($msg,[],'zh-cn'), 'data' => $data];
+        if ($success) {
+            $result['code'] = 0;
+        } else {
+            $result['code'] = $code ? $code : -1;
+        }
+        return $result;
+    }
+}
+
 if (!function_exists('num2rmb')) {
 
     /**

+ 3 - 3
app/Http/Controllers/Admin/AdvertController.php

@@ -78,13 +78,13 @@ class AdvertController extends Backend
         $params = request()->post();
         $params = $validate->check($params,'buy');
         if(!is_array($params)){
-            return message($params, false,[]);
+            return returnJson($params, false,[]);
         }
 
         if(!AdvertOrderService::make()->buy($this->userInfo['user_id'], $params)){
-            return message(AdvertOrderService::make()->getError(), false);
+            return returnJson(AdvertOrderService::make()->getError(), false);
         }else{
-            return message(AdvertOrderService::make()->getError(), true);
+            return returnJson(AdvertOrderService::make()->getError(), true);
         }
     }
 }

+ 3 - 3
app/Http/Controllers/Admin/CapitalController.php

@@ -61,13 +61,13 @@ class CapitalController extends Backend
         $params = request()->post();
         $params = $validate->check($params,'buy');
         if(!is_array($params)){
-            return message($params, false,[]);
+            return returnJson($params, false,[]);
         }
 
         if(!AdvertOrderService::make()->buy($this->userInfo['user_id'], $params)){
-            return message(AdvertOrderService::make()->getError(), false);
+            return returnJson(AdvertOrderService::make()->getError(), false);
         }else{
-            return message(AdvertOrderService::make()->getError(), true);
+            return returnJson(AdvertOrderService::make()->getError(), true);
         }
     }
 }

+ 6 - 6
app/Http/Controllers/Admin/CoinLogController.php

@@ -53,13 +53,13 @@ class CoinLogController extends Backend
         $params = request()->post();
         $params = $validate->check($params,'withdraw');
         if(!is_array($params)){
-            return message($params, false,[]);
+            return returnJson($params, false,[]);
         }
 
         if(!CoinLogService::make()->withdraw($this->userInfo['user_id'], $params)){
-            return message(CoinLogService::make()->getError(), false);
+            return returnJson(CoinLogService::make()->getError(), false);
         }else{
-            return message(CoinLogService::make()->getError(), true);
+            return returnJson(CoinLogService::make()->getError(), true);
         }
     }
 
@@ -72,13 +72,13 @@ class CoinLogController extends Backend
         $params = request()->post();
         $params = $validate->check($params,'confirm');
         if(!is_array($params)){
-            return message($params, false,[]);
+            return returnJson($params, false,[]);
         }
 
         if(!CoinLogService::make()->confirmWithdraw($this->userInfo['user_id'], $params)){
-            return message(CoinLogService::make()->getError(), false);
+            return returnJson(CoinLogService::make()->getError(), false);
         }else{
-            return message(CoinLogService::make()->getError(), true);
+            return returnJson(CoinLogService::make()->getError(), true);
         }
     }
 }

+ 9 - 9
app/Http/Controllers/Admin/IndexController.php

@@ -118,7 +118,7 @@ class IndexController extends Backend
         RedisService::keyDel("caches:article*");
         RedisService::keyDel("caches:qrcode*");
         RedisService::keyDel("laravel_cache:model*");
-        return message(MESSAGE_OK, true);
+        return returnJson(MESSAGE_OK, true);
     }
 
     /**
@@ -133,7 +133,7 @@ class IndexController extends Backend
         $userId = isset($info['user_id'])? $info['user_id'] : 0;
         $userInfo = MemberService::make()->getInfo($userId);
         if($userId<=0 || empty($userInfo)){
-            return message(MESSAGE_FAILED, false);
+            return returnJson(MESSAGE_FAILED, false);
         }
 
         // 用户交易设置参数
@@ -155,7 +155,7 @@ class IndexController extends Backend
             'setting'=> $setting
         ];
 
-        return message(MESSAGE_OK, true, $datas);
+        return returnJson(MESSAGE_OK, true, $datas);
     }
 
     /**
@@ -170,13 +170,13 @@ class IndexController extends Backend
         $userId = isset($info['user_id'])? $info['user_id'] : 0;
         $userInfo = MemberService::make()->getInfo($userId);
         if($userId<=0 || empty($userInfo)){
-            return message(MESSAGE_FAILED, false);
+            return returnJson(MESSAGE_FAILED, false);
         }
 
         // 用户交易设置参数
         $setting = MemberSettingService::make()->getInfo($userId);
 
-        return message(MESSAGE_OK, true, $setting);
+        return returnJson(MESSAGE_OK, true, $setting);
     }
 
     /**
@@ -189,7 +189,7 @@ class IndexController extends Backend
         $data1 = ConfigService::make()->getConfigOptionTextByGroup(6);
         $data['coin_in_tips'] = isset($data1['coin_in_tips'])? $data1['coin_in_tips'] : '';
         $data['coin_out_tips'] = isset($data1['coin_out_tips'])? $data1['coin_out_tips'] : '';
-        return message(MESSAGE_OK, true, $data);
+        return returnJson(MESSAGE_OK, true, $data);
     }
 
 
@@ -220,7 +220,7 @@ class IndexController extends Backend
             $data['wallet']['erc_out_usdt'] = UsdtWalletService::make()->getErc20Usdt($data['erc_out_address']);
         }
 
-        return message(MESSAGE_OK, true, $data);
+        return returnJson(MESSAGE_OK, true, $data);
     }
 
     /**
@@ -234,7 +234,7 @@ class IndexController extends Backend
         $address = request()->post('address', 1);
         $limit = request()->post('limit', 15);
         if(empty($address)){
-            return message(MESSAGE_OK, false);
+            return returnJson(MESSAGE_OK, false);
         }
 
         // trc
@@ -243,6 +243,6 @@ class IndexController extends Backend
         }else {
             $datas = UsdtWalletService::make()->getErc20TransferLog($address,$type, $limit);
         }
-        return message(MESSAGE_OK, true, is_array($datas)? $datas : []);
+        return returnJson(MESSAGE_OK, true, is_array($datas)? $datas : []);
     }
 }

+ 1 - 1
app/Http/Controllers/Admin/MemberController.php

@@ -37,6 +37,6 @@ class MemberController extends Backend
     public function info()
     {
         $info = MemberService::make()->getInfo($this->userInfo['user_id']);
-        return message(1002, true, $info);
+        return returnJson(1002, true, $info);
     }
 }

+ 4 - 4
app/Http/Controllers/Admin/SettingController.php

@@ -44,9 +44,9 @@ class SettingController extends Backend
    {
         $params = request()->all();
         if(MemberSettingService::make()->saveData($this->userInfo['user_id'], $params)){
-            return message(MESSAGE_OK, true);
+            return returnJson(MESSAGE_OK, true);
         }else{
-            return message(MESSAGE_OK, true);
+            return returnJson(MESSAGE_OK, true);
         }
    }
 
@@ -62,7 +62,7 @@ class SettingController extends Backend
         $userId = isset($info['user_id'])? $info['user_id'] : 0;
         $userInfo = MemberService::make()->getInfo($userId);
         if($userId<=0 || empty($userInfo)){
-            return message(MESSAGE_FAILED, false);
+            return returnJson(MESSAGE_FAILED, false);
         }
 
         // 用户交易设置参数
@@ -72,7 +72,7 @@ class SettingController extends Backend
             'trade'=> ConfigService::make()->getConfigOptionByGroup(5)
         ];
 
-        return message(MESSAGE_OK, true, $datas);
+        return returnJson(MESSAGE_OK, true, $datas);
     }
 
 }

+ 11 - 11
app/Http/Controllers/Admin/TradeOrderController.php

@@ -77,7 +77,7 @@ class TradeOrderController extends Backend
         $params = request()->post();
         $params['business_id'] = $this->userInfo['user_id'];
         $info = TradeOrderService::make()->getWaitOrder($params);
-        return message(1002, true, $info);
+       return returnJson(1002, true, $info);
     }
 
     /**
@@ -88,9 +88,9 @@ class TradeOrderController extends Backend
     {
         $params = request()->post();
         if(!TradeOrderService::make()->businessPay($this->userInfo['user_id'], $params)){
-            return message(TradeOrderService::make()->getError(), false);
+           return returnJson(TradeOrderService::make()->getError(), false);
         }else{
-            return message(TradeOrderService::make()->getError(), true);
+           return returnJson(TradeOrderService::make()->getError(), true);
         }
     }
 
@@ -109,9 +109,9 @@ class TradeOrderController extends Backend
             $businessId = 0;
         }
         if(!TradeOrderService::make()->businessCollection($businessId, $params)){
-            return message(TradeOrderService::make()->getError(), false);
+           return returnJson(TradeOrderService::make()->getError(), false);
         }else{
-            return message(TradeOrderService::make()->getError(), true);
+           return returnJson(TradeOrderService::make()->getError(), true);
         }
     }
 
@@ -126,7 +126,7 @@ class TradeOrderController extends Backend
         $userId = request()->post('userId',0);
         $num = request()->post('num',0);
         $datas = MemberService::make()->getTradeMemberOptions($num, $tradeType, $userId, $keyword);
-        return message(1002, true, $datas);
+       return returnJson(1002, true, $datas);
     }
 
     /**
@@ -137,15 +137,15 @@ class TradeOrderController extends Backend
         $params = request()->post();
         $params = $validate->check($params,'info');
         if(!is_array($params)){
-            return message($params, false,[]);
+            return returnJson($params, false,[]);
         }
 
         $id = request()->post('id',0);
         $businessId = request()->post('business_id',0);
         if(!TradeOrderService::make()->reassign($id, $businessId)){
-            return message(TradeOrderService::make()->getError(), false);
+            return returnJson(TradeOrderService::make()->getError(), false);
         }else{
-            return message(TradeOrderService::make()->getError(), true);
+            return returnJson(TradeOrderService::make()->getError(), true);
         }
     }
 
@@ -163,9 +163,9 @@ class TradeOrderController extends Backend
             $businessId = 0;
         }
         if(!TradeOrderService::make()->businessCancel($businessId,$params)){
-            return message(TradeOrderService::make()->getError(), false);
+           return returnJson(TradeOrderService::make()->getError(), false);
         }else{
-            return message(TradeOrderService::make()->getError(), true);
+           return returnJson(TradeOrderService::make()->getError(), true);
         }
     }
 

+ 6 - 6
app/Http/Controllers/Admin/UploadController.php

@@ -35,13 +35,13 @@ class UploadController extends Backend
         // 上传单图统一调取方法
         $result = upload_image($request, 'file');
         if (!$result['success']) {
-            return message($result['message'], false);
+            return returnJson($result['message'], false);
         }
 
         // 文件路径
         $file_path = $result['data']['img_path'];
         if (!$file_path) {
-            return message("文件上传失败", false);
+            return returnJson("文件上传失败", false);
         }
 
         // 网络域名拼接
@@ -50,7 +50,7 @@ class UploadController extends Backend
         }
 
         // 返回结果
-        return message(MESSAGE_OK, true, $file_path);
+        return returnJson(MESSAGE_OK, true, $file_path);
     }
 
     /**
@@ -63,12 +63,12 @@ class UploadController extends Backend
     {
         $result = upload_file($request);
         if (!$result['success']) {
-            $this->jsonReturn(MESSAGE_FAILED, false, $result['message']);
+            return returnJson(MESSAGE_FAILED, false, $result['message']);
         }
         // 文件路径
         $file_path = $result['data']['file_path'];
         if (!$file_path) {
-            $this->jsonReturn(message("文件上传失败"));
+            return returnJson("文件上传失败");
         }
 
         // 网络域名拼接
@@ -77,7 +77,7 @@ class UploadController extends Backend
         }
 
         // 返回结果
-        $this->jsonReturn(MESSAGE_OK, true, $file_path);
+        return returnJson(MESSAGE_OK, true, $file_path);
     }
 
 }

+ 38 - 38
app/Services/Common/UserService.php

@@ -102,7 +102,7 @@ class UserService extends BaseService
                 ->where("mark", "=", 1)
                 ->count();
             if ($count > 0) {
-                return message("系统中已存在相同的用户名", false);
+                return returnJson("系统中已存在相同的用户名", false);
             }
         } else {
             if($password){
@@ -115,7 +115,7 @@ class UserService extends BaseService
                 ->where("mark", "=", 1)
                 ->count();
             if ($count > 0) {
-                return message("系统中已存在相同的用户名", false);
+                return returnJson("系统中已存在相同的用户名", false);
             }
 
             // 币商会员账号验证
@@ -127,7 +127,7 @@ class UserService extends BaseService
                     ->where("mark", "=", 1)
                     ->count();
                 if ($count > 0) {
-                    return message("系统中已存在相同的会员账号", false);
+                    return returnJson("系统中已存在相同的会员账号", false);
                 }
             }
 
@@ -157,7 +157,7 @@ class UserService extends BaseService
         $result = $this->model->edit($data, $error);
         if (!$result) {
             $this->model->rollBack();
-            return message($error, false);
+            return returnJson($error, false);
         }
         // 删除已存在的用户角色关系数据
         $userRoleService = new UserRoleService();
@@ -189,7 +189,7 @@ class UserService extends BaseService
                 $data['trc_address'] = isset($trcAddress['address'])? $trcAddress['address'] : '';
             }else{
                 $this->model->rollBack();
-                return message('生成TRC钱包地址失败', false);
+                return returnJson('生成TRC钱包地址失败', false);
             }
 
             // 生erc2.0钱包地址
@@ -200,7 +200,7 @@ class UserService extends BaseService
                 $data['erc_address'] = isset($ercAddress['address'])? $ercAddress['address'] : '';
             }else{
                 $this->model->rollBack();
-                return message('生成ERC钱包地址失败', false);
+                return returnJson('生成ERC钱包地址失败', false);
             }
         }
 
@@ -208,14 +208,14 @@ class UserService extends BaseService
         if($info){
             if(!$this->memberModel->where(['id'=> $userId])->update($data)){
                 $this->model->rollBack();
-                return message('修改交易员信息失败', false);
+                return returnJson('修改交易员信息失败', false);
             }
             $this->model->commit();
             $this->model->where(['id'=> $adminId])->update(['user_id'=> $userId]);
         }else{
             if(!$userId = $this->memberModel->edit($data)){
                 $this->model->rollBack();
-                return message($userId? '修改交易员信息失败':'创建交易员账号失败', false);
+                return returnJson($userId? '修改交易员信息失败':'创建交易员账号失败', false);
             }
 
             $this->model->commit();
@@ -228,7 +228,7 @@ class UserService extends BaseService
         }
 
 
-        return message();
+        return returnJson();
     }
 
     /**
@@ -247,7 +247,7 @@ class UserService extends BaseService
         $menuService = new MenuService();
         $permissionList = $menuService->getPermissionsList($userId);
         $userInfo['permissionList'] = $permissionList;
-        return message("操作成功", true, $userInfo);
+        return returnJson("操作成功", true, $userInfo);
     }
 
     /**
@@ -288,9 +288,9 @@ class UserService extends BaseService
         }
         $result = $this->model->edit($data);
         if (!$result) {
-            return message("更新资料信息失败", false);
+            return returnJson("更新资料信息失败", false);
         }
-        return message("更新资料信息成功");
+        return returnJson("更新资料信息成功");
     }
 
     /**
@@ -307,27 +307,27 @@ class UserService extends BaseService
         // 原始密码
         $oldPassword = trim(getter($param, "oldPassword"));
         if (!$oldPassword) {
-            return message("旧密码不能为空", false);
+            return returnJson("旧密码不能为空", false);
         }
         // 新密码
         $newPassword = trim(getter($param, "newPassword"));
         if (!$newPassword) {
-            return message("新密码不能为空", false);
+            return returnJson("新密码不能为空", false);
         }
         $userInfo = $this->model->getInfo($userId);
         if (!$userInfo) {
-            return message("用户信息不存在", false);
+            return returnJson("用户信息不存在", false);
         }
         if ($userInfo['password'] != get_password($oldPassword . md5($oldPassword.'otc'))) {
-            return message("旧密码输入不正确", false);
+            return returnJson("旧密码输入不正确", false);
         }
         // 设置新密码
         $userInfo['password'] = get_password($newPassword . md5($newPassword.'otc'));
         $result = $this->model->edit($userInfo);
         if (!$result) {
-            return message("修改失败", false);
+            return returnJson("修改失败", false);
         }
-        return message("修改成功");
+        return returnJson("修改成功");
     }
 
     /**
@@ -345,28 +345,28 @@ class UserService extends BaseService
         // 原始密码
         $loginPassword = trim(getter($param, "loginPassword"));
         if (!$loginPassword) {
-            return message("登录密码不能为空", false);
+            return returnJson("登录密码不能为空", false);
         }
         // 新密码
         $newPassword = trim(getter($param, "newPassword"));
         if (!$newPassword) {
-            return message("新密码不能为空", false);
+            return returnJson("新密码不能为空", false);
         }
         $userInfo = $this->model->getInfo($adminId);
         $memberInfo = MemberService::make()->getInfo($userId);
         if (!$userInfo || empty($memberInfo)) {
-            return message("用户信息不存在", false);
+            return returnJson("用户信息不存在", false);
         }
         if ($userInfo['password'] != get_password($loginPassword . md5($loginPassword.'otc'))) {
-            return message("登录密码输入不正确", false);
+            return returnJson("登录密码输入不正确", false);
         }
         // 设置新密码
         $password = get_password($newPassword . md5($newPassword.'otc'));
         $result = $this->memberModel->where(['id'=> $userId])->update(['trade_password'=> $password]);
         if (!$result) {
-            return message("交易密码更新设置失败", false);
+            return returnJson("交易密码更新设置失败", false);
         }
-        return message("交易密码更新设置成功");
+        return returnJson("交易密码更新设置成功");
     }
 
     /**
@@ -382,42 +382,42 @@ class UserService extends BaseService
         $code = trim(getter($param, "code"));
         $username = trim(getter($param, "username"));
         if(empty($username)){
-            return message("账号参数错误", false);
+            return returnJson("账号参数错误", false);
         }
         if (!$code) {
-            return message("验证码不能为空", false);
+            return returnJson("验证码不能为空", false);
         }
 
         // 验证码
         $validator = new MemberValidator();
         if(!is_array($validator->check(['mobile'=> $username],'mobile'))){
             if(!EmailService::make()->check($username, $code, 'google')){
-                return message(EmailService::make()->getError(), false);
+                return returnJson(EmailService::make()->getError(), false);
             }
         }else{
             if(!SmsService::make()->check($username, $code, 'google')){
-                return message(SmsService::make()->getError(), false);
+                return returnJson(SmsService::make()->getError(), false);
             }
         }
 
         //
         $googleCode = trim(getter($param, "google_code"));
         if (!$googleCode) {
-            return message("谷歌验证码不能为空", false);
+            return returnJson("谷歌验证码不能为空", false);
         }
         $userInfo = $this->model->getInfo($userId);
         if (!$userInfo) {
-            return message("用户信息不存在", false);
+            return returnJson("用户信息不存在", false);
         }
 
         // 谷歌验证码
         $googleSecret = isset($userInfo['google_secret'])? $userInfo['google_secret'] : '';
         if(empty($googleSecret)){
-            return message("您尚未绑定谷歌验证码", false);
+            return returnJson("您尚未绑定谷歌验证码", false);
         }
 
         if (!GoogleAuthenticator::CheckCode($googleSecret, $googleCode)) {
-            return message("谷歌验证码错误", false);
+            return returnJson("谷歌验证码错误", false);
         }
 
         // 设置新谷歌验证码
@@ -427,9 +427,9 @@ class UserService extends BaseService
         $googleLimitTime = $googleLimitTime>0? $googleLimitTime : 1;
         $result = $this->model->where(['id'=> $userId])->update(['google_secret'=> $googleSecret,'google_verify_time'=> time() + $googleLimitTime*3600]);
         if (!$result) {
-            return message("谷歌验证码更新设置失败", false);
+            return returnJson("谷歌验证码更新设置失败", false);
         }
-        return message("谷歌验证码更新设置成功");
+        return returnJson("谷歌验证码更新设置成功");
     }
 
     /**
@@ -445,19 +445,19 @@ class UserService extends BaseService
         // 用户ID
         $userId = getter($param, "id");
         if (!$userId) {
-            return message("用户ID不能为空", false);
+            return returnJson("用户ID不能为空", false);
         }
         $userInfo = $this->model->getInfo($userId);
         if (!$userInfo) {
-            return message("用户信息不存在", false);
+            return returnJson("用户信息不存在", false);
         }
         // 设置新密码
         $userInfo['password'] = get_password("123456" . md5('123456'.'otc'));
         $result = $this->model->edit($userInfo);
         if (!$result) {
-            return message("重置密码失败", false);
+            return returnJson("重置密码失败", false);
         }
-        return message("重置密码成功");
+        return returnJson("重置密码成功");
     }
 
 }