mirror of
https://github.com/ProxyPanel/ProxyPanel.git
synced 2026-04-12 23:48:53 +00:00
Fix Bugs
1. 商品内容格式不正确导致的显示BUG; 2. 设置提现申请状态未正确取值的错误; 3. 非整数 余额充值&返利价格 的记录问题;
This commit is contained in:
@@ -74,7 +74,7 @@ class AutoJob extends Command
|
||||
User::activeUser()
|
||||
->with(['subscribe', 'subscribeLogs'])
|
||||
->whereHas('subscribe', function (Builder $query) {
|
||||
$query->where('status', '==', 0); // 获取有订阅且未被封禁用户
|
||||
$query->whereStatus(0); // 获取有订阅且未被封禁用户
|
||||
})
|
||||
->chunk(config('tasks.chunk'), function ($users) use ($subscribe_ban_times) {
|
||||
foreach ($users as $user) {
|
||||
|
||||
@@ -33,7 +33,7 @@ class AffiliateController extends Controller
|
||||
public function detail(Request $request, ReferralApply $aff)
|
||||
{
|
||||
return view('admin.aff.detail', [
|
||||
'referral' => $aff->load('user:id,email'),
|
||||
'referral' => $aff->load('user:id,email'),
|
||||
'commissions' => $aff->referral_logs()->with(['invitee:id,email', 'order.goods:id,name'])->paginate()->appends($request->except('page')),
|
||||
]);
|
||||
}
|
||||
@@ -41,16 +41,20 @@ class AffiliateController extends Controller
|
||||
// 设置提现申请状态
|
||||
public function setStatus(Request $request, ReferralApply $aff)
|
||||
{
|
||||
$status = (int) $request->validate(['status' => 'required|numeric|between:-1,2']);
|
||||
$status = (int) $request->input('status');
|
||||
|
||||
if ($aff->update(['status' => $status])) {
|
||||
// 审核申请的时候将关联的
|
||||
if ($status === 1 || $status === 2) {
|
||||
$aff->referral_logs()->update(['status' => $status]);
|
||||
if ($aff->referral_logs()->update(['status' => $status])) {
|
||||
return response()->json(['status' => 'success', 'message' => '操作成功']);
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json(['status' => 'success', 'message' => '操作成功']);
|
||||
}
|
||||
|
||||
return response()->json(['status' => 'success', 'message' => '操作成功']);
|
||||
return response()->json(['status' => 'fail', 'message' => '操作失败']);
|
||||
}
|
||||
|
||||
// 用户返利流水记录
|
||||
|
||||
@@ -133,7 +133,7 @@ class SystemController extends Controller
|
||||
|
||||
// 如果是返利比例,则需要除100
|
||||
if ($name === 'referral_percent') {
|
||||
$value = (int) $value / 100;
|
||||
$value /= 100;
|
||||
}
|
||||
|
||||
// 更新配置
|
||||
|
||||
@@ -304,7 +304,7 @@ class UserController extends Controller
|
||||
// 操作用户余额
|
||||
public function handleUserCredit(Request $request, User $user): JsonResponse
|
||||
{
|
||||
$amount = (int) $request->input('amount');
|
||||
$amount = $request->input('amount');
|
||||
|
||||
if (empty($amount)) {
|
||||
return Response::json(['status' => 'fail', 'message' => '充值异常']);
|
||||
|
||||
@@ -12,6 +12,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
class ReferralLog extends Model
|
||||
{
|
||||
protected $table = 'referral_log';
|
||||
protected $guarded = [];
|
||||
|
||||
public function scopeUid($query)
|
||||
{
|
||||
|
||||
@@ -104,12 +104,12 @@ class OrderService
|
||||
$oldData = self::$user->transfer_enable;
|
||||
$updateData = [
|
||||
'invite_num' => self::$user->invite_num + (self::$goods->invite_num ?: 0),
|
||||
'level' => self::$goods->level,
|
||||
'enable' => 1,
|
||||
'level' => self::$goods->level,
|
||||
'enable' => 1,
|
||||
];
|
||||
|
||||
// 无端口用户 添加端口
|
||||
if (self::$user->port === null || self::$user->port === 0) {
|
||||
if (empty(self::$user->port)) {
|
||||
$updateData['port'] = Helpers::getPort();
|
||||
}
|
||||
|
||||
@@ -149,68 +149,43 @@ class OrderService
|
||||
|
||||
return array_merge($data, [
|
||||
'transfer_enable' => self::$goods->traffic * MB,
|
||||
'reset_time' => $nextResetTime,
|
||||
'reset_time' => $nextResetTime,
|
||||
]);
|
||||
}
|
||||
|
||||
// 佣金计算
|
||||
private function setCommissionExpense(User $user): bool
|
||||
private function setCommissionExpense(User $user) // 佣金计算
|
||||
{
|
||||
$referralType = sysConfig('referral_type');
|
||||
|
||||
if ($referralType && $user->inviter_id) {// 是否需要支付佣金
|
||||
$inviter = $user->inviter;
|
||||
// 获取历史返利记录
|
||||
$referral = ReferralLog::whereInviteeId(self::$order->user_id)->doesntExist();
|
||||
$referral = ReferralLog::whereInviteeId($user->id)->doesntExist();
|
||||
// 无记录 / 首次返利
|
||||
if ($referral && sysConfig('is_invite_register')) {
|
||||
// 邀请注册功能开启时,返还邀请者邀请名额
|
||||
$inviter->update(['invite_num' => $inviter->invite_num + 1]);
|
||||
}
|
||||
// 按照返利模式进行返利判断
|
||||
if ($referralType == 2 || $referral) {
|
||||
return $this->addReferralLog(
|
||||
$user->id,
|
||||
$inviter->id,
|
||||
self::$order->id,
|
||||
self::$order->amount,
|
||||
self::$order->amount * sysConfig('referral_percent')
|
||||
);
|
||||
if ($referralType === '2' || $referral) {
|
||||
return $user->commissionLogs()
|
||||
->create([
|
||||
'inviterId' => $inviter->id,
|
||||
'order_id' => self::$order->id,
|
||||
'amount' => self::$order->amount,
|
||||
'commission' => self::$order->amount * sysConfig('referral_percent'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加返利日志.
|
||||
*
|
||||
* @param int $inviteeId 用户ID
|
||||
* @param int $inviterId 返利对象ID
|
||||
* @param int $oid 订单ID
|
||||
* @param int $amount 发生金额
|
||||
* @param int $commission 返利金额
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function addReferralLog(int $inviteeId, int $inviterId, int $oid, int $amount, int $commission): bool
|
||||
{
|
||||
$log = new ReferralLog();
|
||||
$log->invitee_id = $inviteeId;
|
||||
$log->inviter_id = $inviterId;
|
||||
$log->order_id = $oid;
|
||||
$log->amount = $amount;
|
||||
$log->commission = $commission;
|
||||
|
||||
return $log->save();
|
||||
}
|
||||
|
||||
// 激活预支付套餐
|
||||
public function activatePrepaidPlan(): bool
|
||||
public function activatePrepaidPlan(): bool // 激活预支付套餐
|
||||
{
|
||||
self::$order->update([
|
||||
'expired_at' => date('Y-m-d H:i:s', strtotime(self::$goods->days.' days')),
|
||||
'status' => 2,
|
||||
'status' => 2,
|
||||
]);
|
||||
|
||||
return $this->activatePlan();
|
||||
|
||||
@@ -210,8 +210,8 @@
|
||||
@endif
|
||||
$('#sort').val('{{$good->sort}}');
|
||||
$('#color').asColorPicker('val', '{{$good->color}}');
|
||||
$('#description').val('{{$good->description}}');
|
||||
$('#info').val('{!! $good->info !!}');
|
||||
$('#description').val(@json($good->description));
|
||||
$('#info').val(@json($good->info));
|
||||
const trafficUnit = $('#traffic_unit');
|
||||
const traffic = $('#traffic');
|
||||
@if($good->traffic >= 1073741824)
|
||||
|
||||
Reference in New Issue
Block a user