Browse Source

“language”

master
chuan 2 months ago
parent
commit
c88151f7be
  1. 164
      app/admin/controller/Index.php
  2. 6
      app/admin/controller/Order.php
  3. 1
      app/admin/controller/Test.php
  4. 7
      app/admin/route/app.php
  5. 8
      app/admin/service/AdminService.php
  6. 22
      app/admin/service/OrderService.php
  7. 6
      app/home/controller/Upload.php
  8. 59
      app/home/lang/zh-cn.php
  9. 60
      app/home/lang/zh-jp.php
  10. 60
      app/home/lang/zh-us.php
  11. 12
      app/home/middleware/AuthMiddleware.php
  12. 33
      app/home/service/BaseHomeService.php
  13. 2
      app/home/service/ConfigService.php
  14. 6
      app/home/service/DocumentService.php
  15. 42
      app/home/service/FundService.php
  16. 18
      app/home/service/IPOService.php
  17. 126
      app/home/service/LoginService.php
  18. 38
      app/home/service/MarketService.php
  19. 86
      app/home/service/PreHkdStockService.php
  20. 357
      app/home/service/UserService.php
  21. 48
      app/home/service/UserVerifyService.php
  22. 20
      app/home/service/VideoService.php
  23. 139
      app/home/service/WalletService.php
  24. 30
      app/model/StockMarketModel.php
  25. 7
      app/model/TradeNewListModel.php
  26. 7
      app/model/UserNoModel.php
  27. 63
      app/utility/Pusher.php
  28. 1
      config/lang.php

164
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()
{

6
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);
}
######################################## 现货交易 #######################################

1
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
{

7
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');

8
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();

22
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()]);
}
}
######################################## 现货交易 #######################################
// 现货持仓

6
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');

59
app/home/lang/zh-cn.php

@ -0,0 +1,59 @@
<?php
return [
'system_busy' => '系统繁忙',
'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' => '已存在申请记录,请等待审核',
];

60
app/home/lang/zh-jp.php

@ -0,0 +1,60 @@
<?php
return [
'system_busy' => 'システムがビジー状態です',
'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' => '申請記録があります。審査をお待ちください',
];

60
app/home/lang/zh-us.php

@ -0,0 +1,60 @@
<?php
return [
'system_busy' => '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',
];

12
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();
}
$header = $request->header();
if(!isset($header['language'])){
// 设置多语言
$request->lang = Config::get('lang.default_lang');
}else{
Config::set(['default_lang'=>'zh-jp'], 'lang');
$header = $request->header();
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;
}else{
$request->lang=Config::get('lang.default_lang');
Config::set(['default_lang'=>$lang], 'lang');
}
}
if(empty($header['token'])){
return json(['code' => '100403', 'message' => 'login please','data' => []]);
}

33
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;
}
/**

2
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();

6
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();

42
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', []);
}
//更新基金 已购买金额

18
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()]);
}
}

126
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'), []);
}
}

38
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);
}

86
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'));
}
}
}

357
app/home/service/UserService.php

File diff suppressed because it is too large

48
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()]);
}
}
}

20
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()]);
}
}
}

139
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()]);
}
}

30
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,
];
}
}

7
app/model/TradeNewListModel.php

@ -0,0 +1,7 @@
<?php
namespace app\model;
class TradeNewListModel extends BaseModel
{
protected $name = 'trade_new_list';
}

7
app/model/UserNoModel.php

@ -0,0 +1,7 @@
<?php
namespace app\model;
class UserNoModel extends BaseModel
{
protected $name = 'user_no';
}

63
app/utility/Pusher.php

@ -4,6 +4,7 @@ namespace app\utility;
use app\home\service\BaseHomeService;
use Pusher\PushNotifications\PushNotifications;
require_once __DIR__ . '/../../vendor/autoload.php';
class Pusher extends BaseHomeService
{
// 发送到所有订阅兴趣的客户端 $interest 必须是数组类型,可以包含多个兴趣名称
@ -15,37 +16,35 @@ class Pusher extends BaseHomeService
"secretKey" => env('PUSHER.SECRET_KEY'),
)
);
$publishResponse = $beamsClient->publishToInterests(
return $beamsClient->publishToInterests(
$interest, // 兴趣名称最多100个
array(
"fcm" => array(
"notification" => array(
[
"apns" => [
"aps" => [
"alert" => [
"title" => $title,
"body" => $body
)
),
"apns" => array(
"aps" => array(
"alert" => array(
]
]
],
"fcm" => [
"notification" => [
"title" => $title,
"body" => $body
)
)),
"web" => array(
"notification" => array(
]
],
"web" => [
"notification" => [
"title" => $title,
"body" => $body
// "icon" => "", //显示同志时的图标
// "deep_link" => "https://www.pusher.com", // 深层连接,点击通知时将在新选项卡中打开此连接
)
)
)
]
]
]
);
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
)
)
)
));
);
}
}

1
config/lang.php

@ -10,6 +10,7 @@ return [
'allow_lang_list' => [
'zh-cn',
'en-us',
'zh-jp',
],
// 多语言自动侦测变量名
'detect_var' => 'lang',

Loading…
Cancel
Save