Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: Neko-X2-Kyarameru/v2board
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.7.4.2
Choose a base ref
...
head repository: Neko-X2-Kyarameru/v2board
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 5 commits
  • 3 files changed
  • 1 contributor

Commits on Aug 13, 2024

  1. 订阅购买页面显示流量重置包

    if("reset_price"!==e) 改为 if(e)
    FantajiNeko authored Aug 13, 2024
    Copy the full SHA
    ec14ca7 View commit details

Commits on Aug 23, 2024

  1. Copy the full SHA
    fda7068 View commit details
  2. Merge pull request #1 from Neko-X2-Kyarameru/FantajiNeko-patch-1

    fix 更新流量提醒邮件规则
    FantajiNeko authored Aug 23, 2024
    Copy the full SHA
    176c73f View commit details

Commits on Dec 30, 2024

  1. Update TicketController.php

    工单telegram通知
    FantajiNeko authored Dec 30, 2024
    Copy the full SHA
    c8afdd5 View commit details
  2. Merge pull request #2 from Neko-X2-Kyarameru/FantajiNeko-patch-1

    Update TicketController.php
    FantajiNeko authored Dec 30, 2024
    Copy the full SHA
    742f76e View commit details
Showing with 70 additions and 20 deletions.
  1. +2 −0 app/Console/Commands/ResetTraffic.php
  2. +67 −19 app/Http/Controllers/User/TicketController.php
  3. +1 −1 public/theme/v2board/assets/umi.js
2 changes: 2 additions & 0 deletions app/Console/Commands/ResetTraffic.php
Original file line number Diff line number Diff line change
@@ -6,6 +6,8 @@
use Illuminate\Console\Command;
use App\Models\User;
use Illuminate\Support\Facades\DB;
use App\Utils\CacheKey;
use Illuminate\Support\Facades\Cache;

class ResetTraffic extends Command
{
86 changes: 67 additions & 19 deletions app/Http/Controllers/User/TicketController.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
<?php

/*
Author: SakuraUI
Website: https://sakuraui.com
Description: 请勿倒卖,如果你是花钱买的恭喜你,倒霉蛋!
*/
namespace App\Http\Controllers\User;

use App\Http\Controllers\Controller;
use App\Http\Requests\User\TicketSave;
use App\Http\Requests\User\TicketWithdraw;
use App\Jobs\SendTelegramJob;
use App\Models\User;
use App\Models\Plan;
use App\Services\TelegramService;
use App\Services\TicketService;
use App\Utils\Dict;
@@ -49,7 +54,7 @@ public function fetch(Request $request)
public function save(TicketSave $request)
{
DB::beginTransaction();
if ((int)Ticket::where('status', 0)->where('user_id', $request->user['id'])->lockForUpdate()->count()) {
if ((int) Ticket::where('status', 0)->where('user_id', $request->user['id'])->lockForUpdate()->count()) {
abort(500, __('There are other unresolved tickets'));
}
$ticket = Ticket::create(array_merge($request->only([
@@ -72,7 +77,7 @@ public function save(TicketSave $request)
abort(500, __('Failed to open ticket'));
}
DB::commit();
$this->sendNotify($ticket, $request->input('message'));
$this->sendNotify($ticket, $request->input('message'), $request->user['id']);
return response([
'data' => true
]);
@@ -99,14 +104,16 @@ public function reply(Request $request)
abort(500, __('Please wait for the technical enginneer to reply'));
}
$ticketService = new TicketService();
if (!$ticketService->reply(
$ticket,
$request->input('message'),
$request->user['id']
)) {
if (
!$ticketService->reply(
$ticket,
$request->input('message'),
$request->user['id']
)
) {
abort(500, __('Ticket reply failed'));
}
$this->sendNotify($ticket, $request->input('message'));
$this->sendNotify($ticket, $request->input('message'), $request->user['id']);
return response([
'data' => true
]);
@@ -142,16 +149,18 @@ private function getLastMessage($ticketId)

public function withdraw(TicketWithdraw $request)
{
if ((int)config('v2board.withdraw_close_enable', 0)) {
if ((int) config('v2board.withdraw_close_enable', 0)) {
abort(500, 'user.ticket.withdraw.not_support_withdraw');
}
if (!in_array(
$request->input('withdraw_method'),
config(
'v2board.commission_withdraw_method',
Dict::WITHDRAW_METHOD_WHITELIST_DEFAULT
if (
!in_array(
$request->input('withdraw_method'),
config(
'v2board.commission_withdraw_method',
Dict::WITHDRAW_METHOD_WHITELIST_DEFAULT
)
)
)) {
) {
abort(500, __('Unsupported withdrawal method'));
}
$user = User::find($request->user['id']);
@@ -170,7 +179,8 @@ public function withdraw(TicketWithdraw $request)
DB::rollback();
abort(500, __('Failed to open ticket'));
}
$message = sprintf("%s\r\n%s",
$message = sprintf(
"%s\r\n%s",
__('Withdrawal method') . "" . $request->input('withdraw_method'),
__('Withdrawal account') . "" . $request->input('withdraw_account')
);
@@ -190,9 +200,47 @@ public function withdraw(TicketWithdraw $request)
]);
}

private function sendNotify(Ticket $ticket, string $message)
private function sendNotify(Ticket $ticket, string $message, $userid = null)
{
$telegramService = new TelegramService();
$telegramService->sendMessageWithAdmin("📮工单提醒 #{$ticket->id}\n———————————————\n主题:\n`{$ticket->subject}`\n内容:\n`{$message}`", true);
if (!empty($userid)) {
$user = User::find($userid);
$transfer_enable = $this->getFlowData($user->transfer_enable); // 总流量
$remaining_traffic = $this->getFlowData($user->transfer_enable - $user->u - $user->d); // 剩余流量
$u = $this->getFlowData($user->u); // 上传
$d = $this->getFlowData($user->d); // 下载
$expired_at = date("Y-m-d h:m:s", $user->expired_at); // 到期时间
$ip_address = $_SERVER['REMOTE_ADDR']; // IP地址
$api_url = "http://ip-api.com/json/{$ip_address}?fields=520191&lang=zh-CN";
$response = file_get_contents($api_url);
$user_location = json_decode($response, true);
if ($user_location && $user_location['status'] === 'success') {
$location = $user_location['city'] . ", " . $user_location['country'];
} else {
$location = "无法确定用户地址";
}
$plan = Plan::find($user->plan_id);
if ($plan) {
$planName = $plan->name;
} else {
$planName = '未分配套餐'; // 或者提供一个默认值
}
$money = $user->balance / 100;
$affmoney = $user->commission_balance / 100;
$telegramService->sendMessageWithAdmin("📮工单提醒 #{$ticket->id}\n———————————————\n邮箱:\n`{$user->email}`\n用户位置:\n`{$location}`\nIP:\n{$ip_address}\n套餐与流量:\n`{$planName} of {$transfer_enable}/{$remaining_traffic}`\n上传/下载:\n`{$u}/{$d}`\n到期时间:\n`{$expired_at}`\n余额/佣金余额:\n`{$money}/{$affmoney}`\n主题:\n`{$ticket->subject}`\n内容:\n`{$message}`", true);
} else {
$telegramService->sendMessageWithAdmin("📮工单提醒 #{$ticket->id}\n———————————————\n主题:\n`{$ticket->subject}`\n内容:\n`{$message}`", true);
}
}
private function getFlowData($b)
{
$g = $b / (1024 * 1024 * 1024); // 转换流量数据
$m = $b / (1024 * 1024);
if ($g >= 1) {
$text = round($g, 2) . "GB";
} else {
$text = round($m, 2) . "MB";
}
return $text;
}
}
2 changes: 1 addition & 1 deletion public/theme/v2board/assets/umi.js

Large diffs are not rendered by default.