mirror of
https://github.com/v2board/v2board.git
synced 2025-06-13 21:28:27 +08:00
update: language more
This commit is contained in:
@ -8,6 +8,7 @@ use App\Services\UserService;
|
||||
use App\Utils\Clash;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Server;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
class AppController extends Controller
|
||||
@ -25,7 +26,13 @@ class AppController extends Controller
|
||||
$serverService = new ServerService();
|
||||
$servers = $serverService->getAvailableServers($user);
|
||||
}
|
||||
$config = Yaml::parseFile(base_path() . '/resources/rules/app.clash.yaml');
|
||||
$defaultConfig = base_path() . '/resources/rules/app.clash.yaml';
|
||||
$customConfig = base_path() . '/resources/rules/custom.app.clash.yaml';
|
||||
if (File::exists($customConfig)) {
|
||||
$config = Yaml::parseFile($customConfig);
|
||||
} else {
|
||||
$config = Yaml::parseFile($defaultConfig);
|
||||
}
|
||||
$proxy = [];
|
||||
$proxies = [];
|
||||
|
||||
@ -84,62 +91,4 @@ class AppController extends Controller
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
public function config(Request $request)
|
||||
{
|
||||
if (empty($request->input('server_id'))) {
|
||||
abort(500, '参数错误');
|
||||
}
|
||||
$user = $request->user;
|
||||
if ($user->expired_at < time() && $user->expired_at !== NULL) {
|
||||
abort(500, '订阅计划已过期');
|
||||
}
|
||||
$server = Server::where('show', 1)
|
||||
->where('id', $request->input('server_id'))
|
||||
->first();
|
||||
if (!$server) {
|
||||
abort(500, '服务器不存在');
|
||||
}
|
||||
$json = json_decode(self::CLIENT_CONFIG);
|
||||
//socks
|
||||
$json->inbound->port = (int)self::SOCKS_PORT;
|
||||
//http
|
||||
$json->inboundDetour[0]->port = (int)self::HTTP_PORT;
|
||||
//other
|
||||
$json->outbound->settings->vnext[0]->address = (string)$server->host;
|
||||
$json->outbound->settings->vnext[0]->port = (int)$server->port;
|
||||
$json->outbound->settings->vnext[0]->users[0]->id = (string)$user->uuid;
|
||||
$json->outbound->settings->vnext[0]->users[0]->alterId = (int)$server->alter_id;
|
||||
$json->outbound->settings->vnext[0]->remark = (string)$server->name;
|
||||
$json->outbound->streamSettings->network = $server->network;
|
||||
if ($server->networkSettings) {
|
||||
switch ($server->network) {
|
||||
case 'tcp':
|
||||
$json->outbound->streamSettings->tcpSettings = json_decode($server->networkSettings);
|
||||
break;
|
||||
case 'kcp':
|
||||
$json->outbound->streamSettings->kcpSettings = json_decode($server->networkSettings);
|
||||
break;
|
||||
case 'ws':
|
||||
$json->outbound->streamSettings->wsSettings = json_decode($server->networkSettings);
|
||||
break;
|
||||
case 'http':
|
||||
$json->outbound->streamSettings->httpSettings = json_decode($server->networkSettings);
|
||||
break;
|
||||
case 'domainsocket':
|
||||
$json->outbound->streamSettings->dsSettings = json_decode($server->networkSettings);
|
||||
break;
|
||||
case 'quic':
|
||||
$json->outbound->streamSettings->quicSettings = json_decode($server->networkSettings);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($request->input('is_global')) {
|
||||
$json->routing->settings->rules[0]->outboundTag = 'proxy';
|
||||
}
|
||||
if ($server->tls) {
|
||||
$json->outbound->streamSettings->security = "tls";
|
||||
}
|
||||
die(json_encode($json, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ class AuthController extends Controller
|
||||
$recaptcha = new ReCaptcha(config('v2board.recaptcha_key'));
|
||||
$recaptchaResp = $recaptcha->verify($request->input('recaptcha_data'));
|
||||
if (!$recaptchaResp->isSuccess()) {
|
||||
abort(500, '验证码有误');
|
||||
abort(500, __('Invalid code is incorrect'));
|
||||
}
|
||||
}
|
||||
if ((int)config('v2board.email_whitelist_enable', 0)) {
|
||||
@ -32,36 +32,36 @@ class AuthController extends Controller
|
||||
$request->input('email'),
|
||||
config('v2board.email_whitelist_suffix', Dict::EMAIL_WHITELIST_SUFFIX_DEFAULT))
|
||||
) {
|
||||
abort(500, '邮箱后缀不处于白名单中');
|
||||
abort(500, __('Email suffix is not in the Whitelist'));
|
||||
}
|
||||
}
|
||||
if ((int)config('v2board.email_gmail_limit_enable', 0)) {
|
||||
$prefix = explode('@', $request->input('email'))[0];
|
||||
if (strpos($prefix, '.') !== false || strpos($prefix, '+') !== false) {
|
||||
abort(500, '不支持Gmail别名邮箱');
|
||||
abort(500, __('Gmail alias is not supported'));
|
||||
}
|
||||
}
|
||||
if ((int)config('v2board.stop_register', 0)) {
|
||||
abort(500, '本站已关闭注册');
|
||||
abort(500, __('Registration has closed'));
|
||||
}
|
||||
if ((int)config('v2board.invite_force', 0)) {
|
||||
if (empty($request->input('invite_code'))) {
|
||||
abort(500, '必须使用邀请码才可以注册');
|
||||
abort(500, __('You must use the invitation code to register'));
|
||||
}
|
||||
}
|
||||
if ((int)config('v2board.email_verify', 0)) {
|
||||
if (empty($request->input('email_code'))) {
|
||||
abort(500, '邮箱验证码不能为空');
|
||||
abort(500, __('Email verification code cannot be empty'));
|
||||
}
|
||||
if (Cache::get(CacheKey::get('EMAIL_VERIFY_CODE', $request->input('email'))) !== $request->input('email_code')) {
|
||||
abort(500, '邮箱验证码有误');
|
||||
abort(500, __('Incorrect email verification code'));
|
||||
}
|
||||
}
|
||||
$email = $request->input('email');
|
||||
$password = $request->input('password');
|
||||
$exist = User::where('email', $email)->first();
|
||||
if ($exist) {
|
||||
abort(500, '邮箱已存在系统中');
|
||||
abort(500, __('Email already exists'));
|
||||
}
|
||||
$user = new User();
|
||||
$user->email = $email;
|
||||
@ -74,7 +74,7 @@ class AuthController extends Controller
|
||||
->first();
|
||||
if (!$inviteCode) {
|
||||
if ((int)config('v2board.invite_force', 0)) {
|
||||
abort(500, '邀请码无效');
|
||||
abort(500, __('Invalid invitation code'));
|
||||
}
|
||||
} else {
|
||||
$user->invite_user_id = $inviteCode->user_id ? $inviteCode->user_id : null;
|
||||
@ -97,7 +97,7 @@ class AuthController extends Controller
|
||||
}
|
||||
|
||||
if (!$user->save()) {
|
||||
abort(500, '注册失败');
|
||||
abort(500, __('Register failed'));
|
||||
}
|
||||
if ((int)config('v2board.email_verify', 0)) {
|
||||
Cache::forget(CacheKey::get('EMAIL_VERIFY_CODE', $request->input('email')));
|
||||
@ -116,18 +116,18 @@ class AuthController extends Controller
|
||||
|
||||
$user = User::where('email', $email)->first();
|
||||
if (!$user) {
|
||||
abort(500, '用户名或密码错误');
|
||||
abort(500, __('Incorrect email or password'));
|
||||
}
|
||||
if (!Helper::multiPasswordVerify(
|
||||
$user->password_algo,
|
||||
$password,
|
||||
$user->password)
|
||||
) {
|
||||
abort(500, '用户名或密码错误');
|
||||
abort(500, __('Incorrect email or password'));
|
||||
}
|
||||
|
||||
if ($user->banned) {
|
||||
abort(500, '该账户已被停止使用');
|
||||
abort(500, __('Your account has been suspended'));
|
||||
}
|
||||
|
||||
$data = [
|
||||
@ -165,14 +165,14 @@ class AuthController extends Controller
|
||||
$key = CacheKey::get('TEMP_TOKEN', $request->input('verify'));
|
||||
$userId = Cache::get($key);
|
||||
if (!$userId) {
|
||||
abort(500, '令牌有误');
|
||||
abort(500, __('Token error'));
|
||||
}
|
||||
$user = User::find($userId);
|
||||
if (!$user) {
|
||||
abort(500, '用户不存在');
|
||||
abort(500, __('The user does not '));
|
||||
}
|
||||
if ($user->banned) {
|
||||
abort(500, '该账户已被停止使用');
|
||||
abort(500, __('Your account has been suspended'));
|
||||
}
|
||||
$request->session()->put('email', $user->email);
|
||||
$request->session()->put('id', $user->id);
|
||||
@ -190,7 +190,7 @@ class AuthController extends Controller
|
||||
{
|
||||
$user = User::where('token', $request->input('token'))->first();
|
||||
if (!$user) {
|
||||
abort(500, '令牌有误');
|
||||
abort(500, __('Token error'));
|
||||
}
|
||||
|
||||
$code = Helper::guid();
|
||||
@ -208,7 +208,7 @@ class AuthController extends Controller
|
||||
->where('password', $authData[1])
|
||||
->first();
|
||||
if (!$user) {
|
||||
abort(500, '令牌有误');
|
||||
abort(500, __('Token error'));
|
||||
}
|
||||
|
||||
$code = Helper::guid();
|
||||
@ -241,16 +241,16 @@ class AuthController extends Controller
|
||||
public function forget(AuthForget $request)
|
||||
{
|
||||
if (Cache::get(CacheKey::get('EMAIL_VERIFY_CODE', $request->input('email'))) !== $request->input('email_code')) {
|
||||
abort(500, '邮箱验证码有误');
|
||||
abort(500, __('Incorrect email verification code'));
|
||||
}
|
||||
$user = User::where('email', $request->input('email'))->first();
|
||||
if (!$user) {
|
||||
abort(500, '该邮箱不存在系统中');
|
||||
abort(500, __('This email is not registered in the system'));
|
||||
}
|
||||
$user->password = password_hash($request->input('password'), PASSWORD_DEFAULT);
|
||||
$user->password_algo = NULL;
|
||||
if (!$user->save()) {
|
||||
abort(500, '重置失败');
|
||||
abort(500, __('Reset failed'));
|
||||
}
|
||||
Cache::forget(CacheKey::get('EMAIL_VERIFY_CODE', $request->input('email')));
|
||||
return response([
|
||||
|
@ -47,15 +47,15 @@ class CommController extends Controller
|
||||
$recaptcha = new ReCaptcha(config('v2board.recaptcha_key'));
|
||||
$recaptchaResp = $recaptcha->verify($request->input('recaptcha_data'));
|
||||
if (!$recaptchaResp->isSuccess()) {
|
||||
abort(500, '验证码有误');
|
||||
abort(500, __('Invalid code is incorrect'));
|
||||
}
|
||||
}
|
||||
$email = $request->input('email');
|
||||
if (Cache::get(CacheKey::get('LAST_SEND_EMAIL_VERIFY_TIMESTAMP', $email))) {
|
||||
abort(500, '验证码已发送,请过一会再请求');
|
||||
abort(500, __('Email verification code has been sent, please request again later'));
|
||||
}
|
||||
$code = rand(100000, 999999);
|
||||
$subject = config('v2board.app_name', 'V2Board') . '邮箱验证码';
|
||||
$subject = config('v2board.app_name', 'V2Board') . __('Email verification code');
|
||||
|
||||
SendEmailJob::dispatch([
|
||||
'email' => $email,
|
||||
|
@ -11,25 +11,25 @@ class CouponController extends Controller
|
||||
public function check(Request $request)
|
||||
{
|
||||
if (empty($request->input('code'))) {
|
||||
abort(500, __('user.coupon.check.coupon_not_empty'));
|
||||
abort(500, __('Coupon cannot be empty'));
|
||||
}
|
||||
$coupon = Coupon::where('code', $request->input('code'))->first();
|
||||
if (!$coupon) {
|
||||
abort(500, __('user.coupon.check.coupon_invalid'));
|
||||
abort(500, __('Invalid coupon'));
|
||||
}
|
||||
if ($coupon->limit_use <= 0 && $coupon->limit_use !== NULL) {
|
||||
abort(500, __('user.coupon.check.coupon_not_available_by_number'));
|
||||
abort(500, __('This coupon is no longer available'));
|
||||
}
|
||||
if (time() < $coupon->started_at) {
|
||||
abort(500, __('user.coupon.check.coupon_not_available_by_time'));
|
||||
abort(500, __('This coupon has not yet started'));
|
||||
}
|
||||
if (time() > $coupon->ended_at) {
|
||||
abort(500, __('user.coupon.check.coupon_expired'));
|
||||
abort(500, __('This coupon has expired'));
|
||||
}
|
||||
if ($coupon->limit_plan_ids) {
|
||||
$limitPlanIds = json_decode($coupon->limit_plan_ids);
|
||||
if (!in_array($request->input('plan_id'), $limitPlanIds)) {
|
||||
abort(500, __('user.coupon.check.coupon_limit_plan'));
|
||||
abort(500, __('The coupon code cannot be used for this subscription'));
|
||||
}
|
||||
}
|
||||
return response([
|
||||
|
@ -14,7 +14,7 @@ class InviteController extends Controller
|
||||
public function save(Request $request)
|
||||
{
|
||||
if (InviteCode::where('user_id', $request->session()->get('id'))->where('status', 0)->count() >= config('v2board.invite_gen_limit', 5)) {
|
||||
abort(500, __('user.invite.save.invite_create_limit'));
|
||||
abort(500, __('The maximum number of creations has been reached'));
|
||||
}
|
||||
$inviteCode = new InviteCode();
|
||||
$inviteCode->user_id = $request->session()->get('id');
|
||||
|
@ -17,15 +17,15 @@ class KnowledgeController extends Controller
|
||||
->where('show', 1)
|
||||
->first()
|
||||
->toArray();
|
||||
if (!$knowledge) abort(500, __('user.knowledge.fetch.knowledge_not_exist'));
|
||||
if (!$knowledge) abort(500, __('Article does not exist'));
|
||||
$user = User::find($request->session()->get('id'));
|
||||
$userService = new UserService();
|
||||
if ($userService->isAvailable($user)) {
|
||||
$appleId = config('v2board.apple_id');
|
||||
$appleIdPassword = config('v2board.apple_id_password');
|
||||
} else {
|
||||
$appleId = __('user.knowledge.fetch.apple_id_must_be_plan');
|
||||
$appleIdPassword = __('user.knowledge.fetch.apple_id_must_be_plan');
|
||||
$appleId = __('No active subscription. Unable to use our provided Apple ID');
|
||||
$appleIdPassword = __('No active subscription. Unable to use our provided Apple ID');
|
||||
$this->formatAccessData($knowledge['body']);
|
||||
}
|
||||
$subscribeUrl = config('v2board.subscribe_url', config('v2board.app_url', env('APP_URL'))) . '/api/v1/client/subscribe?token=' . $user['token'];
|
||||
@ -63,7 +63,7 @@ class KnowledgeController extends Controller
|
||||
function getBetween($input, $start, $end){$substr = substr($input, strlen($start)+strpos($input, $start),(strlen($input) - strpos($input, $end))*(-1));return $substr;}
|
||||
$accessData = getBetween($body, '<!--access start-->', '<!--access end-->');
|
||||
if ($accessData) {
|
||||
$body = str_replace($accessData, '<div class="v2board-no-access">'. __('user.knowledge.formatAccessData.no_access') .'</div>', $body);
|
||||
$body = str_replace($accessData, '<div class="v2board-no-access">'. __('You must have a valid subscription to view content in this area') .'</div>', $body);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -52,12 +52,12 @@ class OrderController extends Controller
|
||||
->where('trade_no', $request->input('trade_no'))
|
||||
->first();
|
||||
if (!$order) {
|
||||
abort(500, __('user.order.details.order_not_exist'));
|
||||
abort(500, __('Order does not exist or has been paid'));
|
||||
}
|
||||
$order['plan'] = Plan::find($order->plan_id);
|
||||
$order['try_out_plan_id'] = (int)config('v2board.try_out_plan_id');
|
||||
if (!$order['plan']) {
|
||||
abort(500, __('user.order.details.plan_not_exist'));
|
||||
abort(500, __('Subscription plan does not exist'));
|
||||
}
|
||||
return response([
|
||||
'data' => $order
|
||||
@ -68,38 +68,38 @@ class OrderController extends Controller
|
||||
{
|
||||
$userService = new UserService();
|
||||
if ($userService->isNotCompleteOrderByUserId($request->session()->get('id'))) {
|
||||
abort(500, __('user.order.save.exist_open_order'));
|
||||
abort(500, __('You have an unpaid or pending order, please try again later or cancel it'));
|
||||
}
|
||||
|
||||
$plan = Plan::find($request->input('plan_id'));
|
||||
$user = User::find($request->session()->get('id'));
|
||||
|
||||
if (!$plan) {
|
||||
abort(500, __('user.order.save.plan_not_exist'));
|
||||
abort(500, __('Subscription plan does not exist'));
|
||||
}
|
||||
|
||||
if ((!$plan->show && !$plan->renew) || (!$plan->show && $user->plan_id !== $plan->id)) {
|
||||
if ($request->input('cycle') !== 'reset_price') {
|
||||
abort(500, __('user.order.save.plan_stop_sell'));
|
||||
abort(500, __('This subscription has been sold out, please choose another subscription'));
|
||||
}
|
||||
}
|
||||
|
||||
if (!$plan->renew && $user->plan_id == $plan->id && $request->input('cycle') !== 'reset_price') {
|
||||
abort(500, __('user.order.save.plan_stop_renew'));
|
||||
abort(500, __('This subscription cannot be renewed, please change to another subscription'));
|
||||
}
|
||||
|
||||
if ($plan[$request->input('cycle')] === NULL) {
|
||||
abort(500, __('user.order.save.plan_stop'));
|
||||
abort(500, __('This payment cycle cannot be purchased, please choose another cycle'));
|
||||
}
|
||||
|
||||
if ($request->input('cycle') === 'reset_price') {
|
||||
if ($user->expired_at <= time() || !$user->plan_id) {
|
||||
abort(500, __('user.order.save.plan_exist_not_buy_package'));
|
||||
abort(500, __('Subscription has expired or no active subscription, unable to purchase Data Reset Package'));
|
||||
}
|
||||
}
|
||||
|
||||
if (!$plan->show && $plan->renew && !$userService->isAvailable($user)) {
|
||||
abort(500, __('user.order.save.plan_expired'));
|
||||
abort(500, __('This subscription has expired, please change to another subscription'));
|
||||
}
|
||||
|
||||
DB::beginTransaction();
|
||||
@ -115,7 +115,7 @@ class OrderController extends Controller
|
||||
$couponService = new CouponService($request->input('coupon_code'));
|
||||
if (!$couponService->use($order)) {
|
||||
DB::rollBack();
|
||||
abort(500, __('user.order.save.coupon_use_failed'));
|
||||
abort(500, __('Coupon failed'));
|
||||
}
|
||||
$order->coupon_id = $couponService->getId();
|
||||
}
|
||||
@ -130,14 +130,14 @@ class OrderController extends Controller
|
||||
if ($remainingBalance > 0) {
|
||||
if (!$userService->addBalance($order->user_id, - $order->total_amount)) {
|
||||
DB::rollBack();
|
||||
abort(500, __('user.order.save.insufficient_balance'));
|
||||
abort(500, __('Insufficient balance'));
|
||||
}
|
||||
$order->balance_amount = $order->total_amount;
|
||||
$order->total_amount = 0;
|
||||
} else {
|
||||
if (!$userService->addBalance($order->user_id, - $user->balance)) {
|
||||
DB::rollBack();
|
||||
abort(500, __('user.order.save.insufficient_balance'));
|
||||
abort(500, __('Insufficient balance'));
|
||||
}
|
||||
$order->balance_amount = $user->balance;
|
||||
$order->total_amount = $order->total_amount - $user->balance;
|
||||
@ -146,7 +146,7 @@ class OrderController extends Controller
|
||||
|
||||
if (!$order->save()) {
|
||||
DB::rollback();
|
||||
abort(500, __('user.order.save.order_create_failed'));
|
||||
abort(500, __('Failed to create order'));
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
@ -165,7 +165,7 @@ class OrderController extends Controller
|
||||
->where('status', 0)
|
||||
->first();
|
||||
if (!$order) {
|
||||
abort(500, __('user.order.checkout.order_not_exist_or_paid'));
|
||||
abort(500, __('Order does not exist or has been paid'));
|
||||
}
|
||||
// free process
|
||||
if ($order->total_amount <= 0) {
|
||||
@ -178,7 +178,7 @@ class OrderController extends Controller
|
||||
]);
|
||||
}
|
||||
$payment = Payment::find($method);
|
||||
if (!$payment || $payment->enable !== 1) abort(500, __('user.order.checkout.pay_method_not_use'));
|
||||
if (!$payment || $payment->enable !== 1) abort(500, __('Payment method is not available'));
|
||||
$paymentService = new PaymentService($payment->payment, $payment->id);
|
||||
$result = $paymentService->pay([
|
||||
'trade_no' => $tradeNo,
|
||||
@ -200,7 +200,7 @@ class OrderController extends Controller
|
||||
->where('user_id', $request->session()->get('id'))
|
||||
->first();
|
||||
if (!$order) {
|
||||
abort(500, __('user.order.check.order_not_exist'));
|
||||
abort(500, __('Order does not exist'));
|
||||
}
|
||||
return response([
|
||||
'data' => $order->status
|
||||
@ -224,20 +224,20 @@ class OrderController extends Controller
|
||||
public function cancel(Request $request)
|
||||
{
|
||||
if (empty($request->input('trade_no'))) {
|
||||
abort(500, __('user.order.cancel.params_wrong'));
|
||||
abort(500, __('Invalid parameter'));
|
||||
}
|
||||
$order = Order::where('trade_no', $request->input('trade_no'))
|
||||
->where('user_id', $request->session()->get('id'))
|
||||
->first();
|
||||
if (!$order) {
|
||||
abort(500, __('user.order.cancel.order_not_exist'));
|
||||
abort(500, __('Order does not exist'));
|
||||
}
|
||||
if ($order->status !== 0) {
|
||||
abort(500, __('user.order.cancel.only_cancel_pending_order'));
|
||||
abort(500, __('You can only cancel pending orders'));
|
||||
}
|
||||
$orderService = new OrderService($order);
|
||||
if (!$orderService->cancel()) {
|
||||
abort(500, __('user.order.cancel.cancel_failed'));
|
||||
abort(500, __('Cancel failed'));
|
||||
}
|
||||
return response([
|
||||
'data' => true
|
||||
|
@ -14,7 +14,7 @@ class PlanController extends Controller
|
||||
$plan = Plan::where('id', $request->input('id'))
|
||||
->first();
|
||||
if (!$plan) {
|
||||
abort(500, __('user.plan.fetch.plan_not_exist'));
|
||||
abort(500, __('Subscription plan does not exist'));
|
||||
}
|
||||
return response([
|
||||
'data' => $plan
|
||||
|
@ -3,7 +3,9 @@
|
||||
namespace App\Http\Controllers\User;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\User;
|
||||
use App\Services\TelegramService;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TelegramController extends Controller
|
||||
{
|
||||
@ -17,4 +19,9 @@ class TelegramController extends Controller
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
public function unbind(Request $request)
|
||||
{
|
||||
$user = User::where('user_id', $request->session()->get('id'))->first();
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ class TicketController extends Controller
|
||||
->where('user_id', $request->session()->get('id'))
|
||||
->first();
|
||||
if (!$ticket) {
|
||||
abort(500, __('user.ticket.fetch.ticket_not_exist'));
|
||||
abort(500, __('Ticket does not exist'));
|
||||
}
|
||||
$ticket['message'] = TicketMessage::where('ticket_id', $ticket->id)->get();
|
||||
for ($i = 0; $i < count($ticket['message']); $i++) {
|
||||
@ -56,7 +56,7 @@ class TicketController extends Controller
|
||||
{
|
||||
DB::beginTransaction();
|
||||
if ((int)Ticket::where('status', 0)->where('user_id', $request->session()->get('id'))->count()) {
|
||||
abort(500, __('user.ticket.save.exist_other_open_ticket'));
|
||||
abort(500, __('There are other unresolved tickets'));
|
||||
}
|
||||
$ticket = Ticket::create(array_merge($request->only([
|
||||
'subject',
|
||||
@ -67,7 +67,7 @@ class TicketController extends Controller
|
||||
]));
|
||||
if (!$ticket) {
|
||||
DB::rollback();
|
||||
abort(500, __('user.ticket.save.ticket_create_failed'));
|
||||
abort(500, __('Failed to open ticket'));
|
||||
}
|
||||
$ticketMessage = TicketMessage::create([
|
||||
'user_id' => $request->session()->get('id'),
|
||||
@ -76,7 +76,7 @@ class TicketController extends Controller
|
||||
]);
|
||||
if (!$ticketMessage) {
|
||||
DB::rollback();
|
||||
abort(500, __('user.ticket.save.ticket_create_failed'));
|
||||
abort(500, __('Failed to open ticket'));
|
||||
}
|
||||
DB::commit();
|
||||
$this->sendNotify($ticket, $ticketMessage);
|
||||
@ -88,22 +88,22 @@ class TicketController extends Controller
|
||||
public function reply(Request $request)
|
||||
{
|
||||
if (empty($request->input('id'))) {
|
||||
abort(500, __('user.ticket.reply.params_wrong'));
|
||||
abort(500, __('Invalid parameter'));
|
||||
}
|
||||
if (empty($request->input('message'))) {
|
||||
abort(500, __('user.ticket.reply.message_not_empty'));
|
||||
abort(500, __('Message cannot be empty'));
|
||||
}
|
||||
$ticket = Ticket::where('id', $request->input('id'))
|
||||
->where('user_id', $request->session()->get('id'))
|
||||
->first();
|
||||
if (!$ticket) {
|
||||
abort(500, __('user.ticket.reply.ticket_not_exist'));
|
||||
abort(500, __('Ticket does not exist'));
|
||||
}
|
||||
if ($ticket->status) {
|
||||
abort(500, __('user.ticket.reply.ticket_close_not_reply'));
|
||||
abort(500, __('The ticket is closed and cannot be replied'));
|
||||
}
|
||||
if ($request->session()->get('id') == $this->getLastMessage($ticket->id)->user_id) {
|
||||
abort(500, __('user.ticket.reply.wait_reply'));
|
||||
abort(500, __('Please wait for the technical enginneer to reply'));
|
||||
}
|
||||
DB::beginTransaction();
|
||||
$ticketMessage = TicketMessage::create([
|
||||
@ -114,7 +114,7 @@ class TicketController extends Controller
|
||||
$ticket->last_reply_user_id = $request->session()->get('id');
|
||||
if (!$ticketMessage || !$ticket->save()) {
|
||||
DB::rollback();
|
||||
abort(500, __('user.ticket.reply.ticket_reply_failed'));
|
||||
abort(500, __('Ticket reply failed'));
|
||||
}
|
||||
DB::commit();
|
||||
$this->sendNotify($ticket, $ticketMessage);
|
||||
@ -127,17 +127,17 @@ class TicketController extends Controller
|
||||
public function close(Request $request)
|
||||
{
|
||||
if (empty($request->input('id'))) {
|
||||
abort(500, __('user.ticket.close.params_wrong'));
|
||||
abort(500, __('Invalid parameter'));
|
||||
}
|
||||
$ticket = Ticket::where('id', $request->input('id'))
|
||||
->where('user_id', $request->session()->get('id'))
|
||||
->first();
|
||||
if (!$ticket) {
|
||||
abort(500, __('user.ticket.close.ticket_not_exist'));
|
||||
abort(500, __('Ticket does not exist'));
|
||||
}
|
||||
$ticket->status = 1;
|
||||
if (!$ticket->save()) {
|
||||
abort(500, __('user.ticket.close.close_failed'));
|
||||
abort(500, __('Close failed'));
|
||||
}
|
||||
return response([
|
||||
'data' => true
|
||||
@ -163,15 +163,15 @@ class TicketController extends Controller
|
||||
Dict::WITHDRAW_METHOD_WHITELIST_DEFAULT
|
||||
)
|
||||
)) {
|
||||
abort(500, __('user.ticket.withdraw.not_support_withdraw_method'));
|
||||
abort(500, __('Unsupported withdrawal method'));
|
||||
}
|
||||
$user = User::find($request->session()->get('id'));
|
||||
$limit = config('v2board.commission_withdraw_limit', 100);
|
||||
if ($limit > ($user->commission_balance / 100)) {
|
||||
abort(500, __('user.ticket.withdraw.system_require_withdraw_limit', ['limit' => $limit]));
|
||||
abort(500, __('The current required minimum withdrawal commission is', ['limit' => $limit]));
|
||||
}
|
||||
DB::beginTransaction();
|
||||
$subject = __('user.ticket.withdraw.ticket_subject');
|
||||
$subject = __('[Commission Withdrawal Request] This ticket is opened by the system');
|
||||
$ticket = Ticket::create([
|
||||
'subject' => $subject,
|
||||
'level' => 2,
|
||||
@ -180,12 +180,12 @@ class TicketController extends Controller
|
||||
]);
|
||||
if (!$ticket) {
|
||||
DB::rollback();
|
||||
abort(500, __('user.ticket.withdraw.ticket_create_failed'));
|
||||
abort(500, __('Failed to open ticket'));
|
||||
}
|
||||
$message = __('user.ticket.withdraw.ticket_message', [
|
||||
'method' => $request->input('withdraw_method'),
|
||||
'account' => $request->input('withdraw_account')
|
||||
]);
|
||||
$message = sprintf("%s\r\n%s",
|
||||
__('Withdrawal method') . ":" . $request->input('withdraw_method'),
|
||||
__('Withdrawal account') . ":" . $request->input('withdraw_account')
|
||||
);
|
||||
$ticketMessage = TicketMessage::create([
|
||||
'user_id' => $request->session()->get('id'),
|
||||
'ticket_id' => $ticket->id,
|
||||
@ -193,7 +193,7 @@ class TicketController extends Controller
|
||||
]);
|
||||
if (!$ticketMessage) {
|
||||
DB::rollback();
|
||||
abort(500, __('user.ticket.withdraw.ticket_create_failed'));
|
||||
abort(500, __('Failed to open ticket'));
|
||||
}
|
||||
DB::commit();
|
||||
$this->sendNotify($ticket, $ticketMessage);
|
||||
|
@ -29,19 +29,19 @@ class UserController extends Controller
|
||||
{
|
||||
$user = User::find($request->session()->get('id'));
|
||||
if (!$user) {
|
||||
abort(500, __('user.user.changePassword.user_not_exist'));
|
||||
abort(500, __('The user does not exist'));
|
||||
}
|
||||
if (!Helper::multiPasswordVerify(
|
||||
$user->password_algo,
|
||||
$request->input('old_password'),
|
||||
$user->password)
|
||||
) {
|
||||
abort(500, __('user.user.changePassword.old_password_wrong'));
|
||||
abort(500, __('The old password is wrong'));
|
||||
}
|
||||
$user->password = password_hash($request->input('new_password'), PASSWORD_DEFAULT);
|
||||
$user->password_algo = NULL;
|
||||
if (!$user->save()) {
|
||||
abort(500, __('user.user.changePassword.save_failed'));
|
||||
abort(500, __('Save failed'));
|
||||
}
|
||||
$request->session()->flush();
|
||||
return response([
|
||||
@ -70,7 +70,7 @@ class UserController extends Controller
|
||||
])
|
||||
->first();
|
||||
if (!$user) {
|
||||
abort(500, __('user.user.info.user_not_exist'));
|
||||
abort(500, __('The user does not exist'));
|
||||
}
|
||||
$user['avatar_url'] = 'https://cdn.v2ex.com/gravatar/' . md5($user->email) . '?s=64&d=identicon';
|
||||
return response([
|
||||
@ -110,12 +110,12 @@ class UserController extends Controller
|
||||
])
|
||||
->first();
|
||||
if (!$user) {
|
||||
abort(500, __('user.user.getSubscribe.user_not_exist'));
|
||||
abort(500, __('The user does not exist'));
|
||||
}
|
||||
if ($user->plan_id) {
|
||||
$user['plan'] = Plan::find($user->plan_id);
|
||||
if (!$user['plan']) {
|
||||
abort(500, __('user.user.getSubscribe.plan_not_exist'));
|
||||
abort(500, __('Subscription plan does not exist'));
|
||||
}
|
||||
}
|
||||
$user['subscribe_url'] = config('v2board.subscribe_url', config('v2board.app_url', env('APP_URL'))) . '/api/v1/client/subscribe?token=' . $user['token'];
|
||||
@ -129,12 +129,12 @@ class UserController extends Controller
|
||||
{
|
||||
$user = User::find($request->session()->get('id'));
|
||||
if (!$user) {
|
||||
abort(500, __('user.user.resetSecurity.user_not_exist'));
|
||||
abort(500, __('The user does not exist'));
|
||||
}
|
||||
$user->uuid = Helper::guid(true);
|
||||
$user->token = Helper::guid();
|
||||
if (!$user->save()) {
|
||||
abort(500, __('user.user.resetSecurity.reset_failed'));
|
||||
abort(500, __('Reset failed'));
|
||||
}
|
||||
return response([
|
||||
'data' => config('v2board.subscribe_url', config('v2board.app_url', env('APP_URL'))) . '/api/v1/client/subscribe?token=' . $user->token
|
||||
@ -150,12 +150,12 @@ class UserController extends Controller
|
||||
|
||||
$user = User::find($request->session()->get('id'));
|
||||
if (!$user) {
|
||||
abort(500, __('user.user.update.user_not_exist'));
|
||||
abort(500, __('The user does not exist'));
|
||||
}
|
||||
try {
|
||||
$user->update($updateData);
|
||||
} catch (\Exception $e) {
|
||||
abort(500, __('user.user.update.save_failed'));
|
||||
abort(500, __('Save failed'));
|
||||
}
|
||||
|
||||
return response([
|
||||
@ -167,15 +167,15 @@ class UserController extends Controller
|
||||
{
|
||||
$user = User::find($request->session()->get('id'));
|
||||
if (!$user) {
|
||||
abort(500, __('user.user.transfer.user_not_exist'));
|
||||
abort(500, __('The user does not exist'));
|
||||
}
|
||||
if ($request->input('transfer_amount') > $user->commission_balance) {
|
||||
abort(500, __('user.user.transfer.insufficient_commission_balance'));
|
||||
abort(500, __('Insufficient commission balance'));
|
||||
}
|
||||
$user->commission_balance = $user->commission_balance - $request->input('transfer_amount');
|
||||
$user->balance = $user->balance + $request->input('transfer_amount');
|
||||
if (!$user->save()) {
|
||||
abort(500, __('user.user.transfer.transfer_failed'));
|
||||
abort(500, __('Transfer failed'));
|
||||
}
|
||||
return response([
|
||||
'data' => true
|
||||
|
@ -23,11 +23,11 @@ class AuthForget extends FormRequest
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'email.required' => '邮箱不能为空',
|
||||
'email.email' => '邮箱格式不正确',
|
||||
'password.required' => '密码不能为空',
|
||||
'password.min' => '密码必须大于8位数',
|
||||
'email_code.required' => '邮箱验证码不能为空'
|
||||
'email.required' => __('Email can not be empty'),
|
||||
'email.email' => __('Email format is incorrect'),
|
||||
'password.required' => __('Password can not be empty'),
|
||||
'password.min' => __('Password must be greater than 8 digits'),
|
||||
'email_code.required' => __('Email verification code cannot be empty')
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -22,10 +22,10 @@ class AuthLogin extends FormRequest
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'email.required' => '邮箱不能为空',
|
||||
'email.email' => '邮箱格式不正确',
|
||||
'password.required' => '密码不能为空',
|
||||
'password.min' => '密码必须大于8位数'
|
||||
'email.required' => __('Email can not be empty'),
|
||||
'email.email' => __('Email format is incorrect'),
|
||||
'password.required' => __('Password can not be empty'),
|
||||
'password.min' => __('Password must be greater than 8 digits')
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -22,10 +22,10 @@ class AuthRegister extends FormRequest
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'email.required' => '邮箱不能为空',
|
||||
'email.email' => '邮箱格式不正确',
|
||||
'password.required' => '密码不能为空',
|
||||
'password.min' => '密码必须大于8位数'
|
||||
'email.required' => __('Email can not be empty'),
|
||||
'email.email' => __('Email format is incorrect'),
|
||||
'password.required' => __('Password can not be empty'),
|
||||
'password.min' => __('Password must be greater than 8 digits')
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -21,8 +21,8 @@ class CommSendEmailVerify extends FormRequest
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'email.required' => '邮箱不能为空',
|
||||
'email.email' => '邮箱格式不正确'
|
||||
'email.required' => __('Email can not be empty'),
|
||||
'email.email' => __('Email format is incorrect')
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -22,9 +22,9 @@ class OrderSave extends FormRequest
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'plan_id.required' => '套餐ID不能为空',
|
||||
'cycle.required' => '套餐周期不能为空',
|
||||
'cycle.in' => '套餐周期有误'
|
||||
'plan_id.required' => __('Plan ID cannot be empty'),
|
||||
'cycle.required' => __('Plan cycle cannot be empty'),
|
||||
'cycle.in' => __('Wrong plan cycle')
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -23,10 +23,10 @@ class TicketSave extends FormRequest
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'subject.required' => '工单主题不能为空',
|
||||
'level.required' => '工单级别不能为空',
|
||||
'level.in' => '工单级别格式不正确',
|
||||
'message.required' => '消息不能为空'
|
||||
'subject.required' => __('Ticket subject cannot be empty'),
|
||||
'level.required' => __('Ticket level cannot be empty'),
|
||||
'level.in' => __('Incorrect ticket level format'),
|
||||
'message.required' => __('Message cannot be empty')
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -22,9 +22,8 @@ class TicketWithdraw extends FormRequest
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'withdraw_method.required' => '提现方式不能为空',
|
||||
'withdraw_method.in' => '提现方式不支持',
|
||||
'withdraw_account.required' => '提现账号不能为空'
|
||||
'withdraw_method.required' => __('The withdrawal method cannot be empty'),
|
||||
'withdraw_account.required' => __('The withdrawal account cannot be empty')
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -22,9 +22,9 @@ class UserChangePassword extends FormRequest
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'old_password.required' => '旧密码不能为空',
|
||||
'new_password.required' => '新密码不能为空',
|
||||
'new_password.min' => '密码必须大于8位数'
|
||||
'old_password.required' => __('Old password cannot be empty'),
|
||||
'new_password.required' => __('New password cannot be empty'),
|
||||
'new_password.min' => __('Password must be greater than 8 digits')
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -21,9 +21,9 @@ class UserTransfer extends FormRequest
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'transfer_amount.required' => '划转金额不能为空',
|
||||
'transfer_amount.integer' => __('user.user.transfer.params_wrong'),
|
||||
'transfer_amount.min' => __('user.user.transfer.params_wrong')
|
||||
'transfer_amount.required' => __('The transfer amount cannot be empty'),
|
||||
'transfer_amount.integer' => __('The transfer amount parameter is wrong'),
|
||||
'transfer_amount.min' => __('The transfer amount parameter is wrong')
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -22,8 +22,8 @@ class UserUpdate extends FormRequest
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'show.in' => '过期提醒格式不正确',
|
||||
'renew.in' => '流量提醒格式不正确'
|
||||
'show.in' => __('Incorrect format of expiration reminder'),
|
||||
'renew.in' => __('Incorrect traffic alert format')
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user