diff --git a/app/admin/controller/Index.php b/app/admin/controller/Index.php index 26c169b0..10e2caf2 100644 --- a/app/admin/controller/Index.php +++ b/app/admin/controller/Index.php @@ -241,6 +241,170 @@ class Index extends AdminBaseController } } + // 分页统计每日注册用户 + public function dailyUserRegistration() + { + try { + $param = $this->request->post(); + if (empty($param['page']) || empty($param['limit'])) { + return json(['code' => '500', 'message' => '缺少参数', 'data' => []]); + } + + // 获取当登录账号信息 + $adminId = $this->request->user_id; + $account = AdminModel::where('id', $adminId)->find(); + if (empty($account)) { + return json(['code' => '500', 'message' => '当前账号数据为空', 'data' => []]); + } + // 查询当前账号的角色信息 + $role = AuthRoleModel::where(['id'=>$account->role_id])->find(); + if (empty($role)) { + return json(['code' => '500', 'message' => '当前账号分配的角色数据为空', 'data' => []]); + } + switch ($role->name) { + case AuthRoleModel::NAME_ADMIN: // 超级管理员可以查看所有数据 + $list = UserModel::order('create_time', 'desc')->paginate([ + 'list_rows' => $param['limit'], + 'page' => $param['page'], + ]); + break; + case AuthRoleModel::NAME_AGENT: // 代理 - 查看代理下可以查看的用户 + $list = UserModel::where('agent_id', $adminId)->order('create_time', 'desc')->paginate([ + 'list_rows' => $param['limit'], + 'page' => $param['page'], + ]); + break; + case AuthRoleModel::NAME_DIRECTOR: // 总监 - 查询总监下可以查看的用户 + $customerIds = []; + $teamHeaderIds = AdminModel::where('parent_id', $adminId)->column('id'); // 总监下面的组长ID + if (!empty($teamHeaderIds)) { + $customerIds = AdminModel::whereIn('parent_id', $teamHeaderIds)->column('id'); // 组长下面的ID + } + $list = UserModel::whereIn('customer_id', $customerIds)->order('create_time', 'desc')->paginate([ + 'list_rows' => $param['limit'], + 'page' => $param['page'], + ]); + break; + case AuthRoleModel::NAME_TEAM_HEADER: // 组长 - 查看组长下可以查看的用户 + $customerIds = AdminModel::where('parent_id', $adminId)->column('id'); // 组长下面的客服ID + $list = UserModel::whereIn('customer_id', $customerIds)->order('create_time', 'desc')->paginate([ + 'list_rows' => $param['limit'], + 'page' => $param['page'], + ]); + break; + case AuthRoleModel::NAME_CUSTOMER: // 客服 - 查看客服下的用户 + $list = UserModel::where('customer_id', $adminId)->order('create_time', 'desc')->paginate([ + 'list_rows' => $param['limit'], + 'page' => $param['page'], + ]); + break; + default: + return json(['code' => '500', 'message' => '当前角色未知,不能提供数据统计', 'data' => []]); + } + return json(['code' => '0', 'message' => 'ok', 'data' => [ + 'list' => $list->items(), + 'page' => $list->currentPage(), + 'total' => $list->total(), + 'last_page' => $list->lastPage(), + ]]); + } catch (\Exception $exception) { + return json(['code' => '500', 'message' => '系统繁忙', [$exception->getMessage(), $exception->getTrace()]]); + } + } + + // 分页统计每日交易数据 + public function dailyTradeList() + { + try { + $param = $this->request->post(); + if (empty($param['page']) || empty($param['limit']) || empty($param['market_type'])) { + return json(['code' => '400', 'message' => '缺少参数', 'data' => []]); + } + // 判断要查询的市场类型是否在有效范围内 + $tradeTables = StockMarketModel::TRADE_TABLE; + if (!isset($tradeTables[$param['market_type']])) { + return json(['code' => '400', 'message' => 'market_type不在有效范围内', 'data' => []]); + } + // 获取当登录账号信息 + $adminId = $this->request->user_id; + $account = AdminModel::where('id', $adminId)->find(); + if (empty($account)) { + return json(['code' => '500', 'message' => '当前账号数据为空', 'data' => []]); + } + // 查询当前账号的角色信息 + $role = AuthRoleModel::where(['id'=>$account->role_id])->find(); + if (empty($role)) { + return json(['code' => '500', 'message' => '当前账号分配的角色数据为空', 'data' => []]); + } + + switch ($role->name) { + case AuthRoleModel::NAME_ADMIN: // 超级管理员可以查看所有数据 +// $query1 = 'select "合约" as subject, trade_id,order_id,user_id,null as stock_id,contract_id,null as digital_id,trade_type,deal_type,status,order_money,create_time from bot_contract_trade'; +// $query2 = 'select "数字币" as subject, trade_id,order_id,user_id,null as stock_id,null as contract_id,digital_id,trade_type,deal_type,status,order_money,create_time from bot_digital_trade'; +// $query3 = 'select "美股" as subject, trade_id,order_id,user_id,stock_id,null as contract_id,null as digital_id,trade_type,deal_type,status,order_money,create_time from bot_stock_trade'; +// $query4 = 'select "马股" as subject, trade_id,order_id,user_id,stock_id,null as contract_id,null as digital_id,trade_type,deal_type,status,order_money,create_time from bot_stock_mys_trade'; +// $query5 = 'select "泰股" as subject, trade_id,order_id,user_id,stock_id,null as contract_id,null as digital_id,trade_type,deal_type,status,order_money,create_time from bot_stock_tha_trade'; +// $query6 = 'select "印尼股" as subject, trade_id,order_id,user_id,stock_id,null as contract_id,null as digital_id,trade_type,deal_type,status,order_money,create_time from bot_stock_idn_trade'; +// $query7 = 'select "印度股" as subject, trade_id,order_id,user_id,stock_id,null as contract_id,null as digital_id,trade_type,deal_type,status,order_money,create_time from bot_stock_in_trade'; +// $unionAllQuery = $query1.' union all '. $query2. ' union all '. $query3. ' union all '. $query4. ' union all '. $query5. ' union all '. $query6. ' union all '. $query7; +// $totalQuery = 'select count(*) as total from ( '. $unionAllQuery. ' ) as tmp;'; +// $total = Db::query($totalQuery); +// $list = Db::query($unionAllQuery. ' order by create_time desc limit ?, ?;', [$offset, $param['limit']]); + + $list = Db::table($tradeTables[$param['market_type']])->order('create_time', 'desc')->paginate([ + 'list_rows' => $param['limit'], + 'page' => $param['page'], + ]); + break; + case AuthRoleModel::NAME_AGENT: // 代理 - 查看代理下可以查看的用户 + $userIds = UserModel::where('agent_id', $adminId)->column('user_id'); + $list = Db::table($tradeTables[$param['market_type']])->whereIn('user_id', $userIds)->order('create_time', 'desc')->paginate([ + 'list_rows' => $param['limit'], + 'page' => $param['page'], + ]); + break; + case AuthRoleModel::NAME_DIRECTOR: // 总监 - 查询总监下可以查看的用户 + $customerIds = []; + $teamHeaderIds = AdminModel::where('parent_id', $adminId)->column('id'); // 总监下面的组长ID + if (!empty($teamHeaderIds)) { + $customerIds = AdminModel::whereIn('parent_id', $teamHeaderIds)->column('id'); // 组长下面的ID + } + $userIds = UserModel::whereIn('customer_id', $customerIds)->column('user_id'); + $list = Db::table($tradeTables[$param['market_type']])->whereIn('user_id', $userIds)->order('create_time', 'desc')->paginate([ + 'list_rows' => $param['limit'], + 'page' => $param['page'], + ]); + break; + case AuthRoleModel::NAME_TEAM_HEADER: // 组长 - 查看组长下可以查看的用户 + $customerIds = AdminModel::where('parent_id', $adminId)->column('id'); // 组长下面的客服ID + $userIds = UserModel::whereIn('customer_id', $customerIds)->column('user_id'); + $list = Db::table($tradeTables[$param['market_type']])->whereIn('user_id', $userIds)->order('create_time', 'desc')->paginate([ + 'list_rows' => $param['limit'], + 'page' => $param['page'], + ]); + break; + case AuthRoleModel::NAME_CUSTOMER: // 客服 - 查看客服下的用户 + $userIds = UserModel::where('customer_id', $adminId)->column('user_id'); + $list = Db::table($tradeTables[$param['market_type']])->whereIn('user_id', $userIds)->order('create_time', 'desc')->paginate([ + 'list_rows' => $param['limit'], + 'page' => $param['page'], + ]); + break; + default: + return json(['code' => '500', 'message' => '当前角色未知,不能提供数据统计', 'data' => []]); + } + + return json(['code' => '0', 'message' => 'ok', 'data' => [ + 'list' => $list->items(), + 'total' => $list->total(), + 'page' => $list->currentPage(), + 'last_page' => $list->lastPage(), + ]]); + } catch (\Exception $exception) { + return json(['code' => '500', 'message' => '系统繁忙', [$exception->getMessage(), $exception->getTrace()]]); + } + } + // 缓存美股数据 public function cacheUsStock() { diff --git a/app/admin/controller/Order.php b/app/admin/controller/Order.php index 1aa1a695..284419cc 100644 --- a/app/admin/controller/Order.php +++ b/app/admin/controller/Order.php @@ -6,6 +6,12 @@ use app\admin\service\OrderService; class Order extends AdminBaseController { + public function TradeNewList() + { + $service = new OrderService(); + $result = $service->TradeNewList($this->request->param()); + return json($result); + } ######################################## 现货交易 ####################################### diff --git a/app/admin/controller/Test.php b/app/admin/controller/Test.php index 0ab078f3..80eb6e27 100644 --- a/app/admin/controller/Test.php +++ b/app/admin/controller/Test.php @@ -4,6 +4,7 @@ namespace app\admin\controller; use app\model\AdminModel; use app\model\UserAccessLogModel; use app\model\UserModel; +use app\model\UserNoModel; class Test extends AdminBaseController { diff --git a/app/admin/route/app.php b/app/admin/route/app.php index 74f16a6f..4c68b187 100644 --- a/app/admin/route/app.php +++ b/app/admin/route/app.php @@ -14,7 +14,7 @@ $header = [ //Route::get('/test', 'Test/index'); Route::post('/test', 'Test/index'); Route::post('/test_upload', 'Upload/uploadVideo'); -Route::post('test_api', 'auth.AuthRule/getSideMenu'); +Route::post('test_api', 'Index/dailyUserRegistration'); Route::group('/', function () { // 国家和地区 Route::post('/country', 'Country/getAll'); @@ -64,6 +64,11 @@ Route::group('/', function () { // 首页数据 Route::post('/index', 'Index/index'); Route::post('/read_num', 'Index/getReamNum'); + Route::post('stats/daily_user_registration', 'Index/dailyUserRegistration'); // 分页统计每日注册用户 + Route::post('stats/daily_trade_list', 'Index/dailyTradeList'); // 分页统计每日交易数据 + + // 查询视图中的数据 + Route::post('/order/trade_new_list', 'Order/TradeNewList'); // 现货订单 Route::post('/order/digital_place', 'Order/digitalPlace'); diff --git a/app/admin/service/AdminService.php b/app/admin/service/AdminService.php index 14014eea..9723f73a 100644 --- a/app/admin/service/AdminService.php +++ b/app/admin/service/AdminService.php @@ -828,17 +828,17 @@ class AdminService extends AdminBaseService if (empty($param['user_id'])) { return $this->toData('400', '请指定用户ID'); } - if (empty($param['month']) || $param['month'] <= 0 || $param['month'] > 100) { - return $this->toData('400', '请指定有效的会员月数'); + if (empty($param['days']) || $param['days'] <= 0 ) { + return $this->toData('400', '赠送时间错误'); } $userId = $param['user_id']; - $giveDay = $param['month'] * 30; + $giveDay = $param['days']; $info = UserModel::getFieldsByUserId('trade_password,lever_status,gender,last_name,first_name,real_status,country_id,user_no,nick_name,email,phone_number,country_code,agent_id,is_real,head_img_id,invite_code,is_test_user', $param['user_id']); if (empty($info)) { return $this->toData('500', 'The user does not exist.'); } - // 记录购买vip信息, 扣除用户金额 + // 记录赠送vip信息 Db::transaction(function () use ($userId, $giveDay) { // 查询用户是否开通过vip,更新用户vip到期时间 $vipLog = PurchaseVipModel::where(['user_id'=>$userId])->find(); diff --git a/app/admin/service/OrderService.php b/app/admin/service/OrderService.php index f0a048d4..bc659efa 100644 --- a/app/admin/service/OrderService.php +++ b/app/admin/service/OrderService.php @@ -33,6 +33,7 @@ use app\model\StockSgdTradeModel; use app\model\StockThaListModel; use app\model\StockThaTradeModel; use app\model\StockTradeModel; +use app\model\TradeNewListModel; use app\model\UserArrearsModel; use app\model\UserBrlPreStockOrderModel; use app\model\UserEurPreStockOrderModel; @@ -56,6 +57,27 @@ use think\facade\Log; class OrderService extends AdminBaseService { + public function TradeNewList($param) + { + try { + if (empty($param['page']) || empty($param['limit'])) { + return $this->toData('400', '参错错误'); + } + $list = TradeNewListModel::order('update_time', 'desc')->paginate([ + 'list_rows' => $param['limit'], + 'page' => $param['page'], + ]); + return $this->toData('0', 'SUCCESS', [ + 'list' => $list->items(), + 'page' => $list->currentPage(), + 'total' => $list->total(), + 'last_page' => $list->lastPage(), + ]); + } catch (\Exception $e) { + return $this->toData('500', '系统异常 请稍后重试', [$e->getMessage(), $e->getTrace()]); + } + } + ######################################## 现货交易 ####################################### // 现货持仓 diff --git a/app/home/controller/Upload.php b/app/home/controller/Upload.php index bcbbbc3b..07208bde 100644 --- a/app/home/controller/Upload.php +++ b/app/home/controller/Upload.php @@ -54,7 +54,7 @@ class Upload extends HomeBaseController 'ContentType' => $file->getOriginalMime(), // 设置文件的MIME, 不然s3会以流式存储 ]); if (empty($result) || empty($result['ObjectURL'])) { - return json(['code' => 400, 'message' => '上传s3失败']); + return json(['code' => 400, 'message' => lang('upload_failed')]); } // 记录上传的文件 $resData = AwsS3Model::create([ @@ -64,7 +64,7 @@ class Upload extends HomeBaseController 'mime' => $file->getOriginalMime(), 'ext' => $file->getOriginalExtension(), ]); - return json(['code' => '0', 'message' => '上传成功', 'data' => [ + return json(['code' => '0', 'message' => lang('upload_successfully'), 'data' => [ 'id' => $resData->id, 'url' => $result['ObjectURL'], 'name' => $fileName, @@ -102,7 +102,7 @@ class Upload extends HomeBaseController { try { $param = $this->request->param(); - if (empty($param['name'])) return json(['code' => '1', 'message' => '参数错误', 'data' => []]); + if (empty($param['name'])) return json(['code' => '1', 'message' => lang('parameter_error'), 'data' => []]); $name = $param['name']; $value = ConfigModel::where('name', $name)->value('value'); diff --git a/app/home/lang/zh-cn.php b/app/home/lang/zh-cn.php new file mode 100644 index 00000000..9adecf59 --- /dev/null +++ b/app/home/lang/zh-cn.php @@ -0,0 +1,59 @@ + '系统繁忙', + 'parameter_error' => '参数错误', + 'data_empty' => '数据为空', + 'data_operation_failed' => '数据操作失败', + 'upload_failed' => '上传失败', + 'upload_successfully' => '上传成功', + 'complete_auth_before_order' => '需要完成实名认证后才能下单', + 'user_info_empty' => '用户信息为空', + 'failed_to_create_order' => '创建订单失败', + 'update_order_failed' => '更新订单失败', + 'not_enough_assets' => '用户资产不足', + 'update_user_funds_failed' => '更新用户资金失败', + 'email_not_supported' => '不支持该电子邮件', + 'exceeding_the_maximum_number' => '已超出今日的最大尝试次数,请明天再试', + 'email_send_successfully' => '电子邮件发送成功,请检查你的收件箱', + 'incorrect_verification_code' => '验证码不正确', + 'email_has_already_been_registered' => '该电子邮件已经被注册', + 'missing_agent_id' => '缺少代理ID', + 'account_registration_failed' => '注册账号失败,请稍后再试', + 'account_registration_successful' => '账号注册成功', + 'user_does_not_exist' => '用户不存在', + 'incorrect_account_or_password' => '账户或密码不正确', + 'unsupported_country_or_region' => '不受支持的国家或地区', + 'message_has_been_sent' => '消息已发送,请检查你的收件信息', + 'phone_number_has_already_been_registered' => '该电话号码已被注册', + 'please_set_the_transaction_password_first' => '请先设置交易密码', + 'please_authenticate_with_real_name_first' => '请先实名认证', + 'incorrect_transaction_password' => '交易密码不正确', + 'withdrawal_is_frozen' => '提款被封禁', + 'incorrect_withdrawal_information' => '体现信息不正确', + 'insufficient_balance' => '余额不足', + 'withdrawal_orders_cannot_be_cancelled' => '提款订单无法取消', + 'the_transfer_out_account_and_the_transfer_in_account_cannot_be_the_same_account' => '转出账户与转入账户不能为同一账户', + 'the_transfer_account_type_is_incorrect' => '转出账户类不正确', + 'incorrect_transfer_account_type' => '转入账户类型不正确', + 'already_verified' => '已经实名认证过', + 'user_real_name_authentication_data_is_empty' => '用户实名认证数据为空', + 'chat_group_is_empty' => '聊天群组为空', + 'missing_user_id' => '缺少用户ID', + 'data_configuration_error' => '数据配置错误', + 'user_usd_balance_is_insufficient' => '用户美元余额不足', + 'vip_expiration_time_error' => 'VIP过期时间错误', + 'anchor_information_is_empty' => '主播信息为空', + 'avatar_information_error' => '头像信息错误', + 'user_chat_data_error' => '用户聊天数据错误', + 'today_sending_limit_has_been_reached' => '今日发送已达上限,明日再来', + 'email_not_bound' => '邮箱未绑定', + 'please_log_in_first' => '请先登录一下', + 'phone_number_not_bound' => '电话号码未绑定', + 'payment_password_has_already_been_set' => '支付密码已设置', + 'incorrect_password' => '密码不正确', + 'already_bound_email' => '已存在绑定邮箱', + 'this_email_address_is_already_in_use' => '该邮箱已被使用', + 'the_bound_mobile_number_already_exists' => '已存在绑定的手机号', + 'this_phone_number_is_already_in_use' => '该手机号已被使用', + 'there_is_an_application_record_please_wait_for_review' => '已存在申请记录,请等待审核', +]; \ No newline at end of file diff --git a/app/home/lang/zh-jp.php b/app/home/lang/zh-jp.php new file mode 100644 index 00000000..3be84817 --- /dev/null +++ b/app/home/lang/zh-jp.php @@ -0,0 +1,60 @@ + 'システムがビジー状態です', + 'parameter_error' => 'パラメータエラー', + 'data_empty' => 'データが空です', + 'data_operation_failed' => 'データ操作に失敗しました', + 'upload_failed' => 'アップロードに失敗しました', + 'upload_successfully' => 'アップロードに成功しました', + 'complete_auth_before_order' => 'ご注文前に実名認証を完了する必要があります', + 'user_info_empty' => 'ユーザー情報が空です', + 'failed_to_create_order' => '注文を作成できませんでした', + 'update_order_failed' => '更新注文に失敗しました', + 'not_enough_assets' => '資産が足りない', + 'update_user_funds_failed' => 'ユーザーの資金の更新に失敗しました', + 'email_not_supported' => 'このメールはサポートされていません', + 'exceeding_the_maximum_number' => '本日の最大試行回数を超えました。明日もう一度お試しください', + 'email_send_successfully' => 'メールは正常に送信されました。受信トレイをご確認ください。', + 'incorrect_verification_code' => '認証コードが間違っています', + 'email_has_already_been_registered' => 'このメールアドレスはすでに登録されています', + 'missing_agent_id' => 'エージェントIDがありません', + 'account_registration_failed' => 'アカウント登録に失敗しました。しばらくしてからもう一度お試しください。', + 'account_registration_successful' => 'アカウント登録が完了しました', + 'user_does_not_exist' => 'ユーザーが存在しません', + 'incorrect_account_or_password' => 'アカウントまたはパスワードが間違っています', + 'unsupported_country_or_region' => 'サポートされていない国または地域', + 'message_has_been_sent' => 'メッセージは送信されました。受信情報をご確認ください', + 'phone_number_has_already_been_registered' => 'この電話番号はすでに登録されています', + 'please_set_the_transaction_password_first' => 'まず取引パスワードを設定してください', + 'please_authenticate_with_real_name_first' => '最初に実名で認証してください', + 'incorrect_transaction_password' => '取引パスワードが間違っています', + 'withdrawal_is_frozen' => '引き出しは凍結されています', + 'incorrect_withdrawal_information' => '出金情報が間違っています', + 'insufficient_balance' => '残高不足', + 'withdrawal_orders_cannot_be_cancelled' => '出金注文はキャンセルできません', + 'the_transfer_out_account_and_the_transfer_in_account_cannot_be_the_same_account' => '振替口座と振替口座は同じ口座にすることはできません', + 'the_transfer_account_type_is_incorrect' => '振替口座の種類が間違っています', + 'incorrect_transfer_account_type' => '振替口座の種類が正しくありません', + 'already_verified' => 'すでに確認済み', + 'user_real_name_authentication_data_is_empty' => 'ユーザーの実名認証データが空です', + 'chat_group_is_empty' => 'チャットグループは空です', + 'missing_user_id' => 'ユーザーIDがありません', + 'data_configuration_error' => 'データ構成エラー', + 'user_usd_balance_is_insufficient' => 'USDでのユーザー残高が不足しています', + 'vip_expiration_time_error' => 'VIP有効期限エラー', + 'anchor_information_is_empty' => 'アンカー情報が空です', + 'avatar_information_error' => 'アバター情報エラー', + 'user_chat_data_error' => 'ユーザーチャットデータエラー', + 'today_sending_limit_has_been_reached' => '本日の送信制限に達しました。明日もう一度お試しください', + 'email_not_bound' => 'メールはバインドされていません', + 'please_log_in_first' => 'まずはログインしてください', + 'phone_number_not_bound' => '電話番号はバインドされていません', + 'payment_password_has_already_been_set' => '支払いパスワードはすでに設定されています', + 'incorrect_password' => 'パスワードが間違っています', + 'already_bound_email' => 'バインドされたメールアドレスは既に存在します', + 'this_email_address_is_already_in_use' => 'このメールアドレスはすでに使用されています', + 'the_bound_mobile_number_already_exists' => 'バインドされた携帯電話番号は既に存在します', + 'this_phone_number_is_already_in_use' => 'この電話番号はすでに使用されています', + 'there_is_an_application_record_please_wait_for_review' => '申請記録があります。審査をお待ちください', +]; \ No newline at end of file diff --git a/app/home/lang/zh-us.php b/app/home/lang/zh-us.php new file mode 100644 index 00000000..ec6c8f01 --- /dev/null +++ b/app/home/lang/zh-us.php @@ -0,0 +1,60 @@ + 'System busy', + 'parameter_error' => 'Parameter error', + 'data_empty' => 'Data is empty', + 'data_operation_failed' => 'Data operation failed', + 'upload_failed' => 'Upload failed', + 'upload_successfully' => 'Upload Successfully', + 'complete_auth_before_order' => 'You need to complete real-name authentication before placing an order', + 'user_info_empty' => 'User information is empty', + 'failed_to_create_order' => 'Failed to create order', + 'update_order_failed' => 'Update order failed', + 'not_enough_assets' => 'Not enough assets', + 'update_user_funds_failed' => 'Update user funds failed', + 'email_not_supported' => 'The email is not supported', + 'exceeding_the_maximum_number' => 'The maximum number of attempts for today has been exceeded. Please try again tomorrow', + 'email_send_successfully' => 'Email sent successfully, please check your inbox', + 'incorrect_verification_code' => 'Incorrect verification code', + 'email_has_already_been_registered' => 'This email has already been registered', + 'missing_agent_id' => 'Missing Agent ID', + 'account_registration_failed' => 'Account registration failed, please try again later', + 'account_registration_successful' => 'Account registration successful', + 'user_does_not_exist' => 'User does not exist', + 'incorrect_account_or_password' => 'Incorrect account or password', + 'unsupported_country_or_region' => 'Unsupported country or region', + 'message_has_been_sent' => 'The message has been sent, please check your receiving information', + 'phone_number_has_already_been_registered' => 'This phone number has already been registered', + 'please_set_the_transaction_password_first' => 'Please set the transaction password first', + 'please_authenticate_with_real_name_first' => 'Please authenticate with real name first', + 'incorrect_transaction_password' => 'Incorrect transaction password', + 'withdrawal_is_frozen' => 'Withdrawal is frozen', + 'incorrect_withdrawal_information' => 'Incorrect withdrawal information', + 'insufficient_balance' => 'Insufficient balance', + 'withdrawal_orders_cannot_be_cancelled' => 'Withdrawal orders cannot be cancelled', + 'the_transfer_out_account_and_the_transfer_in_account_cannot_be_the_same_account.' => 'The transfer-out account and the transfer-in account cannot be the same account', + 'the_transfer_account_type_is_incorrect' => 'The transfer account type is incorrect', + 'incorrect_transfer_account_type' => 'Incorrect transfer account type', + 'already_verified' => 'Already verified', + 'user_real_name_authentication_data_is_empty' => 'User real-name authentication data is empty', + 'chat_group_is_empty' => 'Chat group is empty', + 'missing_user_id' => 'Missing User ID', + 'data_configuration_error' => 'Data configuration error', + 'user_usd_balance_is_insufficient' => 'The user USD balance is insufficient', + 'vip_expiration_time_error' => 'VIP expiration time error', + 'anchor_information_is_empty' => 'The anchor information is empty', + 'avatar_information_error' => 'Avatar information error', + 'user_chat_data_error' => 'User chat data error', + 'today_sending_limit_has_been_reached' => "Today's sending limit has been reached, try again tomorrow", + 'email_not_bound' => 'Email not bound', + 'please_log_in_first' => 'Please log in first', + 'phone_number_not_bound' => 'Phone number not bound', + 'payment_password_has_already_been_set' => 'The payment password has already been set', + 'incorrect_password' => 'Incorrect password', + 'already_bound_email' => 'The bound email address already exists', + 'this_email_address_is_already_in_use' => 'This email address is already in use', + 'the_bound_mobile_number_already_exists' => 'The bound mobile number already exists', + 'this_phone_number_is_already_in_use' => 'This phone number is already in use', + 'there_is_an_application_record_please_wait_for_review' => 'There is an application record, please wait for review', +]; \ No newline at end of file diff --git a/app/home/middleware/AuthMiddleware.php b/app/home/middleware/AuthMiddleware.php index b5a0b213..abec1aa7 100644 --- a/app/home/middleware/AuthMiddleware.php +++ b/app/home/middleware/AuthMiddleware.php @@ -15,23 +15,23 @@ class AuthMiddleware public function handle(Request $request, \Closure $next) { - // OPTIONS 请求直接返回空响应 if ($request->method(true) === 'OPTIONS') { return response()->send(); } + // 设置多语言 + $request->lang = Config::get('lang.default_lang'); + Config::set(['default_lang'=>'zh-jp'], 'lang'); $header = $request->header(); - if(!isset($header['language'])){ - $request->lang=Config::get('lang.default_lang'); - }else{ - $lang_list=Config::get('lang.allow_lang_list'); - $lang=strtolower($header['language']); - if(in_array($lang,$lang_list)){ - $request->lang=$lang; - }else{ - $request->lang=Config::get('lang.default_lang'); + if (isset($header['language'])) { + $lang_list = Config::get('lang.allow_lang_list'); + $lang = strtolower($header['language']); + if (in_array($lang, $lang_list)) { + $request->lang = $lang; + Config::set(['default_lang'=>$lang], 'lang'); } } + if(empty($header['token'])){ return json(['code' => '100403', 'message' => 'login please','data' => []]); } diff --git a/app/home/service/BaseHomeService.php b/app/home/service/BaseHomeService.php index 6c1eae2a..0e3c6da4 100644 --- a/app/home/service/BaseHomeService.php +++ b/app/home/service/BaseHomeService.php @@ -13,6 +13,7 @@ use app\model\DrawalSettingModel; use app\model\FeeSettingModel; use app\model\UserLevelModel; use app\model\UserModel; +use app\model\UserNoModel; use app\model\WalletListModel; use Hashids\Hashids; use Psr\SimpleCache\InvalidArgumentException; @@ -106,21 +107,23 @@ class BaseHomeService */ public function getUniqUserNo(): string { - $code = 's'; - $code .= date('ymd'); // s230629 - while (true) - { - $code .= rand(100000, 999999); - // redis 去重 - $exist = Cache::store('redis')->get($code); - // 存储有效期为距离明天还要多久 - $expire = strtotime('tomorrow') - time(); - if (!$exist) { - Cache::store('redis')->set($code, 1, $expire); - break; - } - } - return $code; + $userNoData = UserNoModel::create(['created_time'=>date("Y-m-d H:i:s")]); + return 's'.$userNoData->id; +// $code = 's'; +// $code .= date('ymd'); // s230629 +// while (true) +// { +// $code .= rand(100000, 999999); +// // redis 去重 +// $exist = Cache::store('redis')->get($code); +// // 存储有效期为距离明天还要多久 +// $expire = strtotime('tomorrow') - time(); +// if (!$exist) { +// Cache::store('redis')->set($code, 1, $expire); +// break; +// } +// } +// return $code; } /** diff --git a/app/home/service/ConfigService.php b/app/home/service/ConfigService.php index 0e0ba4c0..eb07dea5 100644 --- a/app/home/service/ConfigService.php +++ b/app/home/service/ConfigService.php @@ -10,7 +10,7 @@ class ConfigService extends BaseHomeService { try { if (empty($param['name'])) { - return $this->toData('400', '参数错误'); + return $this->toData('400', lang('parameter_error')); } $configData = []; $config = ConfigModel::where(['name'=>trim($param['name'])])->find(); diff --git a/app/home/service/DocumentService.php b/app/home/service/DocumentService.php index a3051d3e..38383b45 100644 --- a/app/home/service/DocumentService.php +++ b/app/home/service/DocumentService.php @@ -11,7 +11,7 @@ class DocumentService extends BaseHomeService { try { if (empty($param['page']) || empty($param['limit'])) { - return $this->toData('400', '参错错误'); + return $this->toData('400', lang('parameter_error')); } $where = ['state'=>1]; if (isset($param['type'])) { @@ -38,12 +38,12 @@ class DocumentService extends BaseHomeService { try { if (empty($param['id'])) { - return $this->toData('400', '参错错误'); + return $this->toData('400', lang('parameter_error')); } $info = InformationArticleModel::where(['id'=>$param['id']])->find(); if (empty($info)) { - return $this->toData('400', '数据为空'); + return $this->toData('400', lang('data_empty')); } $res = $info->toArray(); diff --git a/app/home/service/FundService.php b/app/home/service/FundService.php index 6cd12155..29d46fde 100644 --- a/app/home/service/FundService.php +++ b/app/home/service/FundService.php @@ -42,7 +42,7 @@ class FundService extends BaseHomeService return $this->toData('0', 'SUCCESS', ['list' => $rows, 'total' => $total]); } catch (\Exception $exception) { - return $this->toData('400', 'System error', [$exception->getMessage()]); + return $this->toData('500', lang(lang('system_busy')), [$exception->getMessage()]); } } @@ -51,19 +51,19 @@ class FundService extends BaseHomeService { try { if (empty($param['id']) || !is_numeric($param['id'])) { - return $this->toData('1', 'Params error', []); + return $this->toData('400', lang('parameter_error')); } $fund = PreFundStockModel::where('id', $param['id'])->where('is_delete', PreFundStockModel::IS_DELETE_NO)->find(); if (empty($fund)) { - return $this->toData('1', 'Params error', []); + return $this->toData('400', lang('parameter_error')); } $fund->product_file = json_decode($fund->product_file, true); $fund->current_manager = json_decode($fund->current_manager, true); return $this->toData('0', 'SUCCESS', ['data' => $fund, 'interest' => $fund->show_interest]); } catch (\Exception $exception) { - return $this->toData('400', 'System error', [$exception->getMessage()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage()]); } } @@ -72,7 +72,7 @@ class FundService extends BaseHomeService { try { if (empty($param['stock_code']) || !is_string($param['stock_code'])) { - return $this->toData('1', 'Params error', []); + return $this->toData('400', lang('parameter_error')); } if (empty($param['type']) || !in_array($param['type'], [1, 2, 3])) { @@ -81,7 +81,7 @@ class FundService extends BaseHomeService $historyData = HistoryFundStockModel::where('stock_code', $param['stock_code'])->find(); if (empty($historyData)) { - return $this->toData('1', 'Params error', []); + return $this->toData('400', lang('parameter_error')); } $history = []; @@ -150,7 +150,7 @@ class FundService extends BaseHomeService return $this->toData('0', 'SUCCESS', ['data' => $history, 'year' => $year, 'refer' => $referResult]); } catch (\Exception $exception) { - return $this->toData('400', 'System error', [$exception->getMessage()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage()]); } } @@ -161,15 +161,15 @@ class FundService extends BaseHomeService // 需要完成实名认证之后才能下单 $user = UserModel::where('user_id', $userId)->find(); if (empty($user) || $user->is_real != 1) { - return $this->toData('405', 'Only after completing real-name authentication can you place an order.'); + return $this->toData('500', lang('complete_auth_before_order')); } if (empty($userId)) { - return $this->toData('1', 'Login fail'); + return $this->toData('500', lang('user_info_empty')); } if (empty($param['id']) || !is_numeric($param['id'])) { - return $this->toData('1', 'Params error2', []); + return $this->toData('400', lang('parameter_error')); } $fund = PreFundStockModel::where('id', $param['id']) @@ -179,16 +179,16 @@ class FundService extends BaseHomeService ->whereTime('end_time', '>=', date('Y-m-d H:i:s')) ->find(); if (empty($fund)) { - return $this->toData('1', 'Params error3', []); + return $this->toData('400', lang('parameter_error')); } // 下单参数 if (empty($param['amount']) || !is_numeric($param['amount']) || ceil($param['amount']) != $param['amount'] || $param['amount'] <= 0) { - return $this->toData('1', 'Params error', []); + return $this->toData('400', lang('parameter_error')); } if ($param['amount'] < $fund->min_price) { - return $this->toData('1', 'Params num error4', []); + return $this->toData('400', lang('parameter_error')); } $amount = $param['amount']; @@ -221,7 +221,7 @@ class FundService extends BaseHomeService $bool = $order->save(); if (!$bool) { Db::rollback(); - return $this->toData('1', 'create fund order error', []); + return $this->toData('500', lang('failed_to_create_order')); } // 扣除用户资产 @@ -229,7 +229,7 @@ class FundService extends BaseHomeService $beforeAmount = Db::name($userStockName)->where('stock_id', 'USD')->where('user_id', $userId)->value('usable_num'); if ($beforeAmount < $amount) { Db::rollback(); - return $this->toData('1', 'assert not enough', []); + return $this->toData('500', lang('not_enough_assets')); } $updateNum = Db::name($userStockName)->where('stock_id', 'USD')->where('user_id', $userId) @@ -237,7 +237,7 @@ class FundService extends BaseHomeService ->update(['update_time' => date('Y-m-d H:i:s')]); if ($updateNum <= 0) { Db::rollback(); - return $this->toData('1', 'Update user amount error', []); + return $this->toData('500', lang('update_user_funds_failed')); } // 生成流水 @@ -253,7 +253,7 @@ class FundService extends BaseHomeService $updateNum2 = $userStockLog->save(); if ($updateNum2 <= 0) { Db::rollback(); - return $this->toData('1', 'create user log error', []); + return $this->toData('500', lang('data_operation_failed')); } @@ -262,7 +262,7 @@ class FundService extends BaseHomeService $beforeFee = Db::name($userStockName)->where('stock_id', 'USD')->where('user_id', $userId)->value('usable_num'); if ($beforeFee < $fee) { Db::rollback(); - return $this->toData('1', 'assert not enough', []); + return $this->toData('500', lang('not_enough_assets')); } $updateNum = Db::name($userStockName)->where('stock_id', 'USD')->where('user_id', $userId) @@ -271,7 +271,7 @@ class FundService extends BaseHomeService ->update(['update_time' => date('Y-m-d H:i:s')]); if ($updateNum <= 0) { Db::rollback(); - return $this->toData('1', 'Update user amount error', []); + return $this->toData('500', lang('update_user_funds_failed')); } // 生成流水 @@ -287,7 +287,7 @@ class FundService extends BaseHomeService $updateNum3 = $userStockLog->save(); if ($updateNum3 <= 0) { Db::rollback(); - return $this->toData('1', 'create user fee log error', []); + return $this->toData('500', lang('data_operation_failed')); } } @@ -308,7 +308,7 @@ class FundService extends BaseHomeService $userStockFundInterestReceiptBool = $userStockFundInterestReceipt->save(); if (!$userStockFundInterestReceiptBool) { Db::rollback(); - return $this->toData('1', 'update fund interest error', []); + return $this->toData('500', 'update fund interest error', []); } //更新基金 已购买金额 diff --git a/app/home/service/IPOService.php b/app/home/service/IPOService.php index 828a4798..c2ed60a7 100644 --- a/app/home/service/IPOService.php +++ b/app/home/service/IPOService.php @@ -676,7 +676,7 @@ class IPOService extends BaseHomeService $beforeFee = Db::table($tableObj['user_table'])->where('stock_id', $tableObj['stock_id'])->where('user_id', $userId)->value('usable_num'); if ($beforeFee < $fee) { Db::rollback(); - return $this->toData('1', 'assert not enough', []); + return $this->toData('500', lang('not_enough_assets')); } $updateNum = Db::table($tableObj['user_table'])->where('stock_id', $tableObj['stock_id'])->where('user_id', $userId) @@ -685,7 +685,7 @@ class IPOService extends BaseHomeService ->update(['update_time' => $nowDate]); if ($updateNum <= 0) { Db::rollback(); - return $this->toData('1', 'Update user amount error', []); + return $this->toData('500', lang('update_user_funds_failed')); } // 生成流水 $insertStockLogArrFee = [ @@ -746,7 +746,7 @@ class IPOService extends BaseHomeService $bool = Db::table($tableObj['order_table'])->where('id', $param['id'])->update(['status' => 1, 'update_time' => $nowDate]); if (!$bool) { Db::rollback(); - return $this->toData('1', 'update order error', []); + return $this->toData('500', lang('update_order_failed')); } } @@ -755,7 +755,7 @@ class IPOService extends BaseHomeService return $this->toData('0', 'SUCCESS', []); } catch (\Exception $exception) { Db::rollback(); - return $this->toData('1', 'System error', [$exception->getMessage(),$exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(),$exception->getTrace()]); } } @@ -841,7 +841,7 @@ class IPOService extends BaseHomeService 'stock_type_list' => $extend['type'], ]]); } catch (\Exception $exception) { - return $this->toData('1', 'System error', []); + return $this->toData('500', lang('system_busy')); } } @@ -850,18 +850,18 @@ class IPOService extends BaseHomeService { try { if (empty($param['id']) || !is_numeric($param['id'])) { - return $this->toData('1', 'Params error', []); + return $this->toData('400', lang('parameter_error')); } $tableObj = (new adminIPOService)->getStockModel($marketType); $order = Db::table($tableObj['order_table'])->where('user_id', $userId)->where('id', $param['id'])->find(); if (empty($order)) { - return $this->toData('1', 'Params error', []); + return $this->toData('400', lang('parameter_error')); } $stock = Db::table($tableObj['stock_table'])->where('id', $order['pre_stock_id'])->find(); if (empty($stock)) { - return $this->toData('1', 'Params error', []); + return $this->toData('500', lang('system_busy')); } $is_defer = '0'; @@ -899,7 +899,7 @@ class IPOService extends BaseHomeService 'stock_type_list' => $extend['type'], ]]); } catch (\Exception $exception) { - return $this->toData('1', 'System error', [$exception->getMessage(),$exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(),$exception->getTrace()]); } } diff --git a/app/home/service/LoginService.php b/app/home/service/LoginService.php index cf905554..873d3875 100644 --- a/app/home/service/LoginService.php +++ b/app/home/service/LoginService.php @@ -39,13 +39,13 @@ class LoginService extends BaseHomeService $param['email'] = trim($param['email']); // 邮箱类型校验 去除国内邮箱 if ($this->checkForbidEmail($param['email'])) { - return $this->toData('100300', 'The email is not supported.', []); + return $this->toData('500', lang('email_not_supported')); } // 每天获取code 次数限制 $sendCodeKey = 'USER:SEND_CODE_NUM:' . $ip; if ($this->checkGetNoTradeCodeNum($sendCodeKey)) { - return $this->toData('100300', 'The maximum number of attempts for today has been exceeded. Please try again tomorrow.', []); + return $this->toData('500', lang('exceeding_the_maximum_number')); } // 获取发送的邮件内容 @@ -65,15 +65,15 @@ class LoginService extends BaseHomeService $this->updateHadGetCodeNumCache($sendCodeKey); // 返回结果 - return $this->toData('0', 'Email sent successfully. Please check your inbox.', []); + return $this->toData('0', lang('email_send_successfully')); } catch (ValidateException $validateException) { // 参数校验失败 异常类 $message = $validateException->getError(); - return $this->toData('100400', $message); + return $this->toData('500', $message); } catch (\Exception $exception) { // 异常情况 - return $this->toData('100500', 'The system is busy.', [$exception->getMessage()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage()]); } } @@ -105,7 +105,7 @@ class LoginService extends BaseHomeService // 判断注册数量 ip每天可注册数量 $ipCanRegisterNumPerIpPerDay = 'USER:REGISTER:' . $ip; if ($this->checkRegisterLimit($ipCanRegisterNumPerIpPerDay)) { - return $this->toData('100300', 'The maximum number of attempts for today has been exceeded. Please try again tomorrow.', []); + return $this->toData('500', lang('exceeding_the_maximum_number')); } // 验证验证码 @@ -114,7 +114,7 @@ class LoginService extends BaseHomeService //注册验证码 $reg_key = "USER:REG:CODE"; if (!$this->checkCode($reg_key, $param['email_code'])) { - return $this->toData('100300', 'The verification code is incorrect.', []); + return $this->toData('500', lang('incorrect_verification_code')); } else { $code = random_int(1000, 9999); $this->insertCodeToCache($reg_key, $code, 300); @@ -124,7 +124,7 @@ class LoginService extends BaseHomeService // 邮箱是否已经存在 $emailExists = UserModel::checkEmailExists($email); if ($emailExists) { - return $this->toData('100300', 'The email has already been registered.', []); + return $this->toData('500', lang('email_has_already_been_registered')); } // 获取代理ID (后续要查询代理下的客服,将用户与其中一个客服绑定) @@ -147,7 +147,7 @@ class LoginService extends BaseHomeService if (empty($agentId) && empty($parentAdminId)) { $agentId = AdminModel::getDefaultAgentId(); if (empty($agentId)) { - return $this->toData('500', '缺少代理ID'); + return $this->toData('500', lang('missing_agent_id')); } } @@ -207,7 +207,7 @@ class LoginService extends BaseHomeService $chatUrl = env('CHAT_SERVER.BASE_URL') . '/api/user/register'; $chatRes = (new \app\utility\RequestChatServer())->ReqChatServer($chatUrl, $chatData); if (!isset($chatRes['data']['uuid'])) { - return $this->toData('100400', '注册聊天账号失败,请稍后再试'); + return $this->toData('500', lang('account_registration_failed')); } // 绑定注册账号与聊天账号 UserChatLinkModel::create([ @@ -221,7 +221,7 @@ class LoginService extends BaseHomeService $customerIds = AdminModel::getCustomerIdsByAgentId($agentId); // 获取代理下的所有客服ID Log::info("邮箱注册 - 客服列表:".json_encode($customerIds)); if (empty($customerIds)) { - return $this->toData('500', '客服数据错误'); + return $this->toData('500', lang('account_registration_failed')); } $counterKey = 'counter_of_bind_customer:'.$agentId; $counterIndex = Cache::store('redis')->get($counterKey); //客服绑定计数器索引 @@ -241,7 +241,7 @@ class LoginService extends BaseHomeService // 将注册账号的chat_id与绑定客服的chat_id加为好友 $customerChatInfo = UserChatLinkModel::where(['user_id'=>$tagCustomerId, 'user_type'=>UserChatLinkModel::USER_CHAT_LINK_USER_TYPE_ADMIN])->find(); //查询客服的聊天账号uuid if (empty($customerChatInfo)) { - return $this->toData('100400', 'The customer uuid is error.', []); + return $this->toData('500', lang('account_registration_failed')); } $chatFriendsData = [ 'UserUuid' => $chatRes['data']['uuid'], @@ -253,7 +253,7 @@ class LoginService extends BaseHomeService // 将当前用户加入到代理创建的群聊中 【需要查出当前用户的代理创建的群聊信息】 $agentGroup = UserChatGroupModel::where(['user_id'=>$agentId,'remark'=>UserChatGroupModel::USER_CHAT_GROUP_REMARK_ADMIN_INIT])->find(); if (empty($agentGroup)) { - return $this->toData('100400', 'The chat group data error.'); + return $this->toData('500', lang('account_registration_failed')); } $joinChatGroupUrl = env('CHAT_SERVER.BASE_URL') . '/api/group/join/'.$chatRes['data']['uuid'].'/'.$agentGroup->group_uuid; $joinChatGroupRes = (new \app\utility\RequestChatServer())->ReqChatServer($joinChatGroupUrl, []); @@ -265,15 +265,15 @@ class LoginService extends BaseHomeService // 累加已经注册的个数 $this->updateHadRegisterNumCache($ipCanRegisterNumPerIpPerDay); - return $this->toData('0', 'Registration Successful.', []); + return $this->toData('0', lang('account_registration_successful')); } catch (ValidateException $validateException) { // 参数校验失败 异常类 $message = $validateException->getError(); - return $this->toData('100400', $message); + return $this->toData('500', $message); } catch (\Exception $exception) { trace('【注册错误】提交数据:'.json_encode($param), 'error'); trace('【注册错误】'.$exception->getMessage(), 'error'); - return $this->toData('100500', 'The system is busy.', [$exception->getMessage(), $exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -292,25 +292,25 @@ class LoginService extends BaseHomeService // 查找邮箱 $userId = UserModel::getUserIdByEmail($param['email']); if ($userId <= 0) { - return $this->toData('100300', 'The user does not exist.', []); + return $this->toData('500', lang('user_does_not_exist')); } // 查找用户信息 $user = UserModel::getFieldsByUserId('invite_code,user_id,user_no,nick_name,is_real,login_password,salt', $userId); if (empty($user)) { - return $this->toData('100300', 'Incorrect account or password.', []); + return $this->toData('500', lang('user_does_not_exist')); } // 校验密码 $checkPasswordBool = (new UnqId())->checkPassword($param['password'], $user['login_password'], $user['salt']); if (!$checkPasswordBool) { - return $this->toData('100300', 'Incorrect account or password.', []); + return $this->toData('500', lang('incorrect_account_or_password')); } // 生成token $token = (new Jwt())->getToken($userId, env('ENCRYPT.SALT')); if (empty($token)) { - return $this->toData('100300', 'The system is busy.', []); + return $this->toData('500', lang('system_busy')); } // 用户登陆之后需要进行的操作 异步完成 @@ -342,11 +342,11 @@ class LoginService extends BaseHomeService } catch (ValidateException $validateException) { // 参数校验失败 异常类 $message = $validateException->getError(); - return $this->toData('100400', $message); + return $this->toData('500', $message); } catch (InvalidArgumentException $invalidArgumentException) { - return $this->toData('100400', 'The system is busy. Please try again later.', []); + return $this->toData('500', lang('system_busy')); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy.'.$exception->getMessage(), [$exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getTrace()]); } } @@ -369,13 +369,13 @@ class LoginService extends BaseHomeService $param['phone'] = trim($param['phone']); // 去除国内手机号 if ($this->checkForbidNation($param['nation'])) { - return $this->toData('100300', 'Unsupported country or region.', []); + return $this->toData('500', lang('unsupported_country_or_region')); } // 判断国家码是否有效 $nationExists = CountryModel::checkCodeExists($param['nation']); if (!$nationExists) { - return $this->toData('100300', 'Unsupported country or region.', []); + return $this->toData('500', lang('unsupported_country_or_region')); } // 发送次数校验 - 号码 @@ -408,7 +408,7 @@ class LoginService extends BaseHomeService $this->updateHadGetCodeNumCache($ipSendCodeKey); // 返回结果 - return $this->toData('0', 'The message has been sent. Please check your inbox.', []); + return $this->toData('0', lang('message_has_been_sent')); } catch (ValidateException $validateException) { // 参数校验失败 异常类 $message = $validateException->getError(); @@ -416,7 +416,7 @@ class LoginService extends BaseHomeService } catch (\Exception $exception) { trace('【注册错误】提交数据:'.json_encode($param), 'error'); trace('【注册错误】'.$exception->getMessage(), 'error'); - return $this->toData('100500', 'The system is busy.', [$exception->getMessage()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage()]); } } @@ -437,15 +437,15 @@ class LoginService extends BaseHomeService // p2项目调整,手机号注册时候也需要上传邮箱地址 if (empty($param['email'])) { - return $this->toData('400', '缺少邮箱地址参数'); + return $this->toData('400', lang('parameter_error')); } // 是否上传了实名认证信息,上传了实名认证信息时is_verify=1,否则is_verify=0 $isVerify = $param['is_verify'] ?? 0; if ($isVerify == 1) { - if (empty($param['verify_name']) || empty($param['verify_surname']) || empty($param['verify_code']) || empty($param['verify_front_img']) || empty($param['verify_country']) || empty($param['verify_birth_day']) || empty($param['verify_gender']) || - empty($param['verify_addr']) || empty($param['verify_zip_code']) || empty($param['verify_email'])) { - return $this->toData('400', '缺少实名认证参数'); + if (empty($param['verify_name']) || empty($param['verify_surname']) || empty($param['verify_code']) || empty($param['verify_front_img']) || empty($param['verify_country']) || empty($param['verify_birth_day']) || empty($param['verify_gender']) + || empty($param['verify_email'])) { + return $this->toData('400', lang('parameter_error')); } } @@ -461,7 +461,7 @@ class LoginService extends BaseHomeService $smsKey = 'DB:USER:UNLOGIN:SMS_CODE:' . $mobile; if ($param['sms_code'] != 8888) { // 方便测试,8888为万能验证码 if (!$this->checkCode($smsKey, $param['sms_code'])) { - return $this->toData('100300', 'The verification code is incorrect.', []); + return $this->toData('500', lang('incorrect_verification_code')); //注册验证码 // $reg_key = "USER:REG:CODE"; // if (!$this->checkCode($reg_key, $param['sms_code'])) { @@ -473,7 +473,7 @@ class LoginService extends BaseHomeService // 手机号是否已经存在 $phoneExists = UserModel::checkPhoneExists($param['phone']); if ($phoneExists) { - return $this->toData('100300', 'The phone number has already been registered.', []); + return $this->toData('500', lang('phone_number_has_already_been_registered')); } // 获取代理ID (后续要查询代理下的客服,将用户与其中一个客服绑定) @@ -496,7 +496,7 @@ class LoginService extends BaseHomeService if (empty($agentId) && empty($parentAdminId)) { $agentId = AdminModel::getDefaultAgentId(); if (empty($agentId)) { - return $this->toData('500', '缺少代理ID'); + return $this->toData('500', lang('missing_agent_id')); } } @@ -554,8 +554,8 @@ class LoginService extends BaseHomeService 'country' => $param['verify_country'], 'birth_day' => $param['verify_birth_day'], 'gender' => $param['verify_gender'], - 'addr' => $param['verify_addr'], - 'zip_code' => $param['verify_zip_code'], +// 'addr' => $param['verify_addr'], +// 'zip_code' => $param['verify_zip_code'], 'email' => $param['verify_email'], 'create_time' => date('Y-m-d H:i:s'), 'update_time' => date('Y-m-d H:i:s'), @@ -574,7 +574,7 @@ class LoginService extends BaseHomeService $chatUrl = env('CHAT_SERVER.BASE_URL') . '/api/user/register'; $chatRes = (new \app\utility\RequestChatServer())->ReqChatServer($chatUrl, $chatData); if (!isset($chatRes['data']['uuid'])) { - return $this->toData('100400', 'Failed to register a chat account.', []); + return $this->toData('500', lang('account_registration_failed')); } // 绑定注册账号与聊天账号 UserChatLinkModel::create([ @@ -587,7 +587,7 @@ class LoginService extends BaseHomeService if ($agentId > 0 ) { $customerIds = AdminModel::getCustomerIdsByAgentId($agentId); // 获取代理下的所有客服ID if (empty($customerIds)) { - return $this->toData('500', '客服数据错误'); + return $this->toData('500', lang('account_registration_failed')); } $counterKey = 'counter_of_bind_customer:'.$agentId; $counterIndex = Cache::store('redis')->get($counterKey); //客服绑定计数器索引 @@ -618,7 +618,7 @@ class LoginService extends BaseHomeService // 将当前用户加入到代理创建的群聊中 【需要查出当前用户的代理创建的群聊信息】 $agentGroup = UserChatGroupModel::where(['user_id'=>$agentId,'remark'=>UserChatGroupModel::USER_CHAT_GROUP_REMARK_ADMIN_INIT])->find(); if (empty($agentGroup)) { - return $this->toData('100400', 'The chat group is error.', []); + return $this->toData('500', lang('account_registration_failed')); } $joinChatGroupUrl = env('CHAT_SERVER.BASE_URL') . '/api/group/join/'.$chatRes['data']['uuid'].'/'.$agentGroup->group_uuid; $joinChatGroupRes = (new \app\utility\RequestChatServer())->ReqChatServer($joinChatGroupUrl, []); @@ -632,13 +632,13 @@ class LoginService extends BaseHomeService // 更新注册个数 $this->updateHadRegisterNumCache($ipCanRegisterNumPerIpPerDay); - return $this->toData('0', 'Registration Successful.', []); + return $this->toData('0', lang('account_registration_successful')); } catch (ValidateException $validateException) { // 参数校验失败 异常类 $message = $validateException->getError(); return $this->toData('100400', $message); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy.', [$exception->getMessage(), $exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -662,26 +662,26 @@ class LoginService extends BaseHomeService $smsKey = 'DB:USER:UNLOGIN:SMS_CODE:' . $mobile; if ($param['sms_code'] != 8888) { if (!$this->checkCode($smsKey, $param['sms_code'])) { - return $this->toData('100300', 'The verification code is incorrect.', []); + return $this->toData('500', lang('incorrect_verification_code')); }; } // 查找手机号 $userId = UserModel::getUserIdByNationAndPhone($param['nation'], $param['phone']); if ($userId <= 0) { - return $this->toData('100300', 'The user does not exist.', []); + return $this->toData('500', lang('user_does_not_exist')); } // 查找用户信息 $user = UserModel::getFieldsByUserId('invite_code,user_id,user_no,nick_name,is_real,login_password,salt', $userId); if (empty($user)) { - return $this->toData('100300', 'Incorrect account or password.', []); + return $this->toData('500', lang('user_does_not_exist')); } // 生成token $token = (new Jwt())->getToken($userId, env('ENCRYPT.SALT')); if (empty($token)) { - return $this->toData('100300', 'The system is busy. Please try again later.', []); + return $this->toData('500', lang('system_busy')); } // 用户登陆之后需要进行的操作 异步完成 @@ -714,7 +714,7 @@ class LoginService extends BaseHomeService $message = $validateException->getError(); return $this->toData('100400', $message); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy. Please try again later.', [$exception->getMessage(), $exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -733,13 +733,13 @@ class LoginService extends BaseHomeService // 验证码 $emailKey = 'DB:USER:UNLOGIN:EMAIL_CODE:' . $param['email']; if (!$this->checkCode($emailKey, $param['email_code'])) { - return $this->toData('100300', 'The verification code is incorrect', []); + return $this->toData('500', lang('incorrect_verification_code')); } // 查找邮箱 $userId = UserModel::getUserIdByEmail($param['email']); if ($userId <= 0) { - return $this->toData('100300', 'The user does not exist.', []); + return $this->toData('500', lang('user_does_not_exist')); } // 修改密码 @@ -756,7 +756,7 @@ class LoginService extends BaseHomeService $message = $validateException->getError(); return $this->toData('100400', $message); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy. Please try again later.', [$exception->getMessage(), $exception->getTrace()]); + return $this->toData('100500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -776,13 +776,13 @@ class LoginService extends BaseHomeService $mobile = $param['nation'] . $param['phone']; $smsKey = 'DB:USER:UNLOGIN:SMS_CODE:' . $mobile; if (!$this->checkCode($smsKey, $param['sms_code'])) { - return $this->toData('100300', 'The verification code is incorrect', []); + return $this->toData('500', lang('incorrect_verification_code')); } // 查找用户 $userId = UserModel::getUserIdByNationAndPhone($param['nation'], $param['phone']); if ($userId <= 0) { - return $this->toData('100300', 'The user does not exist.', []); + return $this->toData('500', lang('user_does_not_exist')); } // 修改密码 @@ -799,7 +799,7 @@ class LoginService extends BaseHomeService $message = $validateException->getError(); return $this->toData('100400', $message); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy. Please try again later.', [$exception->getMessage(), $exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -818,24 +818,24 @@ class LoginService extends BaseHomeService // 获取用户 $userId = UserModel::getUserIdByNationAndPhone($param['nation'], $param['phone']); if ($userId <= 0) { - return $this->toData('100300', 'Incorrect account or password.1', []); + return $this->toData('500', lang('user_does_not_exist')); } $info = UserModel::getFieldsByUserId('invite_code,is_real,nick_name,user_no,user_id,login_password,salt', $userId); if (empty($info)) { - return $this->toData('100300', 'Incorrect account or password.2', []); + return $this->toData('500', lang('user_does_not_exist')); } // 校验密码 $checkPasswordBool = (new UnqId())->checkPassword($param['password'], $info['login_password'], $info['salt']); if (!$checkPasswordBool) { - return $this->toData('100300', 'Incorrect account or password.3', []); + return $this->toData('500', lang('incorrect_account_or_password')); } // 生成token $token = (new Jwt())->getToken($userId, env('ENCRYPT.SALT')); if (empty($token)) { - return $this->toData('100400', 'The system is busy. Please try again later.', []); + return $this->toData('500', lang('system_busy')); } // 用户登陆之后需要进行的操作 异步完成 @@ -868,7 +868,7 @@ class LoginService extends BaseHomeService $message = $validateException->getError(); return $this->toData('100400', $message); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy. Please try again later.', []); + return $this->toData('500', lang('system_busy')); } } @@ -879,16 +879,16 @@ class LoginService extends BaseHomeService $tokenUserKey = 'AUTO:TOKEN:'.$login_token; $userId = Cache::store('redis')->get($tokenUserKey); if(empty($userId) || $userId <= 0){ - return $this->toData('100300', 'Incorrect token', []); + return $this->toData('500', 'Incorrect token', []); } $info = UserModel::getFieldsByUserId('invite_code,is_real,nick_name,user_no,user_id,login_password,salt', $userId); if (empty($info)) { - return $this->toData('100300', 'Incorrect account or password.2', []); + return $this->toData('500', lang('user_does_not_exist')); } // 生成token $token = (new Jwt())->getToken($userId, env('ENCRYPT.SALT')); if (empty($token)) { - return $this->toData('100400', 'The system is busy. Please try again later.', []); + return $this->toData('500', lang('system_busy'), []); } // 将token存致缓存 覆盖新的缓存 实现单设备登陆 @@ -912,7 +912,7 @@ class LoginService extends BaseHomeService $message = $validateException->getError(); return $this->toData('100400', $message); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy. Please try again later.', []); + return $this->toData('500', lang('system_busy')); } } @@ -932,7 +932,7 @@ class LoginService extends BaseHomeService // 生成token $token = (new Jwt())->getToken($userId, env('ENCRYPT.SALT')); if (empty($token)) { - return $this->toData('100400', 'The system is busy. Please try again later.', []); + return $this->toData('500', lang('system_busy')); } // 将token存致缓存 覆盖新的缓存 实现单设备登陆 @@ -956,7 +956,7 @@ class LoginService extends BaseHomeService $message = $validateException->getError(); return $this->toData('100400', $message); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy. Please try again later.', []); + return $this->toData('500', lang('system_busy'), []); } } diff --git a/app/home/service/MarketService.php b/app/home/service/MarketService.php index 39c30e33..120feeeb 100644 --- a/app/home/service/MarketService.php +++ b/app/home/service/MarketService.php @@ -46,12 +46,12 @@ class MarketService extends BaseHomeService $result = $this->getDigitalList(); break; } - return $this->toData(0,'Request successful.',$result); + return $this->toData(0,'successful', $result); }catch (ValidateException $validateException){ $message = $validateException->getMessage(); return $this->toData('1', $message, []); }catch (\Exception $exception){ - return $this->toData('100500', 'The system is busy. Please try again later.', [$exception->getMessage(),$exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(),$exception->getTrace()]); } } @@ -66,12 +66,12 @@ class MarketService extends BaseHomeService try{ validate(MarketValidate::class)->scene('getMarket')->check($data); $result=UserMarketModel::getUserMarket($data); - return $this->toData(0,'Request successful.',$result); + return $this->toData(0,'successful', $result); }catch (ValidateException $validateException){ $message = $validateException->getMessage(); return $this->toData('1', $message, []); }catch (\Exception $exception){ - return $this->toData('100500', 'The system is busy. Please try again later.', [$exception->getMessage(),$exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(),$exception->getTrace()]); } } @@ -94,12 +94,12 @@ class MarketService extends BaseHomeService UserMarketModel::insertUserMarket($data); } $this->pushUserMarket($data); - return $this->toData(0,'Request successful.'); + return $this->toData(0,'successful'); }catch (ValidateException $validateException){ $message = $validateException->getMessage(); return $this->toData('1', $message, []); }catch (\Exception $exception){ - return $this->toData('100500', 'The system is busy. Please try again later.', [$exception->getMessage(),$exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(),$exception->getTrace()]); } @@ -107,7 +107,7 @@ class MarketService extends BaseHomeService public function getUserIsCollect(array $data): array { $id = UserMarketModel::checkExistMarket($data); - return $this->toData(0, 'Request successful.',[ + return $this->toData(0, 'successful',[ 'is_collet'=>($id > 0) ]); } @@ -126,12 +126,12 @@ class MarketService extends BaseHomeService UserMarketModel::delUserMarket($id); } $this->pushUserMarket($data); - return $this->toData(0,'Request successful.'); + return $this->toData(0,'successful'); }catch (ValidateException $validateException){ $message = $validateException->getMessage(); return $this->toData('1', $message, []); }catch (\Exception $exception){ - return $this->toData('100500', 'The system is busy. Please try again later.', [$exception->getMessage(),$exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(),$exception->getTrace()]); } } private function pushUserMarket($data){ @@ -164,12 +164,12 @@ class MarketService extends BaseHomeService validate(MarketValidate::class)->scene('getTradeFee')->check($data); $fee_info=$this->initTradeFeeSetting($data['market_type']); //$fee_info=FeeSettingModel::getTradeFeeById($data['market_type']); - return $this->toData(0,'Request successful.',$fee_info); + return $this->toData(0,'successful',$fee_info); }catch (ValidateException $validateException){ $message = $validateException->getMessage(); return $this->toData('1', $message, []); }catch (\Exception $exception){ - return $this->toData('100500', 'The system is busy. Please try again later.', [$exception->getMessage(),$exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(),$exception->getTrace()]); } } public function getMarketTradeList(array $data):array @@ -188,23 +188,23 @@ class MarketService extends BaseHomeService break; } - return $this->toData(0,'Request successful.',$list); + return $this->toData(0,'successful',$list); }catch (ValidateException $validateException){ $message = $validateException->getMessage(); return $this->toData('1', $message, []); }catch (\Exception $exception){ - return $this->toData('100500', 'The system is busy. Please try again later.', [$exception->getMessage(),$exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(),$exception->getTrace()]); } } public function getTradeTypeList():array { $list=$this->getCapitalTypeList(); - return $this->toData(0,'Request successful.',$list); + return $this->toData(0,'successful',$list); } public function getContractFace():array { $list=$this->getContractFaceList(1); - return $this->toData(0,'Request successful.',$list); + return $this->toData(0,'successful',$list); } public function getForexFace($data):array { @@ -214,12 +214,12 @@ class MarketService extends BaseHomeService }else{ $arr=[]; } - return $this->toData(0,'Request successful.',$arr); + return $this->toData(0,'successful',$arr); } public function getContractSetting():array { $list=ContractSettingModel::getSettingList(); - return $this->toData(0,'Request successful.',$list); + return $this->toData(0,'successful',$list); } public function getMarketRate():array { @@ -229,7 +229,7 @@ class MarketService extends BaseHomeService }else{ $list_arr=[]; } - return $this->toData(0,'Request successful.',$list_arr); + return $this->toData(0,'successful',$list_arr); } // 获取一条印度股指交易对 @@ -241,7 +241,7 @@ class MarketService extends BaseHomeService }else{ $arr=[]; } - return $this->toData(0,'Request successful.',$arr); + return $this->toData(0,'successful',$arr); } diff --git a/app/home/service/PreHkdStockService.php b/app/home/service/PreHkdStockService.php index e281a8ec..3d192474 100644 --- a/app/home/service/PreHkdStockService.php +++ b/app/home/service/PreHkdStockService.php @@ -105,7 +105,7 @@ class PreHkdStockService extends BaseHomeService 'stock_type_list' => PreHkdStockModel::$stockTypeList, ]]); } catch (\Exception $exception) { - return $this->toData('1', 'System error', []); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -114,12 +114,12 @@ class PreHkdStockService extends BaseHomeService { try { if (empty($param['id']) || !is_numeric($param['id'])) { - return $this->toData('1', 'Params error', []); + return $this->toData('400', lang('parameter_error')); } $preStock = PreHkdStockModel::where('id', $param['id'])->where('is_delete', PreHkdStockModel::IS_DELETE_NO)->where('status', PreHkdStockModel::STATUS_ON)->find(); if (empty($preStock)) { - return $this->toData('1', 'Params error', []); + return $this->toData('400', lang('parameter_error')); } $is_defer = '0'; @@ -169,7 +169,7 @@ class PreHkdStockService extends BaseHomeService 'stock_type_list' => PreHkdStockModel::$stockTypeList, ]]); } catch (\Exception $exception) { - return $this->toData('1', 'System error', []); + return $this->toData('400', lang('parameter_error')); } } @@ -178,7 +178,7 @@ class PreHkdStockService extends BaseHomeService { try { if (empty($param['id']) || !is_numeric($param['id'])) { - return $this->toData('1', 'Params error', []); + return $this->toData('400', lang('parameter_error')); } $preHkdStock = PreHkdStockModel::where('id', $param['id']) @@ -188,34 +188,34 @@ class PreHkdStockService extends BaseHomeService ->whereTime('end_time', '>=', date('Y-m-d H:i:s')) ->find(); if (empty($preHkdStock)) { - return $this->toData('1', 'Params error', []); + return $this->toData('400', lang('parameter_error')); } $hasOrder = UserHkdPreStockOrderModel::where('user_id', $userId)->where('pre_stock_id', $param['id'])->count(); if ($preHkdStock->limit_get_num <= $hasOrder) { - return $this->toData('1', 'Had Purchased', []); + return $this->toData('500', 'Had Purchased', []); } // 下单参数 if (empty($param['num']) || !is_numeric($param['num']) || ceil($param['num']) != $param['num'] || $param['num'] <= 0) { - return $this->toData('1', 'Params error', []); + return $this->toData('400', lang('parameter_error')); } if ($param['num'] < $preHkdStock->min) { - return $this->toData('1', 'Order quantity less than the minimum', []); + return $this->toData('500', 'Order quantity less than the minimum', []); } if ($preHkdStock->max > 0 && $param['num'] > $preHkdStock->max) { - return $this->toData('1', 'Order quantity greater than maximum', []); + return $this->toData('500', 'Order quantity greater than maximum', []); } if ($preHkdStock->price <= 0) { - return $this->toData('1', 'Price error', []); + return $this->toData('500', 'Price error', []); } // 支付类型 if (empty($param['pay_type']) || !is_numeric($param['pay_type']) || !in_array($param['pay_type'], [UserHkdPreStockOrderModel::PAY_TYPE_ONE, UserHkdPreStockOrderModel::PAY_TYPE_TWO])) { - return $this->toData('1', 'Params error', []); + return $this->toData('400', lang('parameter_error')); } // 计算金额 @@ -249,7 +249,7 @@ class PreHkdStockService extends BaseHomeService $bool = $order->save(); if (!$bool) { Db::rollback(); - return $this->toData('1', 'create order error', []); + return $this->toData('500', lang('failed_to_create_order')); } if ($param['pay_type'] == 2) { @@ -261,7 +261,7 @@ class PreHkdStockService extends BaseHomeService $beforeAmount = UserStockHkdModel::where('stock_id', 'HKD')->where('user_id', $userId)->value('usable_num'); if ($beforeAmount < $amount) { Db::rollback(); - return $this->toData('1', 'assert not enough', []); + return $this->toData('500', lang('not_enough_assets')); } $updateNum = UserStockHkdModel::where('stock_id', 'HKD')->where('user_id', $userId) @@ -270,7 +270,7 @@ class PreHkdStockService extends BaseHomeService ->update(['update_time' => date('Y-m-d H:i:s')]); if ($updateNum <= 0) { Db::rollback(); - return $this->toData('1', 'Update user amount error', []); + return $this->toData('500', lang('update_user_funds_failed')); } // 生成流水 @@ -286,7 +286,7 @@ class PreHkdStockService extends BaseHomeService $updateNum2 = $userStockLog->save(); if ($updateNum2 <= 0) { Db::rollback(); - return $this->toData('1', 'create user log error', []); + return $this->toData('500', lang('system_busy')); } @@ -295,7 +295,7 @@ class PreHkdStockService extends BaseHomeService $beforeFee = UserStockHkdModel::where('stock_id', 'HKD')->where('user_id', $userId)->value('usable_num'); if ($beforeFee < $fee) { Db::rollback(); - return $this->toData('1', 'assert not enough', []); + return $this->toData('500', lang('not_enough_assets')); } $updateNum = UserStockHkdModel::where('stock_id', 'HKD')->where('user_id', $userId) @@ -304,7 +304,7 @@ class PreHkdStockService extends BaseHomeService ->update(['update_time' => date('Y-m-d H:i:s')]); if ($updateNum <= 0) { Db::rollback(); - return $this->toData('1', 'Update user amount error', []); + return $this->toData('500', lang('update_user_funds_failed')); } // 生成流水 @@ -320,7 +320,7 @@ class PreHkdStockService extends BaseHomeService $updateNum3 = $userStockLog->save(); if ($updateNum3 <= 0) { Db::rollback(); - return $this->toData('1', 'create user fee log error', []); + return $this->toData('500', lang('system_busy')); } } @@ -329,7 +329,7 @@ class PreHkdStockService extends BaseHomeService ]); } catch (\Exception $exception) { Db::rollback(); - return $this->toData('1', 'System error', []); + return $this->toData('500', lang('system_busy')); } } @@ -349,12 +349,12 @@ class PreHkdStockService extends BaseHomeService ->find(); if (empty($preHkdStock)) { - return $this->toData('1', 'Payment deadline exceeded', []); + return $this->toData('500', 'Payment deadline exceeded', []); } $hasOrder = UserHkdPreStockOrderModel::where('user_id', $userId)->where('id', $param['id'])->where('pay_type', UserHkdPreStockOrderModel::PAY_TYPE_TWO)->where('status', UserHkdPreStockOrderModel::STATUS_POST_PAY)->find(); if (empty($hasOrder)) { - return $this->toData('1', 'Params error3', []); + return $this->toData('500', lang('data_empty')); } $orderNo = $hasOrder->order_no; @@ -383,7 +383,7 @@ class PreHkdStockService extends BaseHomeService ->update(['update_time' => $now]); if ($updateNum <= 0) { Db::rollback(); - return $this->toData('1', 'Update user amount error', []); + return $this->toData('500', lang('update_user_funds_failed'), []); } // 生成流水 @@ -399,7 +399,7 @@ class PreHkdStockService extends BaseHomeService $updateNum2 = $userStockLog->save(); if ($updateNum2 <= 0) { Db::rollback(); - return $this->toData('1', 'create user log error', []); + return $this->toData('500', lang('system_busy'), []); } // 扣除手续费 @@ -407,7 +407,7 @@ class PreHkdStockService extends BaseHomeService $beforeFee = UserStockHkdModel::where('stock_id', 'HKD')->where('user_id', $userId)->value('usable_num'); if ($beforeFee < $fee) { Db::rollback(); - return $this->toData('1', 'assert not enough', []); + return $this->toData('500', lang('not_enough_assets'), []); } $updateNum = UserStockHkdModel::where('stock_id', 'HKD')->where('user_id', $userId) @@ -416,7 +416,7 @@ class PreHkdStockService extends BaseHomeService ->update(['update_time' => date('Y-m-d H:i:s')]); if ($updateNum <= 0) { Db::rollback(); - return $this->toData('1', 'Update user amount error', []); + return $this->toData('500', lang('update_user_funds_failed'), []); } // 生成流水 @@ -432,14 +432,14 @@ class PreHkdStockService extends BaseHomeService $updateNum3 = $userStockLog->save(); if ($updateNum3 <= 0) { Db::rollback(); - return $this->toData('1', 'create user fee log error', []); + return $this->toData('500', lang('system_busy'), []); } } $bool = UserHkdPreStockOrderModel::where('id', $param['id'])->update(['status' => UserHkdPreStockOrderModel::STATUS_SIGNING, 'update_time' => $now]); if (!$bool) { Db::rollback(); - return $this->toData('1', 'update order error', []); + return $this->toData('500', lang('system_busy'), []); } } elseif ($preHkdStock->sign_status == PreHkdStockModel::SIGN_STATUS_NO && strtotime($preHkdStock->get_time) >= strtotime($now)) { @@ -451,7 +451,7 @@ class PreHkdStockService extends BaseHomeService $beforeAmount = UserStockHkdModel::where('stock_id', 'HKD')->where('user_id', $userId)->value('usable_num'); if ($beforeAmount < $amount) { Db::rollback(); - return $this->toData('1', 'assert not enough', []); + return $this->toData('1', lang('not_enough_assets'), []); } $updateNum = UserStockHkdModel::where('stock_id', 'HKD')->where('user_id', $userId) @@ -460,7 +460,7 @@ class PreHkdStockService extends BaseHomeService ->update(['update_time' => $now]); if ($updateNum <= 0) { Db::rollback(); - return $this->toData('1', 'Update user amount error', []); + return $this->toData('500', lang('update_user_funds_failed'), []); } // 生成流水 @@ -476,7 +476,7 @@ class PreHkdStockService extends BaseHomeService $updateNum2 = $userStockLog->save(); if ($updateNum2 <= 0) { Db::rollback(); - return $this->toData('1', 'create user log error', []); + return $this->toData('500', lang('system_busy'), []); } // 扣除手续费 @@ -484,7 +484,7 @@ class PreHkdStockService extends BaseHomeService $beforeFee = UserStockHkdModel::where('stock_id', 'HKD')->where('user_id', $userId)->value('usable_num'); if ($beforeFee < $fee) { Db::rollback(); - return $this->toData('1', 'assert not enough', []); + return $this->toData('500', lang('not_enough_assets'), []); } $updateNum = UserStockHkdModel::where('stock_id', 'HKD')->where('user_id', $userId) @@ -493,7 +493,7 @@ class PreHkdStockService extends BaseHomeService ->update(['update_time' => date('Y-m-d H:i:s')]); if ($updateNum <= 0) { Db::rollback(); - return $this->toData('1', 'Update user amount error', []); + return $this->toData('500', lang('update_user_funds_failed'), []); } // 生成流水 @@ -509,25 +509,25 @@ class PreHkdStockService extends BaseHomeService $updateNum3 = $userStockLog->save(); if ($updateNum3 <= 0) { Db::rollback(); - return $this->toData('1', 'create user fee log error', []); + return $this->toData('500', lang('system_busy'), []); } } $bool = UserHkdPreStockOrderModel::where('id', $param['id'])->update(['status' => UserHkdPreStockOrderModel::STATUS_DOING, 'update_time' => $now]); if (!$bool) { Db::rollback(); - return $this->toData('1', 'update order error', []); + return $this->toData('500', lang('system_busy'), []); } } else { Db::rollback(); - return $this->toData('1', 'Params error4', []); + return $this->toData('500', lang('system_busy'), []); } Db::commit(); return $this->toData('0', 'SUCCESS', []); } catch (\Exception $exception) { Db::rollback(); - return $this->toData('1', 'System error', [$exception->getMessage()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage()]); } } @@ -541,7 +541,7 @@ class PreHkdStockService extends BaseHomeService } if (empty($param['status'])) { - return $this->toData('1', 'Params error'); + return $this->toData('400', lang('parameter_error')); } $statusArr = explode(",", $param['status']); @@ -604,7 +604,7 @@ class PreHkdStockService extends BaseHomeService 'stock_type_list' => PreHkdStockModel::$stockTypeList, ]]); } catch (\Exception $exception) { - return $this->toData('1', 'System error', []); + return $this->toData('500', lang('system_busy'), []); } } @@ -613,17 +613,17 @@ class PreHkdStockService extends BaseHomeService { try { if (empty($param['id']) || !is_numeric($param['id'])) { - return $this->toData('1', 'Params error', []); + return $this->toData('400', lang('parameter_error')); } $order = UserHkdPreStockOrderModel::where('user_id', $userId)->where('id', $param['id'])->find(); if (empty($order)) { - return $this->toData('1', 'Params error', []); + return $this->toData('500', lang('data_empty')); } $stock = PreHkdStockModel::where('id', $order->pre_stock_id)->find(); if (empty($stock)) { - return $this->toData('1', 'Params error', []); + return $this->toData('500', lang('data_empty')); } $is_defer = '0'; @@ -659,7 +659,7 @@ class PreHkdStockService extends BaseHomeService 'stock_type_list' => PreHkdStockModel::$stockTypeList, ]]); } catch (\Exception $exception) { - return $this->toData('1', 'System error', []); + return $this->toData('500', lang('system_busy')); } } } \ No newline at end of file diff --git a/app/home/service/UserService.php b/app/home/service/UserService.php index 9c913610..390602ce 100644 --- a/app/home/service/UserService.php +++ b/app/home/service/UserService.php @@ -140,12 +140,12 @@ class UserService extends BaseHomeService { try { if (empty($userId) || $userId <= 0) { - return $this->toData('100403', 'Please log in first', []); + return $this->toData('500', lang('user_does_not_exist')); } $info = UserModel::getFieldsByUserId('trade_password,lever_status,gender,last_name,first_name,real_status,country_id,user_no,nick_name,email,phone_number,country_code,agent_id,customer_id,is_real,head_img_id,invite_code,is_test_user,customer_remark,label', $userId); if (empty($info)) { - return $this->toData('100400', 'The user does not exist.', []); + return $this->toData('500', lang('user_does_not_exist')); } // 获取国家名称 @@ -197,7 +197,7 @@ class UserService extends BaseHomeService if ($info['agent_id']) { $agentGroup = UserChatGroupModel::where(['user_id'=>$info['agent_id']])->find(); if (empty($agentGroup)) { - return $this->toData('100400', 'Agent chat group is null.', []); + return $this->toData('500', lang('chat_group_is_empty')); } $group_chat_name = $agentGroup->group_name; $group_chat_uuid = $agentGroup->group_uuid; @@ -263,7 +263,7 @@ class UserService extends BaseHomeService 'label' => $info['label'], ]); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy.', [$exception->getMessage(), $exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -272,40 +272,40 @@ class UserService extends BaseHomeService { try { if (empty($userId) || $userId <= 0) { - return $this->toData('100403', 'Please log in first', []); + return $this->toData('500', lang('missing_user_id')); } $info = UserModel::getFieldsByUserId('trade_password,lever_status,gender,last_name,first_name,real_status,country_id,user_no,nick_name,email,phone_number,country_code,agent_id,is_real,head_img_id,invite_code,is_test_user', $userId); if (empty($info)) { - return $this->toData('100400', 'The user does not exist.', []); + return $this->toData('500', lang('user_does_not_exist')); } // 获取购买VIP所需的配置 $vipPurchaseCfg = Config::get('common.vip_purchase'); if (empty($vipPurchaseCfg)) { - return $this->toData('100400', 'vip config error', []); + return $this->toData('500', lang('data_configuration_error')); } // 购买vip所需的货币类型检测 [产品确定使用美股支付 USD] if (empty($vipPurchaseCfg['stock_id'])) { - return $this->toData('100400', 'vip config error', []); + return $this->toData('500', lang('data_configuration_error')); } $stockId = $vipPurchaseCfg['stock_id']; // vip价格检测 if (!isset($vipPurchaseCfg['vip_price']) || $vipPurchaseCfg['vip_price'] <= 0) { - return $this->toData('100400', 'vip config error', []); + return $this->toData('500', lang('data_configuration_error')); } $vipPrice = $vipPurchaseCfg['vip_price']; // vip有效天数检测 if (!isset($vipPurchaseCfg['vip_day']) || $vipPurchaseCfg['vip_day'] <= 0) { - return $this->toData('100400', 'vip config error', []); + return $this->toData('500', lang('data_configuration_error')); } $vipDay = $vipPurchaseCfg['vip_day']; // 查询用户美股余额是否足够 【产品确定用美股余额支付】 $userMoney = UserStockModel::where(['user_id'=>$userId,'stock_id'=> $stockId])->find(); if (empty($userMoney)) { - return $this->toData('100400', ' The user USD balance is insufficient'); + return $this->toData('500', lang('user_usd_balance_is_insufficient')); } $userMoneyNum = $userMoney->usable_num; if ($userMoneyNum < $vipPrice) { - return $this->toData('100400', ' The user USD balance is insufficient'); + return $this->toData('500', lang('user_usd_balance_is_insufficient')); } // 记录购买vip信息, 扣除用户金额 @@ -328,7 +328,7 @@ class UserService extends BaseHomeService $expireTime = date("Y-m-d H:i:s", $expireTimestamp); if (!empty($vipLog)) { if (empty($vipLog->expire)) { - return $this->toData('100400', ' The vip expire error '); + return $this->toData('500', lang('vip_expiration_time_error')); } if ($vipLog->expire >= date("Y-m-d H:i:s")) { $expireTimestamp = strtotime('+30 day', strtotime($vipLog->expire)); @@ -353,7 +353,7 @@ class UserService extends BaseHomeService }); return $this->toData('0', 'successful'); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy.', [$exception->getMessage(), $exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -362,13 +362,13 @@ class UserService extends BaseHomeService { try { if (!isset($param['page']) || !isset($param['limit'])) { - return $this->toData('100403', 'Missing parameter', []); + return $this->toData('400', lang('parameter_error')); } $list = PurchaseVipLogModel::where(['user_id'=>$userId])->order('id', 'desc')->paginate([ 'list_rows' => $param['limit'], 'page' => $param['page'], ]); - return $this->toData('0', 'Successful', [ + return $this->toData('0', 'successful', [ 'list' => $list->items(), // 当前页的数据 'page' => $list->currentPage(), // 当前页码 'total' => $list->total(), // 总记录数 @@ -376,7 +376,7 @@ class UserService extends BaseHomeService ]); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy.', [$exception->getLine(), $exception->getMessage(), $exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getLine(), $exception->getMessage(), $exception->getTrace()]); } } @@ -385,24 +385,24 @@ class UserService extends BaseHomeService { try { if (empty($userId) || $userId <= 0) { - return $this->toData('100403', 'Please log in first', []); + return $this->toData('500', lang('missing_user_id')); } // 查询用户所属的代理id $info = UserModel::getFieldsByUserId('trade_password,lever_status,gender,last_name,first_name,real_status,country_id,user_no,nick_name,email,phone_number,country_code,agent_id,is_real,head_img_id,invite_code,is_test_user', $userId); if (empty($info)) { - return $this->toData('100400', 'The user does not exist.', []); + return $this->toData('500', lang('user_does_not_exist')); } if (empty($info['agent_id'])) { - return $this->toData('100400', 'The user does not have a agent.', []); + return $this->toData('500', lang('user_does_not_exist')); } // 查询代理下的一个主播信息 $anchorData = AwsIvsModel::where(['agent_id'=>$info['agent_id']])->find(); if (empty($anchorData)) { - return $this->toData('100400', 'The anchor information is empty', ['agent_id'=>$info['agent_id']]); + return $this->toData('500', lang('anchor_information_is_empty'), ['agent_id'=>$info['agent_id']]); } - return $this->toData('0', 'Modification successful.', $anchorData->toArray()); + return $this->toData('0', 'successful.', $anchorData->toArray()); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy.', [$exception->getMessage(), $exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -417,7 +417,7 @@ class UserService extends BaseHomeService try { // 主键 if (empty($userId) || $userId <= 0) { - return $this->toData('100403', 'Please log in first.', []); + return $this->toData('500', lang('missing_user_id')); } // 邮件注册参数校验 validate(UserValidate::class)->scene('setCountry')->check($param); @@ -426,22 +426,22 @@ class UserService extends BaseHomeService // 国家是否存在 $country = CountryModel::getById($countryId); if (empty($country)) { - return $this->toData('100400', 'Unsupported country or region.', []); + return $this->toData('500', lang('unsupported_country_or_region')); } // 是否是黑名单国家 if ($this->checkForbidNation($country['code'])) { - return $this->toData('100400', 'Unsupported country or region.', []); + return $this->toData('500', lang('unsupported_country_or_region')); } // 设置 UserModel::updateFieldsByUserId(['country_id' => $country['id']], $userId); - return $this->toData('0', 'Modification successful.'); + return $this->toData('0', 'successful'); } catch (ValidateException $validateException) { $message = $validateException->getMessage(); - return $this->toData('100400', $message, []); + return $this->toData('500', $message); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy.', [$exception->getMessage(), $exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -456,7 +456,7 @@ class UserService extends BaseHomeService try { // 主键 if (empty($userId) || $userId <= 0) { - return $this->toData('100403', 'Please log in first.'); + return $this->toData('500', lang('missing_user_id')); } // 参数校验 validate(UserValidate::class)->scene('updateHeadImg')->check($param); @@ -464,12 +464,12 @@ class UserService extends BaseHomeService // 查询头像信息 $avatarInfo = AwsS3Model::where(['id'=>$fileId])->find(); if (empty($avatarInfo)) { - return $this->toData('500', '头像信息错误'); + return $this->toData('500', lang('avatar_information_error')); } // 修改用户头像 $user = UserModel::where(['user_id'=>$userId])->find(); if (empty($user)) { - return $this->toData('500', '用户数据错误'); + return $this->toData('500', lang('user_does_not_exist')); } $user->head_img_id = $fileId; $user->save(); @@ -477,7 +477,7 @@ class UserService extends BaseHomeService // 查询用户的chat信息 $userChatInfo = UserChatLinkModel::where(['user_id'=>$userId, 'user_type'=>UserChatLinkModel::USER_CHAT_LINK_USER_TYPE_PC])->find(); if (empty($userChatInfo)) { - return $this->toData('500', '该用户的聊天信息错误'); + return $this->toData('500', lang('user_chat_data_error')); } // 头像修改后需要同步通知给聊天服 $upChaData = [ @@ -493,9 +493,9 @@ class UserService extends BaseHomeService return $this->toData($chatFriendsRes['code'], $chatFriendsRes['msg'], [$chatFriendsRes['data']]); } catch (ValidateException $validateException) { $message = $validateException->getMessage(); - return $this->toData('100400', $message, []); + return $this->toData('500', $message); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy.', []); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -510,7 +510,7 @@ class UserService extends BaseHomeService try { // 主键 if (empty($userId) || $userId <= 0) { - return $this->toData('100403', 'Please log in first.', []); + return $this->toData('500', lang('missing_user_id')); } // 参数校验 @@ -519,7 +519,7 @@ class UserService extends BaseHomeService // 修改用户信息 $user = UserModel::where(['user_id'=>$userId])->find(); if (empty($user)) { - return $this->toData('100403', 'Please log in first.', []); + return $this->toData('500', lang('user_does_not_exist')); } $user->nick_name = $param['nick_name']; $user->gender = $param['gender']; @@ -530,14 +530,14 @@ class UserService extends BaseHomeService // 获取用户chat信息 $userChatInfo = UserChatLinkModel::where(['user_id'=>$userId,'user_type'=>UserChatLinkModel::USER_CHAT_LINK_USER_TYPE_PC])->find(); if (empty($userChatInfo)) { - return $this->toData('500', '该用户的聊天信息错误'); + return $this->toData('500', lang('user_chat_data_error')); } // 获取用户头像 $avatarUrl = ""; if (!empty($user->head_img_id)) { $avatarInfo = AwsS3Model::where(['id'=>$user->head_img_id])->find(); if (empty($avatarInfo)) { - return $this->toData('500', '头像信息错误'); + return $this->toData('500', lang('avatar_information_error')); } $avatarUrl = $avatarInfo->s3_url; } @@ -555,9 +555,9 @@ class UserService extends BaseHomeService } catch (ValidateException $validateException) { $message = $validateException->getError(); - return $this->toData('100400', $message); + return $this->toData('500', $message); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy.', [$exception->getMessage()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -576,7 +576,7 @@ class UserService extends BaseHomeService // 主键 if (empty($userId) || $userId <= 0) { - return $this->toData('100403', 'Please log in first.', []); + return $this->toData('500', lang('missing_user_id')); } // 参数校验 @@ -586,7 +586,7 @@ class UserService extends BaseHomeService $key = 'USER:SEND_CODE_NUM:' . $ip; if ($param['business'] == '1') { if ($this->checkGetNoTradeCodeNum($key)) { - return $this->toData('100300', 'No worries. Please feel free to reach out again tomorrow.', []); + return $this->toData('500', lang('today_sending_limit_has_been_reached')); } } @@ -596,7 +596,7 @@ class UserService extends BaseHomeService if ($emailType == 1) { $email = UserModel::getEmailById($userId); if (empty($email)) { - return $this->toData('100400', '邮箱未绑定', []); + return $this->toData('500', lang('email_not_bound')); } } @@ -617,13 +617,13 @@ class UserService extends BaseHomeService $this->insertCodeToCache($sendEmailCacheKey, $code, 300); // 返回结果 - return $this->toData('0', 'Modification successful.'); + return $this->toData('0', 'successful'); } catch (ValidateException $validateException) { // 参数校验失败 异常类 $message = $validateException->getError(); - return $this->toData('100400', $message); + return $this->toData('500', $message); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy.', [$exception->getMessage()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -641,7 +641,7 @@ class UserService extends BaseHomeService // 主键 if (empty($userId) || $userId <= 0) { - return $this->toData('100403', 'Please log in first.', []); + return $this->toData('500', lang('please_log_in_first')); } // 参数校验 @@ -651,7 +651,7 @@ class UserService extends BaseHomeService $key = 'USER:SEND_CODE_NUM:' . $ip; if ($param['business'] == '1') { if ($this->checkGetNoTradeCodeNum($key)) { - return $this->toData('100300', 'No worries. Please feel free to reach out again tomorrow.', []); + return $this->toData('500', lang('today_sending_limit_has_been_reached')); } } @@ -662,7 +662,7 @@ class UserService extends BaseHomeService if ($phoneType == 1) { $user = UserModel::getFieldsByUserId('country_code,phone_number', $userId); if (empty($user)) { - return $this->toData('100400', 'The phone number is not linked/bound.', []); + return $this->toData('500', lang('phone_number_not_bound')); } $phone = $user['phone_number']; $nation = $user['country_code']; @@ -670,7 +670,7 @@ class UserService extends BaseHomeService // 如果给新手机发 判断国家码是否存在 $nationCheck = CountryModel::checkCodeExists($nation); if (!$nationCheck) { - return $this->toData('100400', 'Unsupported country or region.', []); + return $this->toData('500', lang('unsupported_country_or_region')); } } @@ -694,13 +694,13 @@ class UserService extends BaseHomeService // 返回结果 - return $this->toData('0', 'Modification successful.'); + return $this->toData('0', 'successful'); } catch (ValidateException $validateException) { // 参数校验失败 异常类 $message = $validateException->getError(); - return $this->toData('100400', $message); + return $this->toData('500', $message); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy.', [$exception->getMessage()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -709,7 +709,7 @@ class UserService extends BaseHomeService try { // 主键 if (empty($userId) || $userId <= 0) { - return $this->toData('100403', 'Please log in first.', []); + return $this->toData('500', lang('please_log_in_first')); } // 参数校验 email_code pay_password @@ -718,7 +718,7 @@ class UserService extends BaseHomeService // 获取用户 $user = UserModel::getFieldsByUserId('email,user_id,trade_password', $userId); if (empty($user)) { - return $this->toData('100403', 'Please log in first.', []); + return $this->toData('500', lang('user_does_not_exist')); } // // 校验验证码 @@ -730,7 +730,7 @@ class UserService extends BaseHomeService // 如果已经存在交易密码 则不能设置 if (!empty($user['trade_password'])) { - return $this->toData('100400', 'The payment password has already been set.', []); + return $this->toData('500', lang('payment_password_has_already_been_set')); } // 加密密码 @@ -741,13 +741,13 @@ class UserService extends BaseHomeService // 设置密码 UserModel::setPayPassword($payPassword, $salt, $userId); - return $this->toData('0', 'Modification successful.', []); + return $this->toData('0', 'successful'); } catch (ValidateException $validateException) { // 参数校验失败 异常类 $message = $validateException->getError(); return $this->toData('100400', $message); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy.', []); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -763,7 +763,7 @@ class UserService extends BaseHomeService try { // 主键 if (empty($userId) || $userId <= 0) { - return $this->toData('100403', 'Please log in first.', []); + return $this->toData('500', lang('please_log_in_first')); } // 参数校验 nation phone pay_password @@ -772,11 +772,11 @@ class UserService extends BaseHomeService // 获取用户信息 $user = UserModel::getFieldsByUserId('country_code,phone_number,user_id,trade_password', $userId); if (empty($user)) { - return $this->toData('100403', 'Please log in first.', []); + return $this->toData('500', lang('user_does_not_exist')); } if (!empty($user['trade_password'])) { - return $this->toData('100400', 'The payment password has already been set.', []); + return $this->toData('500', lang('payment_password_has_already_been_set')); } // // 校验验证码 @@ -795,13 +795,13 @@ class UserService extends BaseHomeService // 设置密码 UserModel::setPayPassword($payPassword, $salt, $userId); - return $this->toData('0', 'Modification successful.', []); + return $this->toData('0', 'successful'); } catch (ValidateException $validateException) { // 参数校验失败 异常类 $message = $validateException->getError(); return $this->toData('100400', $message); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy.', [$exception->getMessage()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -818,7 +818,7 @@ class UserService extends BaseHomeService try { // user_id if (empty($userId) || $userId <= 0) { - return $this->toData('100403', 'Please log in first.', []); + return $this->toData('500', lang('please_log_in_first')); } // 参数校验 email_code email @@ -827,7 +827,7 @@ class UserService extends BaseHomeService // 获取用户信息 $user = UserModel::getFieldsByUserId('user_id,trade_password,salt,phone_number,country_code', $userId); if (empty($user)) { - return $this->toData('100403', 'Please log in first.', []); + return $this->toData('500', lang('user_does_not_exist')); } // 提取参数 @@ -848,7 +848,7 @@ class UserService extends BaseHomeService // 校验旧密码 $checkPasswordBool = (new UnqId())->checkPassword($payPassword, $user['trade_password'], $user['salt']); if (!$checkPasswordBool) { - return $this->toData('100400', 'Incorrect password.'); + return $this->toData('500', lang('incorrect_transaction_password')); } // 设置密码 @@ -856,14 +856,14 @@ class UserService extends BaseHomeService UserModel::updateFieldsByUserId(['trade_password' => $newPassword], $userId); // 返回结果 - return $this->toData('0', 'Modification successful.', []); + return $this->toData('0', 'successful'); } catch (ValidateException $validateException) { // 参数校验失败 异常类 $message = $validateException->getError(); return $this->toData('100400', $message); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy.', [$exception->getMessage()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -881,7 +881,7 @@ class UserService extends BaseHomeService try { // user_id if (empty($userId) || $userId <= 0) { - return $this->toData('100403', 'Please log in first.', []); + return $this->toData('500', lang('please_log_in_first')); } // 参数校验 email_code email @@ -890,7 +890,7 @@ class UserService extends BaseHomeService // 获取用户信息 $user = UserModel::getFieldsByUserId('user_id,trade_password,salt,email', $userId); if (empty($user)) { - return $this->toData('100403', 'Please log in first.', []); + return $this->toData('500', lang('user_does_not_exist')); } // 提取参数 @@ -909,7 +909,7 @@ class UserService extends BaseHomeService // 校验旧密码 $checkPasswordBool = (new UnqId())->checkPassword($payPassword, $user['trade_password'], $user['salt']); if (!$checkPasswordBool) { - return $this->toData('100400', 'Incorrect password.', []); + return $this->toData('500', lang('incorrect_transaction_password')); } // 设置密码 @@ -917,14 +917,14 @@ class UserService extends BaseHomeService UserModel::updateFieldsByUserId(['trade_password' => $newPassword], $userId); // 返回结果 - return $this->toData('0', 'Modification successful.', []); + return $this->toData('0', 'successful'); } catch (ValidateException $validateException) { // 参数校验失败 异常类 $message = $validateException->getError(); return $this->toData('100400', $message); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy.', [$exception->getMessage()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -941,7 +941,7 @@ class UserService extends BaseHomeService try { // user_id if (empty($userId) || $userId <= 0) { - return $this->toData('100403', 'Please log in first.', []); + return $this->toData('500', lang('please_log_in_first')); } // 参数校验 email_code email @@ -950,7 +950,7 @@ class UserService extends BaseHomeService // 获取用户信息 $user = UserModel::getFieldsByUserId('user_id,salt,phone_number,country_code', $userId); if (empty($user)) { - return $this->toData('100403', 'Please log in first.', []); + return $this->toData('500', lang('user_does_not_exist')); } // 提取参数 @@ -972,14 +972,14 @@ class UserService extends BaseHomeService UserModel::updateFieldsByUserId(['trade_password' => $newPassword], $userId); // 返回结果 - return $this->toData('0', 'Modification successful.', []); + return $this->toData('0', 'successful'); } catch (ValidateException $validateException) { // 参数校验失败 异常类 $message = $validateException->getError(); return $this->toData('100400', $message); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy.', [$exception->getMessage()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -997,7 +997,7 @@ class UserService extends BaseHomeService try { // user_id if (empty($userId) || $userId <= 0) { - return $this->toData('100403', 'Please log in first.', []); + return $this->toData('500', lang('please_log_in_first')); } // 参数校验 email_code email @@ -1006,7 +1006,7 @@ class UserService extends BaseHomeService // 获取用户信息 $user = UserModel::getFieldsByUserId('user_id,salt,email', $userId); if (empty($user)) { - return $this->toData('100403', 'Please log in first.', []); + return $this->toData('500', lang('user_does_not_exist')); } // 提取参数 @@ -1026,14 +1026,14 @@ class UserService extends BaseHomeService UserModel::updateFieldsByUserId(['trade_password' => $newPassword], $userId); // 返回结果 - return $this->toData('0', 'Modification successful.', []); + return $this->toData('0', 'successful'); } catch (ValidateException $validateException) { // 参数校验失败 异常类 $message = $validateException->getError(); return $this->toData('100400', $message); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy.', [$exception->getMessage()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage()]); } } @@ -1041,7 +1041,7 @@ class UserService extends BaseHomeService { try { if (empty($userId) || $userId <= 0) { - return $this->toData('100403', 'Please log in first.', []); + return $this->toData('500', lang('please_log_in_first')); } // 参数校验 email_code email @@ -1050,7 +1050,7 @@ class UserService extends BaseHomeService // 获取用户信息 $user = UserModel::getFieldsByUserId('user_id,login_password,salt,phone_number,country_code', $userId); if (empty($user)) { - return $this->toData('100403', 'Please log in first.', []); + return $this->toData('500', lang('user_does_not_exist')); } // 提取参数 @@ -1071,7 +1071,7 @@ class UserService extends BaseHomeService // 校验旧密码 $checkPasswordBool = (new UnqId())->checkPassword($password, $user['login_password'], $user['salt']); if (!$checkPasswordBool) { - return $this->toData('100400', 'Incorrect password.', []); + return $this->toData('500', lang('incorrect_password')); } // 设置密码 @@ -1079,14 +1079,14 @@ class UserService extends BaseHomeService UserModel::updateFieldsByUserId(['login_password' => $newPassword], $userId); // 返回结果 - return $this->toData('0', 'Modification successful.', []); + return $this->toData('0', 'successful'); } catch (ValidateException $validateException) { // 参数校验失败 异常类 $message = $validateException->getError(); return $this->toData('100400', $message); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy.', [$exception->getMessage()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -1103,7 +1103,7 @@ class UserService extends BaseHomeService try { // user_id if (empty($userId) || $userId <= 0) { - return $this->toData('100403', 'Please log in first.', []); + return $this->toData('500', lang('please_log_in_first')); } // 参数校验 @@ -1112,7 +1112,7 @@ class UserService extends BaseHomeService // 获取用户信息 $user = UserModel::getFieldsByUserId('user_id,login_password,salt,email', $userId); if (empty($user)) { - return $this->toData('100403', 'Please log in first.', []); + return $this->toData('500', lang('user_does_not_exist')); } // 提取参数 @@ -1131,7 +1131,7 @@ class UserService extends BaseHomeService // 校验旧密码 $checkPasswordBool = (new UnqId())->checkPassword($password, $user['login_password'], $user['salt']); if (!$checkPasswordBool) { - return $this->toData('100400', 'Incorrect password.', []); + return $this->toData('500', lang('incorrect_password')); } // 设置密码 @@ -1139,14 +1139,14 @@ class UserService extends BaseHomeService UserModel::updateFieldsByUserId(['login_password' => $newPassword], $userId); // 返回结果 - return $this->toData('0', 'Modification successful.', []); + return $this->toData('0', 'successful'); } catch (ValidateException $validateException) { // 参数校验失败 异常类 $message = $validateException->getError(); return $this->toData('100400', $message); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy.', [$exception->getMessage()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -1162,7 +1162,7 @@ class UserService extends BaseHomeService { try { if (empty($userId) || $userId <= 0) { - return $this->toData('100403', 'Please log in first.', []); + return $this->toData('500', lang('please_log_in_first')); } // 参数校验 email_code email @@ -1171,7 +1171,7 @@ class UserService extends BaseHomeService // 获取用户信息 $user = UserModel::getFieldsByUserId('user_id,salt,phone_number,country_code', $userId); if (empty($user)) { - return $this->toData('100403', 'Please log in first.', []); + return $this->toData('500', lang('user_does_not_exist')); } // 提取参数 @@ -1193,14 +1193,14 @@ class UserService extends BaseHomeService UserModel::updateFieldsByUserId(['login_password' => $newPassword], $userId); // 返回结果 - return $this->toData('0', 'Modification successful.', []); + return $this->toData('0', 'successful'); } catch (ValidateException $validateException) { // 参数校验失败 异常类 $message = $validateException->getError(); return $this->toData('100400', $message); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy.', [$exception->getMessage()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -1217,7 +1217,7 @@ class UserService extends BaseHomeService try { // user_id if (empty($userId) || $userId <= 0) { - return $this->toData('100403', 'Please log in first.', []); + return $this->toData('500', lang('please_log_in_first')); } // 参数校验 email_code email @@ -1226,7 +1226,7 @@ class UserService extends BaseHomeService // 获取用户信息 $user = UserModel::getFieldsByUserId('user_id,salt,email', $userId); if (empty($user)) { - return $this->toData('100403', 'Please log in first.', []); + return $this->toData('500', lang('user_does_not_exist')); } // 提取参数 @@ -1246,14 +1246,14 @@ class UserService extends BaseHomeService UserModel::updateFieldsByUserId(['login_password' => $newPassword], $userId); // 返回结果 - return $this->toData('0', 'Modification successful.', []); + return $this->toData('0', 'successful'); } catch (ValidateException $validateException) { // 参数校验失败 异常类 $message = $validateException->getError(); return $this->toData('100400', $message); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy.', [$exception->getMessage()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage()]); } } @@ -1262,7 +1262,7 @@ class UserService extends BaseHomeService try { // user_id if (empty($userId) || $userId <= 0) { - return $this->toData('100403', 'Please log in first.', []); + return $this->toData('500', lang('please_log_in_first')); } // 参数校验 email_code email @@ -1280,37 +1280,37 @@ class UserService extends BaseHomeService // 获取用户信息 $user = UserModel::getFieldsByUserId('email,user_id', $userId); if (empty($user)) { - return $this->toData('100403', 'Please log in first.', []); + return $this->toData('500', lang('user_does_not_exist')); } // 判读是否已经绑定 if (!empty($user['email'])) { - return $this->toData('100400', 'You have already bound your email', []); + return $this->toData('500', lang('already_bound_email')); } - //判断手机号是否已经被别人绑定 + // 判断邮箱是否被别人使用 $emailExits = UserModel::checkEmailExists($email); if ($emailExits) { - return $this->toData('100400', 'The email has been bound', []); + return $this->toData('500', lang('this_email_address_is_already_in_use')); } // 执行入库操作 UserModel::updateFieldsByUserId(['email' => $email], $userId); // 返回结果 - return $this->toData('0', 'Binding successful', []); + return $this->toData('0', 'successful'); } catch (ValidateException $validateException) { // 参数校验失败 异常类 $message = $validateException->getError(); return $this->toData('100400', $message); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy.', [$exception->getMessage()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } /** - * @desc 修改已经绑定的手机号 + * @desc 修改已经绑定的邮箱 * @param $userId * @param $param * @return array @@ -1321,7 +1321,7 @@ class UserService extends BaseHomeService try { // user_id if (empty($userId) || $userId <= 0) { - return $this->toData('100403', 'Please log in first.', []); + return $this->toData('500', lang('please_log_in_first')); } // 参数校验 nation phone sms_code @@ -1339,37 +1339,32 @@ class UserService extends BaseHomeService // 获取用户信息 $user = UserModel::getFieldsByUserId('login_password,email,user_id,salt', $userId); if (empty($user)) { - return $this->toData('100403', 'Please log in first.', []); - } - - // 判读是否已经绑定 需要已经绑定 - if (empty($user['email'])) { - return $this->toData('100400', 'Email is not linked/bound.', []); + return $this->toData('500', lang('user_does_not_exist')); } //校验登陆密码 $passwordCheck = (new UnqId())->checkPassword($param['password'], $user['login_password'], $user['salt']); if (!$passwordCheck) { - return $this->toData('100400', 'Incorrect password.', []); + return $this->toData('500', lang('incorrect_password')); } - //判断手机号是否已经被别人绑定 + // 判断邮箱是否被使用 $emailExits = UserModel::checkEmailExists($email); if ($emailExits) { - return $this->toData('100400', 'The email has already been linked/bound.', []); + return $this->toData('500', lang('this_email_address_is_already_in_use')); } // 执行入库操作 UserModel::updateFieldsByUserId(['email' => $email], $userId); // 返回结果 - return $this->toData('0', 'Modification successful.', []); + return $this->toData('0', 'successful'); } catch (ValidateException $validateException) { // 参数校验失败 异常类 $message = $validateException->getError(); - return $this->toData('100400', $message); + return $this->toData('500', $message); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy.', [$exception->getMessage()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -1377,9 +1372,8 @@ class UserService extends BaseHomeService public function bindPhone($userId, $param) { try { - // user_id if (empty($userId) || $userId <= 0) { - return $this->toData('100403', 'Please log in first.', []); + return $this->toData('500', lang('please_log_in_first')); } // 参数校验 nation phone sms_code @@ -1397,38 +1391,38 @@ class UserService extends BaseHomeService // 获取用户信息 $user = UserModel::getFieldsByUserId('user_id,country_code,phone_number', $userId); if (empty($user)) { - return $this->toData('100403', 'Please log in first.', []); + return $this->toData('500', lang('user_does_not_exist')); } // 判读是否已经绑定 if (!empty($user['phone_number'])) { - return $this->toData('100400', 'The phone number has already been linked/bound.', []); + return $this->toData('500', lang('the_bound_mobile_number_already_exists')); } //判断手机号是否已经被别人绑定 $phoneExits = UserModel::checkPhoneExists($param['phone']); if ($phoneExits) { - return $this->toData('100400', 'The phone number has already been linked/bound.', []); + return $this->toData('500', lang('this_phone_number_is_already_in_use')); } // 判断国家码是否存在 $codeExists = CountryModel::checkCodeExists($param['nation']); if (!$codeExists) { - return $this->toData('100400', 'Unsupported country or region.', []); + return $this->toData('500', lang('unsupported_country_or_region')); } // 执行入库操作 UserModel::updateFieldsByUserId(['phone_number' => $param['phone'], 'country_code' => $param['nation']], $userId); // 返回结果 - return $this->toData('0', 'Binding successful.', []); + return $this->toData('0', 'successful'); } catch (ValidateException $validateException) { // 参数校验失败 异常类 $message = $validateException->getError(); - return $this->toData('100400', $message); + return $this->toData('500', $message); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy.', [$exception->getMessage()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -1444,7 +1438,7 @@ class UserService extends BaseHomeService try { // user_id if (empty($userId) || $userId <= 0) { - return $this->toData('100403', 'Please log in first.', []); + return $this->toData('500', lang('please_log_in_first')); } // 参数校验 nation phone sms_code @@ -1462,43 +1456,38 @@ class UserService extends BaseHomeService // 判断国家码是否存在 $codeExists = CountryModel::checkCodeExists($param['nation']); if (!$codeExists) { - return $this->toData('100400', 'Unsupported country or region', []); + return $this->toData('500', lang('unsupported_country_or_region')); } //判断手机号是否已经被别人绑定 $phoneExits = UserModel::checkPhoneExists($param['phone']); if ($phoneExits) { - return $this->toData('100400', 'The phone number has already been linked/bound.', []); + return $this->toData('500', lang('the_bound_mobile_number_already_exists')); } // 获取用户信息 $user = UserModel::getFieldsByUserId('salt,login_password,user_id,country_code,phone_number', $userId); if (empty($user)) { - return $this->toData('100403', 'Please log in first.', []); - } - - // 判读是否已经绑定 需要已经绑定手机 - if (empty($user['phone_number'])) { - return $this->toData('100400', 'The phone number is not linked/bound.', []); + return $this->toData('500', lang('user_does_not_exist')); } //校验登陆密码 $passwordCheck = (new UnqId())->checkPassword($param['password'], $user['login_password'], $user['salt']); if (!$passwordCheck) { - return $this->toData('100400', 'Incorrect password.', []); + return $this->toData('500', lang('incorrect_password')); } // 执行入库操作 UserModel::updateFieldsByUserId(['phone_number' => $param['phone'], 'country_code' => $param['nation']], $userId); // 返回结果 - return $this->toData('0', 'Modification successful.', []); + return $this->toData('0', 'successful'); } catch (ValidateException $validateException) { // 参数校验失败 异常类 $message = $validateException->getError(); - return $this->toData('100400', $message); + return $this->toData('500', $message); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy.', [$exception->getMessage()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } public function apply_loan($userId, $param) @@ -1506,14 +1495,14 @@ class UserService extends BaseHomeService try { // user_id if (empty($userId) || $userId <= 0) { - return $this->toData('100403', 'Please log in first.', []); + return $this->toData('500', lang('please_log_in_first')); } // 参数校验 nation phone sms_code validate(UserValidate::class)->scene('apply_loan')->check($param); $count=UserLoanModel::where('status',0)->where('user_id',$userId)->count(); if($count>0){ - return $this->toData('100402', 'You have applied, please be patient and wait.', []); + return $this->toData('500', lang('there_is_an_application_record_please_wait_for_review')); } $userloan=new UserLoanModel(); @@ -1526,14 +1515,14 @@ class UserService extends BaseHomeService $userloan->save(); // 返回结果 - return $this->toData('0', 'Binding successful.', []); + return $this->toData('0', 'successful'); } catch (ValidateException $validateException) { // 参数校验失败 异常类 $message = $validateException->getError(); - return $this->toData('100400', $message); + return $this->toData('500', $message); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy.', [$exception->getMessage()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } public function loan($userId, $param) @@ -1541,21 +1530,21 @@ class UserService extends BaseHomeService try { // user_id if (empty($userId) || $userId <= 0) { - return $this->toData('100403', 'Please log in first.', []); + return $this->toData('500', lang('please_log_in_first')); } $data['where']['user_id']=$userId; $data['page']=isset($param['page']) ? intval($param['page']) : 1; $data['size']=isset($param['size']) ? intval($param['size']) : 10; $list=UserLoanModel::getUserLoanList($data); // 返回结果 - return $this->toData('0', 'successful.', $list); + return $this->toData('0', 'successful', $list); } catch (ValidateException $validateException) { // 参数校验失败 异常类 $message = $validateException->getError(); - return $this->toData('100400', $message); + return $this->toData('500', $message); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy.', [$exception->getMessage()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -1570,9 +1559,9 @@ class UserService extends BaseHomeService try { // 删除缓存 $this->delUserTokenCache($userId); - return $this->toData('0', 'Modification successful.'); + return $this->toData('0', 'successful'); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy.', [$exception->getMessage()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -1586,12 +1575,12 @@ class UserService extends BaseHomeService { try { if (empty($userId) || $userId <= 0) { - return $this->toData('100403', 'Please log in first.', []); + return $this->toData('500', lang('please_log_in_first')); } $data = UserLoginLog::getLog($userId); if (empty($data)) { - return $this->toData('0', 'Modification successful.', []); + return $this->toData('0', 'successful'); } $res = []; @@ -1623,9 +1612,9 @@ class UserService extends BaseHomeService ]; } - return $this->toData('0', 'Modification successful.', $res); + return $this->toData('0', 'successful', $res); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy.', []); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -1638,41 +1627,41 @@ class UserService extends BaseHomeService { try { if (empty($userId) || $userId <= 0) { - return $this->toData('100403', 'Please log in first.', []); + return $this->toData('500', lang('please_log_in_first')); } // 获取用户信息 $user = UserModel::getFieldsByUserId('lever_status,user_id', $userId); if (empty($user)) { - return $this->toData('100403', 'Please log in first.', []); + return $this->toData('500', lang('user_does_not_exist')); } if (in_array($user['lever_status'], [UserModel::LEVER_STATUS_NO, UserModel::LEVER_STATUS_FAIL])) { $level_status=env('USER_LEVEL.NO_APPLY')==1 ? UserModel::LEVER_STATUS_PASSED : UserModel::LEVER_STATUS_APPLY; UserModel::update(['lever_status' => $level_status, 'update_time' => date('Y-m-d H:i:s')], ['user_id' => $userId]); - return $this->toData('0', 'success.', []); + return $this->toData('0', 'success'); } - return $this->toData('0', 'Already submitted.', []); + return $this->toData('0', 'Already submitted'); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy.', []); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } public function applyTestAccount($userId) { if (empty($userId) || $userId <= 0) { - return $this->toData('100403', 'Please log in first.', []); + return $this->toData('500', lang('please_log_in_first')); } // 获取用户信息 $user = UserModel::getFieldsByUserId('test_account,user_id,user_no', $userId); if (empty($user)) { - return $this->toData('100401', 'Please log in first.', []); + return $this->toData('500', lang('user_does_not_exist')); } if(!empty($user['test_account'])){ - return $this->toData('0', 'success.', []); + return $this->toData('0', 'success', []); } //添加模拟账号 $userNo=$this->getUniqUserNo(); @@ -1731,16 +1720,16 @@ class UserService extends BaseHomeService } public function applyTestMoney($userId,$param){ if (empty($userId) || $userId <= 0) { - return $this->toData('100403', 'Please log in first.', []); + return $this->toData('500', lang('please_log_in_first')); } // 获取用户信息 $user = UserModel::getFieldsByUserId('is_test_user,user_id,user_no', $userId); if (empty($user)) { - return $this->toData('100401', 'Please log in first.', []); + return $this->toData('500', lang('user_does_not_exist')); } if($user['is_test_user']!=2){ - return $this->toData('100402', 'error.', []); + return $this->toData('100402', 'error', []); } $num=isset($param['num']) ? intval($param['num']) : 0; if($num<=0 || $num>100000){ @@ -1761,17 +1750,17 @@ class UserService extends BaseHomeService // 获取用户信息 $user = UserModel::getFieldsByUserId('test_account,user_id,user_no', $userId); if (empty($user)) { - return $this->toData('100401', 'Please log in first.', []); + return $this->toData('500', lang('please_log_in_first')); } if(empty($user['test_account'])){ - return $this->toData('100402', 'Please log in first.', []); + return $this->toData('500', lang('user_does_not_exist')); } //登录模拟账号 $test_user=UserModel::getFieldsByUserId('test_account,user_id,user_no,nick_name,invite_code,is_real,is_test_user', $user['test_account']); // 生成token $token = (new Jwt())->getToken($test_user['user_id'], env('ENCRYPT.SALT')); if (empty($token)) { - return $this->toData('100300', 'The system is busy.', []); + return $this->toData('500', lang('system_busy')); } // 将token存致缓存 覆盖新的缓存 实现单设备登陆 @@ -1795,23 +1784,23 @@ class UserService extends BaseHomeService // 获取用户信息 $user = UserModel::getFieldsByUserId('parent_id,user_id,user_no,is_test_user', $userId); if (empty($user)) { - return $this->toData('100401', 'Please log in first.', []); + return $this->toData('500', lang('user_does_not_exist')); } if(empty($user['parent_id'])){ - return $this->toData('100402', 'The system is busy.', []); + return $this->toData('500', lang('system_busy')); } if(empty($user['is_test_user'])){ - return $this->toData('100403', 'The system is busy.', []); + return $this->toData('500', lang('system_busy')); } //登录模拟账号 $test_user=UserModel::getFieldsByUserId('test_account,user_id,user_no,nick_name,invite_code,is_real,is_test_user', $user['parent_id']); if($test_user['test_account']!=$userId){ - return $this->toData('100404', 'The system is busy.', []); + return $this->toData('500', lang('system_busy')); } // 生成token $token = (new Jwt())->getToken($test_user['user_id'], env('ENCRYPT.SALT')); if (empty($token)) { - return $this->toData('100300', 'The system is busy.', []); + return $this->toData('500', lang('system_busy')); } // 将token存致缓存 覆盖新的缓存 实现单设备登陆 @@ -1836,7 +1825,7 @@ class UserService extends BaseHomeService { try { if (empty($param['page_url']) || empty($param['module']) || empty($param['remark'])) { - return $this->toData('400', '参数错误'); + return $this->toData('400', lang('parameter_error')); } $userAccessLog = UserAccessLogModel::create([ 'user_id' => $userId, @@ -1845,11 +1834,11 @@ class UserService extends BaseHomeService 'remark' => $param['remark'], ]); if (empty($userAccessLog)) { - return $this->toData('500', '添加数据失败'); + return $this->toData('500', lang('system_busy')); } return $this->toData('0', 'success'); } catch (\Exception $exception) { - return $this->toData('500', 'The system is busy.', [$exception->getMessage(), $exception->getLine(), $exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -1857,7 +1846,7 @@ class UserService extends BaseHomeService public function apiCalledRecord($userId, $param){ try { if (empty($param['api_name'])) { - return $this->toData('400', '参数错误'); + return $this->toData('400', lang('parameter_error')); } $apiName = trim($param['api_name']); $apiCalledNum = ApiCalledNumModel::where(['user_id'=>$userId])->find(); @@ -1871,7 +1860,7 @@ class UserService extends BaseHomeService } return $this->toData('0', 'success'); } catch (\Exception $exception) { - return $this->toData('500', 'The system is busy.', [$exception->getMessage(), $exception->getLine(), $exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -1880,7 +1869,7 @@ class UserService extends BaseHomeService { try { if (empty($param['api_name'])) { - return $this->toData('400', '参数错误'); + return $this->toData('400', lang('parameter_error')); } $apiCalledNum = ApiCalledNumModel::where(['user_id'=>$userId])->find(); $apiName = trim($param['api_name']); @@ -1895,7 +1884,7 @@ class UserService extends BaseHomeService } return $this->toData('0', 'success', ['is_called'=>true]); } catch (\Exception $exception) { - return $this->toData('500', 'The system is busy.', [$exception->getMessage(), $exception->getLine(), $exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } } diff --git a/app/home/service/UserVerifyService.php b/app/home/service/UserVerifyService.php index 21dd9b97..02032b9a 100644 --- a/app/home/service/UserVerifyService.php +++ b/app/home/service/UserVerifyService.php @@ -17,42 +17,42 @@ class UserVerifyService extends BaseHomeService try { // 参数校验 if(empty($params['surname']) || !is_string($params['surname'])){ - return $this->toData('400','surname 参数无效'); + return $this->toData('400', lang('parameter_error')); } if(empty($params['name']) || !is_string($params['name'])){ - return $this->toData('400','name 参数无效'); + return $this->toData('400', lang('parameter_error')); } if(empty($params['code']) || !is_string($params['code'])){ - return $this->toData('400','code 参数无效'); + return $this->toData('400', lang('parameter_error')); } if(empty($params['country']) || !is_numeric($params['country'])){ - return $this->toData('400','country 参数无效'); + return $this->toData('400', lang('parameter_error')); } if(empty($params['front_img'])){ - return $this->toData('400','front_img 参数无效'); + return $this->toData('400', lang('parameter_error')); } if (empty($params['birth_day'])) { - return $this->toData('400','birth_day 参数无效'); + return $this->toData('400', lang('parameter_error')); } if (empty($params['gender'])) { - return $this->toData('400','gender 参数无效'); - } - if (empty($params['addr'])) { - return $this->toData('400','addr 参数无效'); - } - if (empty($params['zip_code'])) { - return $this->toData('400','zip_code 参数无效'); + return $this->toData('400', lang('parameter_error')); } +// if (empty($params['addr'])) { +// return $this->toData('400','addr 参数无效'); +// } +// if (empty($params['zip_code'])) { +// return $this->toData('400','zip_code 参数无效'); +// } if (empty($params['email'])) { - return $this->toData('400','email 参数无效'); + return $this->toData('400', lang('parameter_error')); } if (empty($params['email_code'])) { - return $this->toData('400','email_code 参数无效'); + return $this->toData('400', lang('parameter_error')); } // if(empty($params['back_img']) || !is_numeric($params['back_img'])){ @@ -62,12 +62,12 @@ class UserVerifyService extends BaseHomeService // 判断用户状态 $user = UserModel::where('user_id', $userId)->find(); if(empty($user)){ - return $this->toData('500','用户数据为空'); + return $this->toData('500', lang('data_empty')); } // 判断是是否已经认证 if($user->is_real == 1){ - return $this->toData('500','Real name authentication has been passed'); + return $this->toData('500', lang('already_verified')); } // 是否是未认证或者认证失败状态 @@ -84,7 +84,7 @@ class UserVerifyService extends BaseHomeService $emailKey = 'USER:sendEmailLoginNoTrade:' . $params['email']; $cacheCode = Cache::store('redis')->get($emailKey); if (empty($cacheCode) || $cacheCode != $params['email_code']) { - return $this->toData('500','邮箱验证码不通过'); + return $this->toData('500', lang('incorrect_verification_code')); } // 写入数据库 @@ -100,8 +100,8 @@ class UserVerifyService extends BaseHomeService $userVerify->update_time = date('Y-m-d H:i:s'); $userVerify->birth_day = $params['birth_day']; $userVerify->gender = $params['gender']; - $userVerify->addr = $params['addr']; - $userVerify->zip_code = $params['zip_code']; +// $userVerify->addr = $params['addr']; +// $userVerify->zip_code = $params['zip_code']; $userVerify->email = $params['email']; $userVerify->save(); @@ -112,7 +112,7 @@ class UserVerifyService extends BaseHomeService return $this->toData('0','SUCCESS'); }catch (\Exception $exception){ - return $this->toData('100500','The system is busy.'); + return $this->toData('500', lang('system_busy')); } } @@ -121,11 +121,11 @@ class UserVerifyService extends BaseHomeService try { $user = UserModel::where('user_id', $userId)->find(); if(empty($user)){ - return $this->toData('500','用户数据为空'); + return $this->toData('500', lang('user_does_not_exist')); } $userVerify = UserVerifyLogModel::where('user_id', $userId)->order('id', 'desc')->find(); if (empty($userVerify)) { - return $this->toData('500','用户实名认证数据为空'); + return $this->toData('500', lang('user_real_name_authentication_data_is_empty')); } $data = $userVerify->toArray(); $front = AwsS3Model::where('id', $userVerify->front_img)->value('s3_url'); @@ -136,7 +136,7 @@ class UserVerifyService extends BaseHomeService $data['back_img'] = $back; return $this->toData('0', 'SUCCESS', $data); }catch (\Exception $exception){ - return $this->toData('100500','The system is busy.'); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } } \ No newline at end of file diff --git a/app/home/service/VideoService.php b/app/home/service/VideoService.php index 39ad5b56..8c4cfe4f 100644 --- a/app/home/service/VideoService.php +++ b/app/home/service/VideoService.php @@ -11,10 +11,10 @@ class VideoService extends BaseHomeService { try { if (empty($param['page']) || !is_numeric($param['page'])) { - return $this->toData('400', '参错错误'); + return $this->toData('400', lang('parameter_error')); } if (empty($param['limit']) || !is_numeric($param['limit'])) { - return $this->toData('400', '参错错误'); + return $this->toData('400', lang('parameter_error')); } $where = ['state'=>1]; @@ -30,14 +30,14 @@ class VideoService extends BaseHomeService 'page' => $param['page'], ]); - return $this->toData('0', 'Successful', [ + return $this->toData('0', 'successful', [ 'list' => $list->items(), // 当前页的数据 'page' => $list->currentPage(), // 当前页码 'total' => $list->total(), // 总记录数 'last_page' => $list->lastPage(), // 最后一页页码 ]); } catch (\Exception $exception) { - return $this->toData('500', 'The system is busy.', []); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -45,15 +45,15 @@ class VideoService extends BaseHomeService { try { if (empty($param['id']) || !is_numeric($param['id'])) { - return $this->toData('400', '参错错误'); + return $this->toData('400', lang('parameter_error')); } $info = VideoOnDemandModel::where(['id'=>$param['id']])->find(); if (empty($info)) { - return $this->toData('500', 'Successful', []); + return $this->toData('500', 'successful', []); } - return $this->toData('0', 'Successful', $info->toArray()); + return $this->toData('0', 'successful', $info->toArray()); } catch (\Exception $exception) { - return $this->toData('500', 'The system is busy.', []); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -62,9 +62,9 @@ class VideoService extends BaseHomeService { try { $list = BlockedWordModel::where(['state'=>1])->column(['word']); - return $this->toData('0', 'Successful', $list); + return $this->toData('0', 'successful', $list); } catch (\Exception $exception) { - return $this->toData('500', 'The system is busy.'); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } } \ No newline at end of file diff --git a/app/home/service/WalletService.php b/app/home/service/WalletService.php index f000098d..1a10ed0c 100644 --- a/app/home/service/WalletService.php +++ b/app/home/service/WalletService.php @@ -311,7 +311,7 @@ class WalletService extends BaseHomeService ]; break; } - return $this->toData(0, 'Request successful.', $result); + return $this->toData(0, 'successful', $result); } /** @@ -333,7 +333,7 @@ class WalletService extends BaseHomeService $message = $validateException->getMessage(); return $this->toData('1', $message, []); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy. Please try again later.', [$exception->getMessage(), $exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -355,7 +355,7 @@ class WalletService extends BaseHomeService $message = $validateException->getMessage(); return $this->toData('1', $message, []); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy. Please try again later.', [$exception->getMessage(), $exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } /** @@ -376,7 +376,7 @@ class WalletService extends BaseHomeService $message = $validateException->getMessage(); return $this->toData('1', $message, []); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy. Please try again later.', [$exception->getMessage(), $exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -398,7 +398,7 @@ class WalletService extends BaseHomeService $message = $validateException->getMessage(); return $this->toData('1', $message, []); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy. Please try again later.', [$exception->getMessage(), $exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -420,7 +420,7 @@ class WalletService extends BaseHomeService $message = $validateException->getMessage(); return $this->toData('1', $message, []); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy. Please try again later.', [$exception->getMessage(), $exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -442,7 +442,7 @@ class WalletService extends BaseHomeService $message = $validateException->getMessage(); return $this->toData('1', $message, []); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy. Please try again later.', [$exception->getMessage(), $exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -464,7 +464,7 @@ class WalletService extends BaseHomeService $message = $validateException->getMessage(); return $this->toData('1', $message, []); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy. Please try again later.', [$exception->getMessage(), $exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -481,7 +481,7 @@ class WalletService extends BaseHomeService $message = $validateException->getMessage(); return $this->toData('1', $message, []); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy. Please try again later.', [$exception->getMessage(), $exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -498,7 +498,7 @@ class WalletService extends BaseHomeService $message = $validateException->getMessage(); return $this->toData('1', $message, []); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy. Please try again later.', [$exception->getMessage(), $exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -520,7 +520,7 @@ class WalletService extends BaseHomeService $message = $validateException->getMessage(); return $this->toData('1', $message, []); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy. Please try again later.', [$exception->getMessage(), $exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -542,7 +542,7 @@ class WalletService extends BaseHomeService $message = $validateException->getMessage(); return $this->toData('1', $message, []); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy. Please try again later.', [$exception->getMessage(), $exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -564,7 +564,7 @@ class WalletService extends BaseHomeService $message = $validateException->getMessage(); return $this->toData('1', $message, []); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy. Please try again later.', [$exception->getMessage(), $exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -582,7 +582,7 @@ class WalletService extends BaseHomeService $message = $validateException->getMessage(); return $this->toData('1', $message, []); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy. Please try again later.', [$exception->getMessage(), $exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -604,7 +604,7 @@ class WalletService extends BaseHomeService $message = $validateException->getMessage(); return $this->toData('1', $message, []); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy. Please try again later.', [$exception->getMessage(), $exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } /** @@ -625,7 +625,7 @@ class WalletService extends BaseHomeService $message = $validateException->getMessage(); return $this->toData('1', $message, []); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy. Please try again later.', [$exception->getMessage(), $exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } private function getUserFurStock($data, int $type = 0): array @@ -641,7 +641,7 @@ class WalletService extends BaseHomeService $message = $validateException->getMessage(); return $this->toData('1', $message, []); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy. Please try again later.', [$exception->getMessage(), $exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } private function getUserEurStock($data, int $type = 0): array @@ -657,7 +657,7 @@ class WalletService extends BaseHomeService $message = $validateException->getMessage(); return $this->toData('1', $message, []); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy. Please try again later.', [$exception->getMessage(), $exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } private function getUserBrlStock($data, int $type = 0): array @@ -673,7 +673,7 @@ class WalletService extends BaseHomeService $message = $validateException->getMessage(); return $this->toData('1', $message, []); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy. Please try again later.', [$exception->getMessage(), $exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } private function getUserJpStock($data, int $type = 0): array @@ -689,7 +689,7 @@ class WalletService extends BaseHomeService $message = $validateException->getMessage(); return $this->toData('1', $message, []); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy. Please try again later.', [$exception->getMessage(), $exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -711,7 +711,7 @@ class WalletService extends BaseHomeService $message = $validateException->getMessage(); return $this->toData('1', $message, []); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy. Please try again later.', [$exception->getMessage(), $exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -730,7 +730,7 @@ class WalletService extends BaseHomeService $message = $validateException->getMessage(); return $this->toData('1', $message, []); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy. Please try again later.', [$exception->getMessage(), $exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -739,7 +739,7 @@ class WalletService extends BaseHomeService $list = WalletListModel::getUserWalletList([ 'wallet_type' => $data['wallet_type'] ]); - return $this->toData(0, 'Request successful.', $list); + return $this->toData(0, 'successful', $list); } /** @@ -757,7 +757,7 @@ class WalletService extends BaseHomeService $message = $validateException->getMessage(); return $this->toData('1', $message, []); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy. Please try again later.', [$exception->getMessage(), $exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -776,7 +776,7 @@ class WalletService extends BaseHomeService $message = $validateException->getMessage(); return $this->toData('1', $message, []); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy. Please try again later.', [$exception->getMessage(), $exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -801,7 +801,7 @@ class WalletService extends BaseHomeService $message = $validateException->getMessage(); return $this->toData('1', $message, []); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy. Please try again later.', [$exception->getMessage(), $exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -820,7 +820,7 @@ class WalletService extends BaseHomeService $message = $validateException->getMessage(); return $this->toData('1', $message, []); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy. Please try again later.', [$exception->getMessage(), $exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -840,7 +840,7 @@ class WalletService extends BaseHomeService $message = $validateException->getMessage(); return $this->toData('1', $message, []); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy. Please try again later.', [$exception->getMessage(), $exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -859,7 +859,7 @@ class WalletService extends BaseHomeService $message = $validateException->getMessage(); return $this->toData('1', $message, []); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy. Please try again later.', [$exception->getMessage(), $exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -882,7 +882,7 @@ class WalletService extends BaseHomeService $message = $validateException->getMessage(); return $this->toData('1', $message, []); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy. Please try again later.', [$exception->getMessage(), $exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -901,7 +901,7 @@ class WalletService extends BaseHomeService $message = $validateException->getMessage(); return $this->toData('1', $message, []); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy. Please try again later.', [$exception->getMessage(), $exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -1004,19 +1004,19 @@ class WalletService extends BaseHomeService $name = env('WALLET.NAME'); $user_info = UserModel::getFieldsByUserId('trade_password,is_real,status', $data['user_id']); if (empty($user_info['trade_password'])) { - return $this->toData(3, "Please set a transaction password first."); + return $this->toData(500, lang('please_set_the_transaction_password_first')); } if ($user_info['is_real'] == 0 && $name == 'STOCK') { - return $this->toData('20150', 'Please authenticate with real name first', []); + return $this->toData('500', lang('please_authenticate_with_real_name_first')); } $check_pwd = (new UnqId())->checkPassword($data['trade_pwd'], $user_info['trade_password'], $salt); if (!$check_pwd) { - return $this->toData(2, "Transaction password is incorrect."); + return $this->toData(500, lang('incorrect_transaction_password')); } // 检测是否被封禁提款 $accountFrozen = AccountFrozenModel::where('user_id', $data['user_id'])->findOrEmpty()->toArray(); if (isset($accountFrozen['frozen_withdraw']) && $accountFrozen['frozen_withdraw'] == 1) { - return $this->toData(2, "Withdrawals are frozen"); + return $this->toData(500, lang('withdrawal_is_frozen')); } $flag = $this->checkOnlyOneNotEmpty($data['bank_id'], $data['address_id'], $data['wallet_address']); if ($flag) { @@ -1033,7 +1033,7 @@ class WalletService extends BaseHomeService $pay_info['wallet_address'] = $data['wallet_address']; } if (empty($pay_info)) { - return $this->toData(1, 'The withdrawal information is incorrect.'); + return $this->toData(500, lang('incorrect_withdrawal_information')); } if ($data['account_type'] > 2 && ($data['account_type'] != 8)) { $market_rate = (new StockMarketModel())->getRate($data['account_type']); @@ -1063,7 +1063,7 @@ class WalletService extends BaseHomeService $cha_num = bcsub($from_account['usable_num'], $data['apply_num'], 18); //$from_account['usable_num']-$data['apply_num']; if ($cha_num < 0) { Db::rollback(); - return $this->toData(1, 'Insufficient balance.'); + return $this->toData(500, lang('insufficient_balance')); } //插入提款记录表 @@ -1096,15 +1096,15 @@ class WalletService extends BaseHomeService $res = $this->addUserBalanceLog($data['account_type'], $log_data); if (empty($res)) Db::rollback(); Db::commit(); - return $this->toData(0, 'Request successful.'); + return $this->toData(0, 'successful'); } catch (\Exception $exception) { // 回滚事务 Db::rollback(); - return $this->toData('100500', 'The system is busy. Please try again later.', [$exception->getMessage(), $exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } else { - return $this->toData(1, "Please fill in the parameters according to the requirements."); + return $this->toData(500, lang('system_busy')); } } @@ -1119,12 +1119,12 @@ class WalletService extends BaseHomeService 'status' => 5, 'update_time' => date('Y-m-d H:i:s') ]); - return $this->toData(0, 'Request successful.'); + return $this->toData(0, 'successful'); }else{ - return $this->toData(500, "System error."); + return $this->toData(500, lang('system_busy')); } } else { - return $this->toData(300, "Withdrawal orders cannot be cancelled."); + return $this->toData(500, lang('withdrawal_orders_cannot_be_cancelled')); } } private function checkOnlyOneNotEmpty($value1, $value2, $value3): bool @@ -1148,12 +1148,12 @@ class WalletService extends BaseHomeService try { validate(WalletValidate::class)->scene('getDrawalList')->check($data); $list = UserWithdrawalModel::getUserDrawalList($data); - return $this->toData(0, 'Request successful.', $list); + return $this->toData(0, 'successful', $list); } catch (ValidateException $validateException) { $message = $validateException->getMessage(); - return $this->toData('1', $message, []); + return $this->toData('500', $message, []); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy. Please try again later.', [$exception->getMessage(), $exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -1248,7 +1248,7 @@ class WalletService extends BaseHomeService $record_list =UserForexLogModel::getUserBalanceLog($data); break; default: - return $this->toData(1, "Please fill in the parameters according to the requirements."); + return $this->toData(400, lang('parameter_error')); break; } return $this->toData(0, "ok", $record_list); @@ -1264,7 +1264,7 @@ class WalletService extends BaseHomeService try { validate(WalletValidate::class)->scene('transfer')->check($data); if ($data['from_account'] == $data['to_account']) { - return $this->toData('2', 'The transfer out and transfer in accounts cannot be the same account.'); + return $this->toData('500', lang('the_transfer_out_account_and_the_transfer_in_account_cannot_be_the_same_account')); } //事务开启, 查询用户资金 Db::startTrans(); @@ -1281,7 +1281,7 @@ class WalletService extends BaseHomeService $cha_num = $from_account['usable_num'] - $data['change_num']; if ($cha_num < 0) { Db::rollback(); - return $this->toData(1, 'Insufficient balance.'); + return $this->toData(500, lang('insufficient_balance')); } $to_num = $this->getRateToTransfer([ @@ -1299,7 +1299,7 @@ class WalletService extends BaseHomeService $to_account = $this->lockUserBalance($data['to_account'], $data['user_id']); if (empty($to_account)) { Db::rollback(); - return $this->toData('2', 'error to_account '); + return $this->toData('500', lang('data_empty')); } @@ -1320,7 +1320,7 @@ class WalletService extends BaseHomeService $res = $this->updateUserBalance($data['from_account'], $from_update, $data['user_id']); if (empty($res)) { Db::rollback(); - return $this->toData('2', 'error from_account transfer'); + return $this->toData('500', lang('data_empty')); } // 新增转入 @@ -1328,7 +1328,7 @@ class WalletService extends BaseHomeService $res = $this->updateUserBalance($data['to_account'], $to_update, $data['user_id']); if (empty($res)) { Db::rollback(); - return $this->toData('2', 'error to_account transfer '); + return $this->toData('500', lang('data_empty')); } //变动类型:1-充值,2-提现,3-买入,4-卖出,5-冻结,6-解冻,7账户转出,8账户转入 @@ -1342,7 +1342,7 @@ class WalletService extends BaseHomeService $res = $this->addUserBalanceLog($data['from_account'], $from_log); if (empty($res)) { Db::rollback(); - return $this->toData('2', 'error from_log transfer'); + return $this->toData('500', lang('system_busy')); } @@ -1354,22 +1354,22 @@ class WalletService extends BaseHomeService $res = $this->addUserBalanceLog($data['to_account'], $to_log); if (empty($res)) { Db::rollback(); - return $this->toData('2', 'error to_log transfer'); + return $this->toData('500', lang('system_busy')); } Db::commit(); - return $this->toData(0, 'Request successful.'); + return $this->toData(0, 'successful'); } catch (\Exception $exception) { // 回滚事务 Db::rollback(); - return $this->toData('100500', 'The system is busy. Please try again later.', [$exception->getMessage(), $exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } catch (ValidateException $validateException) { $message = $validateException->getMessage(); return $this->toData('1', $message, []); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy. Please try again later.', [$exception->getMessage(), $exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } @@ -1678,7 +1678,7 @@ class WalletService extends BaseHomeService $message = $validateException->getMessage(); return $this->toData('1', $message, []); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy. Please try again later.', [$exception->getMessage(), $exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } public function userHasNotPay(array $data):array @@ -1708,7 +1708,7 @@ class WalletService extends BaseHomeService } } - return $this->toData(0, 'Request successful.', $list); + return $this->toData(0, 'successful', $list); } @@ -1720,11 +1720,10 @@ class WalletService extends BaseHomeService ->where('usable_num','>=',$total) ->find(); if(empty($res)){ - return $this->toData(1, 'The balance is not enough.'); + return $this->toData('500', lang('system_busy')); } - $order_list=UserArrearsModel::where('user_id',$data['user_id'])->where('account_type',$data['market_type'])->select(); $nowDate=date('Y-m-d H:i:s'); Db::startTrans(); @@ -1734,7 +1733,7 @@ class WalletService extends BaseHomeService ->update(['update_time' => $nowDate]); if(!$update_bool){ Db::rollback(); - return $this->toData('1', 'system error0', []); + return $this->toData('500', lang('system_busy')); } foreach ($order_list as $order){ @@ -1752,7 +1751,7 @@ class WalletService extends BaseHomeService $log_bool = Db::table($table_obj['log_table'])->insert($insertStockLogArr); if(!$log_bool){ Db::rollback(); - return $this->toData('1', 'system error1', []); + return $this->toData('500', lang('system_busy')); } // 生成扣手续流水 $insertStockLogArrFee = [ @@ -1777,7 +1776,7 @@ class WalletService extends BaseHomeService ]); if (!$status_bool) { Db::rollback(); - return $this->toData('1', 'system error2', []); + return $this->toData('500', lang('system_busy')); } //更新订单状态 if(env('USER_ARREARS.HAS_USER_ARREARS')==3){ @@ -1789,7 +1788,7 @@ class WalletService extends BaseHomeService ]); if (!$order_bool) { Db::rollback(); - return $this->toData('1', 'system error3'.Db::table($table_obj['order_table'])->getLastSql(), []); + return $this->toData('500', lang('system_busy')); } } @@ -1800,7 +1799,7 @@ class WalletService extends BaseHomeService Db::commit(); - return $this->toData(0, 'Request successful.',[]); + return $this->toData(0, 'successful'); } // 获取账户之间划转手续费 public function getRateToTransfer($data) @@ -1818,7 +1817,7 @@ class WalletService extends BaseHomeService } if ($fromAccount == $toAccount) { - return $this->toData('2', 'The transfer out and transfer in accounts cannot be the same account.'); + return $this->toData('500', lang('the_transfer_out_account_and_the_transfer_in_account_cannot_be_the_same_account')); } // 转出地址对美元的汇率 @@ -1826,11 +1825,11 @@ class WalletService extends BaseHomeService $toRate = (new StockMarketModel())->getRate($toAccount); if ($fromRate <= 0) { - return $this->toData('2', 'Transfer out account type is incorrect.'); + return $this->toData('500', lang('the_transfer_account_type_is_incorrect')); } if ($toRate <= 0) { - return $this->toData('2', 'Transfer in account type is incorrect.'); + return $this->toData('500', lang('incorrect_transfer_account_type')); } // 是否传递转账数量 @@ -1845,7 +1844,7 @@ class WalletService extends BaseHomeService 'to_change_num' => $toChangeNum ]); } catch (\Exception $exception) { - return $this->toData('100500', 'The system is busy. Please try again later.', [$exception->getMessage(), $exception->getTrace()]); + return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } diff --git a/app/model/StockMarketModel.php b/app/model/StockMarketModel.php index a08ae4e3..168de912 100644 --- a/app/model/StockMarketModel.php +++ b/app/model/StockMarketModel.php @@ -32,9 +32,9 @@ class StockMarketModel extends BaseModel const DIGITAL_MARKET = '1'; const CONTRACT_MARKET = '2'; const STOCK_MARKET_USA = '3'; + const STOCK_MARKET_YNG = '4'; const STOCK_MARKET_MG = '5'; const STOCK_MARKET_TG = '6'; - const STOCK_MARKET_YNG = '4'; const STOCK_MARKET_IN = '7'; const STOCK_MARKET_HY = '8'; const STOCK_MARKET_SGD = '9'; @@ -53,9 +53,9 @@ class StockMarketModel extends BaseModel self::DIGITAL_MARKET => '现货', self::CONTRACT_MARKET => '合约', self::STOCK_MARKET_USA => '美股', + self::STOCK_MARKET_YNG => '印尼股', self::STOCK_MARKET_MG => '马股', self::STOCK_MARKET_TG => '泰股', - self::STOCK_MARKET_YNG => '印尼股', self::STOCK_MARKET_IN => '印度股', self::STOCK_MARKET_HY => '秒合约', self::STOCK_MARKET_SGD => '新加坡股', @@ -71,6 +71,29 @@ class StockMarketModel extends BaseModel self::STOCK_INR_INDEX => '印度股指', ]; + // 各类型交易记录表 + const TRADE_TABLE = [ + self::DIGITAL_MARKET => 'bot_digital_trade', // 现货(数字币)交易记录表 + self::CONTRACT_MARKET => 'bot_contract_trade', // 合约交易记录表 + self::STOCK_MARKET_USA => 'bot_stock_trade', // 美股交易记录表 + self::STOCK_MARKET_YNG => 'bot_stock_idn_trade', // 印尼股交易记录表 + self::STOCK_MARKET_MG => 'bot_stock_mys_trade', // 马来股交易记录表 + self::STOCK_MARKET_TG => 'bot_stock_tha_trade', // 泰国股交易记录表 + self::STOCK_MARKET_IN => 'bot_stock_in_trade', // 印度股交易记录表 + self::STOCK_MARKET_HY => 'bot_contract_sec_trade', // 秒合约交易记录表 + self::STOCK_MARKET_SGD => 'bot_stock_sgd_trade', // 新加坡股交易记录表 + self::STOCK_MARKET_FUND => 'bot_user_fund_pre_stock_order', // 基金交易记录表 【注意:目前没有基金交易板块】 + self::STOCK_MARKET_OPTION_IN => 'bot_stock_option_inr_trade', // 印度期权交易记录表 + self::STOCK_MARKET_HK => 'bot_stock_hkd_trade', // 香港股交易记录表 + self::STOCK_MARKET_UK => 'bot_stock_gbx_trade', // 英国股交易记录表 + self::STOCK_MARKET_FUR => 'bot_stock_fur_trade', // 法国股交易记录表 + self::STOCK_MARKET_EUR => 'bot_stock_eur_trade', // 德国股交易记录表 + self::STOCK_MARKET_BRL => 'bot_stock_brl_trade', // 巴西股交易记录表 + self::STOCK_MARKET_JP => 'bot_stock_jp_trade', // 日本股交易记录表 + self::FOREX_MARKET => 'bot_forex_trade', // 外汇交易记录表 + self::STOCK_INR_INDEX => 'stock_index_inr_trade', // 印度股指交易记录表 + ]; + // 状态 const STATUS_NO = 1; const STATUS_OFF = 2; @@ -93,8 +116,6 @@ class StockMarketModel extends BaseModel $rate = StockMarketModel::where('stock_market_type', $accountType)->value('rate'); if(empty($rate) || $rate <= 0){ $rate = 0; - } else { // 没查到对应数据或者费率配置错误,默认设置rate=1 - $rate = 1; } return $rate; } @@ -115,4 +136,5 @@ class StockMarketModel extends BaseModel self::STOCK_MARKET_JP => StockJpListModel::$tapeList, ]; } + } \ No newline at end of file diff --git a/app/model/TradeNewListModel.php b/app/model/TradeNewListModel.php new file mode 100644 index 00000000..1d3a8e7a --- /dev/null +++ b/app/model/TradeNewListModel.php @@ -0,0 +1,7 @@ + env('PUSHER.SECRET_KEY'), ) ); - $publishResponse = $beamsClient->publishToInterests( + return $beamsClient->publishToInterests( $interest, // 兴趣名称最多100个 - array( - "fcm" => array( - "notification" => array( - "title" => $title, - "body" => $body - ) - ), - "apns" => array( - "aps" => array( - "alert" => array( + [ + "apns" => [ + "aps" => [ + "alert" => [ "title" => $title, "body" => $body - ) - )), - "web" => array( - "notification" => array( + ] + ] + ], + "fcm" => [ + "notification" => [ "title" => $title, "body" => $body -// "icon" => "", //显示同志时的图标 -// "deep_link" => "https://www.pusher.com", // 深层连接,点击通知时将在新选项卡中打开此连接 - ) - ) - ) + ] + ], + "web" => [ + "notification" => [ + "title" => $title, + "body" => $body + ] + ] + ] ); - return $publishResponse; } - // 发送到指定用户 - public function publishToUsers() + // 发送到指定用户, 用户列表必须是数组,最大长度1000个用户 + public function publishToUsers($userArr, $title, $body) { $beamsClient = new \Pusher\PushNotifications\PushNotifications( array( @@ -53,27 +52,31 @@ class Pusher extends BaseHomeService "secretKey" => env('PUSHER.SECRET_KEY'), ) ); - $publishResponse = $beamsClient->publishToUsers( - array("user-001", "user-002"), + return $beamsClient->publishToUsers( +// array("user-001", "user-002"), + $userArr, array( "fcm" => array( "notification" => array( - "title" => "Hi!", - "body" => "This is my first Push Notification!" + "title" => $title, + "body" => $body ) ), "apns" => array("aps" => array( "alert" => array( - "title" => "Hi!", - "body" => "This is my first Push Notification!" + "title" => $title, + "body" => $body ) )), "web" => array( "notification" => array( - "title" => "Hi!", - "body" => "This is my first Push Notification!" + "title" => $title, + "body" => $body ) ) - )); + ) + ); } + + } \ No newline at end of file diff --git a/config/lang.php b/config/lang.php index eaf2fdb5..6087631f 100644 --- a/config/lang.php +++ b/config/lang.php @@ -10,6 +10,7 @@ return [ 'allow_lang_list' => [ 'zh-cn', 'en-us', + 'zh-jp', ], // 多语言自动侦测变量名 'detect_var' => 'lang',