mirror of
				https://github.com/v2board/v2board.git
				synced 2025-10-30 17:02:04 +08:00 
			
		
		
		
	update: backend language and order result page
This commit is contained in:
		| @@ -20,6 +20,7 @@ class AuthController extends Controller | ||||
| { | ||||
|     public function register(AuthRegister $request) | ||||
|     { | ||||
|         abort(500, __('passport.auth.register.verify_incorrect')); | ||||
|         if ((int)config('v2board.recaptcha_enable', 0)) { | ||||
|             $recaptcha = new ReCaptcha(config('v2board.recaptcha_key')); | ||||
|             $recaptchaResp = $recaptcha->verify($request->input('recaptcha_data')); | ||||
|   | ||||
| @@ -11,25 +11,25 @@ class CouponController extends Controller | ||||
|     public function check(Request $request) | ||||
|     { | ||||
|         if (empty($request->input('code'))) { | ||||
|             abort(500, '优惠券码不能为空'); | ||||
|             abort(500, __('user.coupon.check.coupon_not_empty')); | ||||
|         } | ||||
|         $coupon = Coupon::where('code', $request->input('code'))->first(); | ||||
|         if (!$coupon) { | ||||
|             abort(500, '优惠券无效'); | ||||
|             abort(500, __('user.coupon.check.coupon_invalid')); | ||||
|         } | ||||
|         if ($coupon->limit_use <= 0 && $coupon->limit_use !== NULL) { | ||||
|             abort(500, '优惠券已无可用次数'); | ||||
|             abort(500, __('user.coupon.check.coupon_not_available_by_number')); | ||||
|         } | ||||
|         if (time() < $coupon->started_at) { | ||||
|             abort(500, '优惠券还未到可用时间'); | ||||
|             abort(500, __('user.coupon.check.coupon_not_available_by_time')); | ||||
|         } | ||||
|         if (time() > $coupon->ended_at) { | ||||
|             abort(500, '优惠券已过期'); | ||||
|             abort(500, __('user.coupon.check.coupon_expired')); | ||||
|         } | ||||
|         if ($coupon->limit_plan_ids) { | ||||
|             $limitPlanIds = json_decode($coupon->limit_plan_ids); | ||||
|             if (!in_array($request->input('plan_id'), $limitPlanIds)) { | ||||
|                 abort(500, '这个计划无法使用该优惠码'); | ||||
|                 abort(500, __('user.coupon.check.coupon_limit_plan')); | ||||
|             } | ||||
|         } | ||||
|         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, '已达到创建数量上限'); | ||||
|             abort(500, __('user.invite.save.invite_create_limit')); | ||||
|         } | ||||
|         $inviteCode = new InviteCode(); | ||||
|         $inviteCode->user_id = $request->session()->get('id'); | ||||
|   | ||||
| @@ -17,11 +17,11 @@ class KnowledgeController extends Controller | ||||
|                 ->where('show', 1) | ||||
|                 ->first() | ||||
|                 ->toArray(); | ||||
|             if (!$knowledge) abort(500, '知识不存在'); | ||||
|             if (!$knowledge) abort(500, __('user.knowledge.fetch.knowledge_not_exist')); | ||||
|             $user = User::find($request->session()->get('id')); | ||||
|             $userService = new UserService(); | ||||
|             $appleId = $userService->isAvailable($user) ? config('v2board.apple_id') : '没有有效订阅无法使用本站提供的AppleID'; | ||||
|             $appleIdPassword = $userService->isAvailable($user) ? config('v2board.apple_id_password') : '没有有效订阅无法使用本站提供的AppleID'; | ||||
|             $appleId = $userService->isAvailable($user) ? config('v2board.apple_id') : __('user.knowledge.fetch.apple_id_must_be_plan'); | ||||
|             $appleIdPassword = $userService->isAvailable($user) ? config('v2board.apple_id_password') : __('user.knowledge.fetch.apple_id_must_be_plan'); | ||||
|             $subscribeUrl = config('v2board.subscribe_url', config('v2board.app_url', env('APP_URL'))) . '/api/v1/client/subscribe?token=' . $user['token']; | ||||
|             $knowledge['body'] = str_replace('{{siteName}}', config('v2board.app_name', 'V2Board'), $knowledge['body']); | ||||
|             $knowledge['body'] = str_replace('{{appleId}}', $appleId, $knowledge['body']); | ||||
|   | ||||
| @@ -50,12 +50,12 @@ class OrderController extends Controller | ||||
|             ->where('trade_no', $request->input('trade_no')) | ||||
|             ->first(); | ||||
|         if (!$order) { | ||||
|             abort(500, '订单不存在'); | ||||
|             abort(500, __('user.order.details.order_not_exist')); | ||||
|         } | ||||
|         $order['plan'] = Plan::find($order->plan_id); | ||||
|         $order['try_out_plan_id'] = (int)config('v2board.try_out_plan_id'); | ||||
|         if (!$order['plan']) { | ||||
|             abort(500, '订阅不存在'); | ||||
|             abort(500, __('user.order.details.plan_not_exist')); | ||||
|         } | ||||
|         return response([ | ||||
|             'data' => $order | ||||
| @@ -66,38 +66,38 @@ class OrderController extends Controller | ||||
|     { | ||||
|         $userService = new UserService(); | ||||
|         if ($userService->isNotCompleteOrderByUserId($request->session()->get('id'))) { | ||||
|             abort(500, '您有未付款或开通中的订单,请稍后或取消再试'); | ||||
|             abort(500, __('user.order.save.exist_open_order')); | ||||
|         } | ||||
|  | ||||
|         $plan = Plan::find($request->input('plan_id')); | ||||
|         $user = User::find($request->session()->get('id')); | ||||
|  | ||||
|         if (!$plan) { | ||||
|             abort(500, '该订阅不存在'); | ||||
|             abort(500, __('user.order.save.plan_not_exist')); | ||||
|         } | ||||
|  | ||||
|         if ((!$plan->show && !$plan->renew) || (!$plan->show && $user->plan_id !== $plan->id)) { | ||||
|             if ($request->input('cycle') !== 'reset_price') { | ||||
|                 abort(500, '该订阅已售罄,请更换其他订阅'); | ||||
|                 abort(500, __('user.order.save.plan_stop_sell')); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         if (!$plan->renew && $user->plan_id == $plan->id && $request->input('cycle') !== 'reset_price') { | ||||
|             abort(500, '该订阅无法续费,请更换其他订阅'); | ||||
|             abort(500, __('user.order.save.plan_stop_renew')); | ||||
|         } | ||||
|  | ||||
|         if ($plan[$request->input('cycle')] === NULL) { | ||||
|             abort(500, '该订阅周期无法进行购买,请选择其他周期'); | ||||
|             abort(500, __('user.order.save.plan_stop')); | ||||
|         } | ||||
|  | ||||
|         if ($request->input('cycle') === 'reset_price') { | ||||
|             if ($user->expired_at <= time() || !$user->plan_id) { | ||||
|                 abort(500, '订阅已过期或无有效订阅,无法购买重置包'); | ||||
|                 abort(500, __('user.order.save.plan_exist_not_buy_package')); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         if (!$plan->show && $plan->renew && !$userService->isAvailable($user)) { | ||||
|             abort(500, '订阅已过期,请更换其他订阅'); | ||||
|             abort(500, __('user.order.save.plan_expired')); | ||||
|         } | ||||
|  | ||||
|         DB::beginTransaction(); | ||||
| @@ -113,7 +113,7 @@ class OrderController extends Controller | ||||
|             $couponService = new CouponService($request->input('coupon_code')); | ||||
|             if (!$couponService->use($order)) { | ||||
|                 DB::rollBack(); | ||||
|                 abort(500, '优惠券使用失败'); | ||||
|                 abort(500, __('user.order.save.coupon_use_failed')); | ||||
|             } | ||||
|             $order->coupon_id = $couponService->getId(); | ||||
|         } | ||||
| @@ -128,14 +128,14 @@ class OrderController extends Controller | ||||
|             if ($remainingBalance > 0) { | ||||
|                 if (!$userService->addBalance($order->user_id, - $order->total_amount)) { | ||||
|                     DB::rollBack(); | ||||
|                     abort(500, '余额不足'); | ||||
|                     abort(500, __('user.order.save.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, '余额不足'); | ||||
|                     abort(500, __('user.order.save.insufficient_balance')); | ||||
|                 } | ||||
|                 $order->balance_amount = $user->balance; | ||||
|                 $order->total_amount = $order->total_amount - $user->balance; | ||||
| @@ -144,7 +144,7 @@ class OrderController extends Controller | ||||
|  | ||||
|         if (!$order->save()) { | ||||
|             DB::rollback(); | ||||
|             abort(500, '订单创建失败'); | ||||
|             abort(500, __('user.order.save.order_create_failed')); | ||||
|         } | ||||
|  | ||||
|         DB::commit(); | ||||
| @@ -163,7 +163,7 @@ class OrderController extends Controller | ||||
|             ->where('status', 0) | ||||
|             ->first(); | ||||
|         if (!$order) { | ||||
|             abort(500, '订单不存在或已支付'); | ||||
|             abort(500, __('user.order.checkout.order_not_exist_or_paid')); | ||||
|         } | ||||
|         // free process | ||||
|         if ($order->total_amount <= 0) { | ||||
| @@ -180,7 +180,7 @@ class OrderController extends Controller | ||||
|             case 0: | ||||
|                 // alipayF2F | ||||
|                 if (!(int)config('v2board.alipay_enable')) { | ||||
|                     abort(500, '支付方式不可用'); | ||||
|                     abort(500, __('user.order.checkout.pay_method_not_use')); | ||||
|                 } | ||||
|                 return response([ | ||||
|                     'type' => 0, | ||||
| @@ -189,7 +189,7 @@ class OrderController extends Controller | ||||
|             case 2: | ||||
|                 // stripeAlipay | ||||
|                 if (!(int)config('v2board.stripe_alipay_enable')) { | ||||
|                     abort(500, '支付方式不可用'); | ||||
|                     abort(500, __('user.order.checkout.pay_method_not_use')); | ||||
|                 } | ||||
|                 return response([ | ||||
|                     'type' => 1, | ||||
| @@ -198,7 +198,7 @@ class OrderController extends Controller | ||||
|             case 3: | ||||
|                 // stripeWepay | ||||
|                 if (!(int)config('v2board.stripe_wepay_enable')) { | ||||
|                     abort(500, '支付方式不可用'); | ||||
|                     abort(500, __('user.order.checkout.pay_method_not_use')); | ||||
|                 } | ||||
|                 return response([ | ||||
|                     'type' => 0, | ||||
| @@ -207,7 +207,7 @@ class OrderController extends Controller | ||||
|             case 4: | ||||
|                 // bitpayX | ||||
|                 if (!(int)config('v2board.bitpayx_enable')) { | ||||
|                     abort(500, '支付方式不可用'); | ||||
|                     abort(500, __('user.order.checkout.pay_method_not_use')); | ||||
|                 } | ||||
|                 return response([ | ||||
|                     'type' => 1, | ||||
| @@ -215,7 +215,7 @@ class OrderController extends Controller | ||||
|                 ]); | ||||
|             case 5: | ||||
|                 if (!(int)config('v2board.mgate_enable')) { | ||||
|                     abort(500, '支付方式不可用'); | ||||
|                     abort(500, __('user.order.checkout.pay_method_not_use')); | ||||
|                 } | ||||
|                 return response([ | ||||
|                     'type' => 1, | ||||
| @@ -223,7 +223,7 @@ class OrderController extends Controller | ||||
|                 ]); | ||||
|             case 6: | ||||
|                 if (!(int)config('v2board.stripe_card_enable')) { | ||||
|                     abort(500, '支付方式不可用'); | ||||
|                     abort(500, __('user.order.checkout.pay_method_not_use')); | ||||
|                 } | ||||
|                 return response([ | ||||
|                     'type' => 2, | ||||
| @@ -231,14 +231,14 @@ class OrderController extends Controller | ||||
|                 ]); | ||||
|             case 7: | ||||
|                 if (!(int)config('v2board.epay_enable')) { | ||||
|                     abort(500, '支付方式不可用'); | ||||
|                     abort(500, __('user.order.checkout.pay_method_not_use')); | ||||
|                 } | ||||
|                 return response([ | ||||
|                     'type' => 1, | ||||
|                     'data' => $this->epay($order) | ||||
|                 ]); | ||||
|             default: | ||||
|                 abort(500, '支付方式不存在'); | ||||
|                 abort(500, __('user.order.checkout.pay_method_not_use')); | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @@ -249,7 +249,7 @@ class OrderController extends Controller | ||||
|             ->where('user_id', $request->session()->get('id')) | ||||
|             ->first(); | ||||
|         if (!$order) { | ||||
|             abort(500, '订单不存在'); | ||||
|             abort(500, __('user.order.check.order_not_exist')); | ||||
|         } | ||||
|         return response([ | ||||
|             'data' => $order->status | ||||
| @@ -323,20 +323,20 @@ class OrderController extends Controller | ||||
|     public function cancel(Request $request) | ||||
|     { | ||||
|         if (empty($request->input('trade_no'))) { | ||||
|             abort(500, '参数有误'); | ||||
|             abort(500, __('user.order.cancel.params_wrong')); | ||||
|         } | ||||
|         $order = Order::where('trade_no', $request->input('trade_no')) | ||||
|             ->where('user_id', $request->session()->get('id')) | ||||
|             ->first(); | ||||
|         if (!$order) { | ||||
|             abort(500, '订单不存在'); | ||||
|             abort(500, __('user.order.cancel.order_not_exist')); | ||||
|         } | ||||
|         if ($order->status !== 0) { | ||||
|             abort(500, '只可以取消待支付订单'); | ||||
|             abort(500, __('user.order.cancel.only_cancel_pending_order')); | ||||
|         } | ||||
|         $orderService = new OrderService($order); | ||||
|         if (!$orderService->cancel()) { | ||||
|             abort(500, '取消失败'); | ||||
|             abort(500, __('user.order.cancel.cancel_failed')); | ||||
|         } | ||||
|         return response([ | ||||
|             'data' => true | ||||
| @@ -372,7 +372,7 @@ class OrderController extends Controller | ||||
|         $currency = config('v2board.stripe_currency', 'hkd'); | ||||
|         $exchange = Helper::exchange('CNY', strtoupper($currency)); | ||||
|         if (!$exchange) { | ||||
|             abort(500, '货币转换超时,请稍后再试'); | ||||
|             abort(500, __('user.order.stripeAlipay.currency_convert_timeout')); | ||||
|         } | ||||
|         Stripe::setApiKey(config('v2board.stripe_sk_live')); | ||||
|         $source = Source::create([ | ||||
| @@ -390,7 +390,7 @@ class OrderController extends Controller | ||||
|             ] | ||||
|         ]); | ||||
|         if (!$source['redirect']['url']) { | ||||
|             abort(500, '支付网关请求失败'); | ||||
|             abort(500, __('user.order.stripeAlipay.gateway_request_failed')); | ||||
|         } | ||||
|         return $source['redirect']['url']; | ||||
|     } | ||||
| @@ -400,7 +400,7 @@ class OrderController extends Controller | ||||
|         $currency = config('v2board.stripe_currency', 'hkd'); | ||||
|         $exchange = Helper::exchange('CNY', strtoupper($currency)); | ||||
|         if (!$exchange) { | ||||
|             abort(500, '货币转换超时,请稍后再试'); | ||||
|             abort(500, __('user.order.stripeWepay.currency_convert_timeout')); | ||||
|         } | ||||
|         Stripe::setApiKey(config('v2board.stripe_sk_live')); | ||||
|         $source = Source::create([ | ||||
| @@ -417,7 +417,7 @@ class OrderController extends Controller | ||||
|             ] | ||||
|         ]); | ||||
|         if (!$source['wechat']['qr_code_url']) { | ||||
|             abort(500, '支付网关请求失败'); | ||||
|             abort(500, __('user.order.stripeWepay.gateway_request_failed')); | ||||
|         } | ||||
|         return $source['wechat']['qr_code_url']; | ||||
|     } | ||||
| @@ -427,7 +427,7 @@ class OrderController extends Controller | ||||
|         $currency = config('v2board.stripe_currency', 'hkd'); | ||||
|         $exchange = Helper::exchange('CNY', strtoupper($currency)); | ||||
|         if (!$exchange) { | ||||
|             abort(500, '货币转换超时,请稍后再试'); | ||||
|             abort(500, __('user.order.stripeCard.currency_convert_timeout')); | ||||
|         } | ||||
|         Stripe::setApiKey(config('v2board.stripe_sk_live')); | ||||
|         try { | ||||
| @@ -442,11 +442,11 @@ class OrderController extends Controller | ||||
|                 ] | ||||
|             ]); | ||||
|         } catch (\Exception $e) { | ||||
|             abort(500, '遇到了点问题,请刷新页面稍后再试'); | ||||
|             abort(500, __('user.order.stripeCard.was_problem')); | ||||
|         } | ||||
|         info($charge); | ||||
|         if (!$charge->paid) { | ||||
|             abort(500, '扣款失败,请检查信用卡信息'); | ||||
|             abort(500, __('user.order.stripeCard.deduction_failed')); | ||||
|         } | ||||
|         return $charge->paid; | ||||
|     } | ||||
|   | ||||
| @@ -14,7 +14,7 @@ class PlanController extends Controller | ||||
|             $plan = Plan::where('id', $request->input('id')) | ||||
|                 ->first(); | ||||
|             if (!$plan) { | ||||
|                 abort(500, '该订阅不存在'); | ||||
|                 abort(500, __('user.plan.fetch.plan_not_exist')); | ||||
|             } | ||||
|             return response([ | ||||
|                 'data' => $plan | ||||
|   | ||||
| @@ -23,7 +23,7 @@ class TicketController extends Controller | ||||
|                 ->where('user_id', $request->session()->get('id')) | ||||
|                 ->first(); | ||||
|             if (!$ticket) { | ||||
|                 abort(500, '工单不存在'); | ||||
|                 abort(500, __('user.ticket.fetch.ticket_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, '存在其他工单尚未处理'); | ||||
|             abort(500, __('user.ticket.save.exist_other_open_ticket')); | ||||
|         } | ||||
|         $ticket = Ticket::create(array_merge($request->only([ | ||||
|             'subject', | ||||
| @@ -67,7 +67,7 @@ class TicketController extends Controller | ||||
|         ])); | ||||
|         if (!$ticket) { | ||||
|             DB::rollback(); | ||||
|             abort(500, '工单创建失败'); | ||||
|             abort(500, __('user.ticket.save.ticket_create_failed')); | ||||
|         } | ||||
|         $ticketMessage = TicketMessage::create([ | ||||
|             'user_id' => $request->session()->get('id'), | ||||
| @@ -76,7 +76,7 @@ class TicketController extends Controller | ||||
|         ]); | ||||
|         if (!$ticketMessage) { | ||||
|             DB::rollback(); | ||||
|             abort(500, '工单创建失败'); | ||||
|             abort(500, __('user.ticket.save.ticket_create_failed')); | ||||
|         } | ||||
|         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, '参数错误'); | ||||
|             abort(500, __('user.ticket.reply.params_wrong')); | ||||
|         } | ||||
|         if (empty($request->input('message'))) { | ||||
|             abort(500, '消息不能为空'); | ||||
|             abort(500, __('user.ticket.reply.message_not_empty')); | ||||
|         } | ||||
|         $ticket = Ticket::where('id', $request->input('id')) | ||||
|             ->where('user_id', $request->session()->get('id')) | ||||
|             ->first(); | ||||
|         if (!$ticket) { | ||||
|             abort(500, '工单不存在'); | ||||
|             abort(500, __('user.ticket.reply.ticket_not_exist')); | ||||
|         } | ||||
|         if ($ticket->status) { | ||||
|             abort(500, '工单已关闭,无法回复'); | ||||
|             abort(500, __('user.ticket.reply.ticket_close_not_reply')); | ||||
|         } | ||||
|         if ($request->session()->get('id') == $this->getLastMessage($ticket->id)->user_id) { | ||||
|             abort(500, '请等待技术支持回复'); | ||||
|             abort(500, __('user.ticket.reply.wait_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, '工单回复失败'); | ||||
|             abort(500, __('user.ticket.reply.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, '参数错误'); | ||||
|             abort(500, __('user.ticket.close.params_wrong')); | ||||
|         } | ||||
|         $ticket = Ticket::where('id', $request->input('id')) | ||||
|             ->where('user_id', $request->session()->get('id')) | ||||
|             ->first(); | ||||
|         if (!$ticket) { | ||||
|             abort(500, '工单不存在'); | ||||
|             abort(500, __('user.ticket.close.ticket_not_exist')); | ||||
|         } | ||||
|         $ticket->status = 1; | ||||
|         if (!$ticket->save()) { | ||||
|             abort(500, '关闭失败'); | ||||
|             abort(500, __('user.ticket.close.close_failed')); | ||||
|         } | ||||
|         return response([ | ||||
|             'data' => true | ||||
| @@ -160,15 +160,15 @@ class TicketController extends Controller | ||||
|                 Dict::WITHDRAW_METHOD_WHITELIST_DEFAULT | ||||
|             ) | ||||
|         )) { | ||||
|             abort(500, '不支持的提现方式'); | ||||
|             abort(500, __('user.ticket.withdraw.not_support_withdraw_method')); | ||||
|         } | ||||
|         $user = User::find($request->session()->get('id')); | ||||
|         $limit = config('v2board.commission_withdraw_limit', 100); | ||||
|         if ($limit > ($user->commission_balance / 100)) { | ||||
|             abort(500, "当前系统要求的提现门槛佣金需为{$limit}CNY"); | ||||
|             abort(500, __('user.ticket.withdraw.system_require_withdraw_limit', ['limit' => $limit])); | ||||
|         } | ||||
|         DB::beginTransaction(); | ||||
|         $subject = '[提现申请]本工单由系统发出'; | ||||
|         $subject = __('user.ticket.withdraw.ticket_subject'); | ||||
|         $ticket = Ticket::create([ | ||||
|             'subject' => $subject, | ||||
|             'level' => 2, | ||||
| @@ -177,9 +177,12 @@ class TicketController extends Controller | ||||
|         ]); | ||||
|         if (!$ticket) { | ||||
|             DB::rollback(); | ||||
|             abort(500, '工单创建失败'); | ||||
|             abort(500, __('user.ticket.withdraw.ticket_create_failed')); | ||||
|         } | ||||
|         $message = "提现方式:{$request->input('withdraw_method')}\r\n提现账号:{$request->input('withdraw_account')}\r\n"; | ||||
|         $message = __('user.ticket.withdraw.ticket_message', [ | ||||
|             'method' => $request->input('withdraw_method'), | ||||
|             'account' => $request->input('withdraw_account') | ||||
|         ]); | ||||
|         $ticketMessage = TicketMessage::create([ | ||||
|             'user_id' => $request->session()->get('id'), | ||||
|             'ticket_id' => $ticket->id, | ||||
| @@ -187,7 +190,7 @@ class TicketController extends Controller | ||||
|         ]); | ||||
|         if (!$ticketMessage) { | ||||
|             DB::rollback(); | ||||
|             abort(500, '工单创建失败'); | ||||
|             abort(500, __('user.ticket.withdraw.ticket_create_failed')); | ||||
|         } | ||||
|         DB::commit(); | ||||
|         $this->sendNotify($ticket, $ticketMessage); | ||||
|   | ||||
| @@ -28,19 +28,19 @@ class UserController extends Controller | ||||
|     { | ||||
|         $user = User::find($request->session()->get('id')); | ||||
|         if (!$user) { | ||||
|             abort(500, '该用户不存在'); | ||||
|             abort(500, __('user.user.changePassword.user_not_exist')); | ||||
|         } | ||||
|         if (!Helper::multiPasswordVerify( | ||||
|             $user->password_algo, | ||||
|             $request->input('old_password'), | ||||
|             $user->password) | ||||
|         ) { | ||||
|             abort(500, '旧密码有误'); | ||||
|             abort(500, __('user.user.changePassword.old_password_wrong')); | ||||
|         } | ||||
|         $user->password = password_hash($request->input('new_password'), PASSWORD_DEFAULT); | ||||
|         $user->password_algo = NULL; | ||||
|         if (!$user->save()) { | ||||
|             abort(500, '保存失败'); | ||||
|             abort(500, __('user.user.changePassword.save_failed')); | ||||
|         } | ||||
|         $request->session()->flush(); | ||||
|         return response([ | ||||
| @@ -69,7 +69,7 @@ class UserController extends Controller | ||||
|             ]) | ||||
|             ->first(); | ||||
|         if (!$user) { | ||||
|             abort(500, '该用户不存在'); | ||||
|             abort(500, __('user.user.info.user_not_exist')); | ||||
|         } | ||||
|         $user['avatar_url'] = 'https://cdn.v2ex.com/gravatar/' . md5($user->email) . '?s=64&d=identicon'; | ||||
|         return response([ | ||||
| @@ -109,12 +109,12 @@ class UserController extends Controller | ||||
|             ]) | ||||
|             ->first(); | ||||
|         if (!$user) { | ||||
|             abort(500, '该用户不存在'); | ||||
|             abort(500, __('user.user.getSubscribe.user_not_exist')); | ||||
|         } | ||||
|         if ($user->plan_id) { | ||||
|             $user['plan'] = Plan::find($user->plan_id); | ||||
|             if (!$user['plan']) { | ||||
|                 abort(500, '订阅计划不存在'); | ||||
|                 abort(500, __('user.user.getSubscribe.plan_not_exist')); | ||||
|             } | ||||
|         } | ||||
|         $user['subscribe_url'] = config('v2board.subscribe_url', config('v2board.app_url', env('APP_URL'))) . '/api/v1/client/subscribe?token=' . $user['token']; | ||||
| @@ -128,12 +128,12 @@ class UserController extends Controller | ||||
|     { | ||||
|         $user = User::find($request->session()->get('id')); | ||||
|         if (!$user) { | ||||
|             abort(500, '该用户不存在'); | ||||
|             abort(500, __('user.user.resetSecurity.user_not_exist')); | ||||
|         } | ||||
|         $user->uuid = Helper::guid(true); | ||||
|         $user->token = Helper::guid(); | ||||
|         if (!$user->save()) { | ||||
|             abort(500, '重置失败'); | ||||
|             abort(500, __('user.user.resetSecurity.reset_failed')); | ||||
|         } | ||||
|         return response([ | ||||
|             'data' => config('v2board.subscribe_url', config('v2board.app_url', env('APP_URL'))) . '/api/v1/client/subscribe?token=' . $user->token | ||||
| @@ -149,12 +149,12 @@ class UserController extends Controller | ||||
|  | ||||
|         $user = User::find($request->session()->get('id')); | ||||
|         if (!$user) { | ||||
|             abort(500, '该用户不存在'); | ||||
|             abort(500, __('user.user.update.user_not_exist')); | ||||
|         } | ||||
|         try { | ||||
|             $user->update($updateData); | ||||
|         } catch (\Exception $e) { | ||||
|             abort(500, '保存失败'); | ||||
|             abort(500, __('user.user.update.save_failed')); | ||||
|         } | ||||
|  | ||||
|         return response([ | ||||
| @@ -166,18 +166,18 @@ class UserController extends Controller | ||||
|     { | ||||
|         $user = User::find($request->session()->get('id')); | ||||
|         if (!$user) { | ||||
|             abort(500, '该用户不存在'); | ||||
|             abort(500, __('user.user.transfer.user_not_exist')); | ||||
|         } | ||||
|         if ($request->input('transfer_amount') <= 0) { | ||||
|             abort(500, '参数错误'); | ||||
|             abort(500, __('user.user.transfer.params_wrong')); | ||||
|         } | ||||
|         if ($request->input('transfer_amount') > $user->commission_balance) { | ||||
|             abort(500, '推广佣金余额不足'); | ||||
|             abort(500, __('user.user.transfer.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, '划转失败'); | ||||
|             abort(500, __('user.user.transfer.transfer_failed')); | ||||
|         } | ||||
|         return response([ | ||||
|             'data' => true | ||||
|   | ||||
| @@ -43,6 +43,7 @@ class Kernel extends HttpKernel | ||||
|             \Illuminate\Session\Middleware\StartSession::class, | ||||
|             \App\Http\Middleware\ForceJson::class, | ||||
|             \App\Http\Middleware\CORS::class, | ||||
|             \App\Http\Middleware\Language::class, | ||||
|             'bindings', | ||||
|         ], | ||||
|     ]; | ||||
|   | ||||
							
								
								
									
										17
									
								
								app/Http/Middleware/Language.php
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										17
									
								
								app/Http/Middleware/Language.php
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,17 @@ | ||||
| <?php | ||||
|  | ||||
| namespace App\Http\Middleware; | ||||
|  | ||||
| use Closure; | ||||
| use Illuminate\Support\Facades\App; | ||||
|  | ||||
| class Language | ||||
| { | ||||
|     public function handle($request, Closure $next) | ||||
|     { | ||||
|         if ($request->header('content-language')) { | ||||
|             App::setLocale($request->header('content-language')); | ||||
|         } | ||||
|         return $next($request); | ||||
|     } | ||||
| } | ||||
| @@ -22,6 +22,12 @@ class User | ||||
|                 $request->session()->put('id', $user->id); | ||||
|             } | ||||
|         } | ||||
| //        if ($request->input('lang')) { | ||||
| //            $request->session()->put('lang', $request->input('lang')); | ||||
| //        } | ||||
| //        if ($request->session()->get('lang')) { | ||||
| //            App::setLocale($request->session()->get('lang')); | ||||
| //        } | ||||
|         if (!$request->session()->get('id')) { | ||||
|             abort(403, '未登录或登陆已过期'); | ||||
|         } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user