6
0
Fork 0

批零提现时,保存最近的管理者信息

release
李静 2022-04-24 10:10:26 +08:00
parent e51d8de60c
commit 2fcd925831
7 changed files with 69 additions and 1 deletions

View File

@ -118,6 +118,9 @@ class DealerController extends AdminController
$column->row(Show::make($id, $builder, function (Show $show) {
// $show->field('id');
$show->field('user.phone');
$show->field('userInfo.nickname')->as(function () {
return $this->userInfo->nickname;
});
$show->field('lvl')->as(function () {
return $this->lvl->text();
});

View File

@ -26,7 +26,7 @@ class DealerWalletToBankLogController extends AdminController
*/
protected function grid()
{
$builder = DealerWalletToBankLog::with(['user']);
$builder = DealerWalletToBankLog::with(['user', 'managerUserInfo']);
return Grid::make($builder, function (Grid $grid) {
$grid->tools(function (Grid\Tools $tools) {
$tools->append(new DealerWalletWithdraw());
@ -37,6 +37,13 @@ class DealerWalletToBankLogController extends AdminController
$grid->column('rate')->append('%');
$grid->column('service_amount')->prepend('¥');
$grid->column('account_amount')->prepend('¥');
$grid->column('manager_id')->display(function () {
if ($this->managerUserInfo) {
$href = admin_route('dealers.show', ['dealer_user' => $this->manager_id]);
return "<a href=\"{$href}\" target=\"_blank\">{$this->managerUserInfo->nickname}</a>";
}
});
$grid->column('status')->display(function ($v) {
$text = $v->text();
$background = $v->color();

View File

@ -90,6 +90,7 @@ class WalletController extends Controller
'rate' => $rate,
'service_amount' => bcdiv($serviceAmount, 100, 2),
'account_amount' => bcdiv($amount - $serviceAmount, 100, 2),
'manager_id' => $user->dealer->firstManager()?->user_id,
]);
//减去用户可提金额

View File

@ -136,6 +136,24 @@ class Dealer extends Model
})->all();
}
/**
* 获取经销商最近的管理者
*
* @return static|null
*/
public function firstManager(): ?static
{
if (empty($pids = $this->userInfo->parent_ids)) {
return null;
}
$manager = UserInfo::whereHas('dealer', function ($builder) {
$builder->where('is_manager', true);
})->whereIn('user_id', $pids)->latest('depth')->first();
return $manager?->dealer;
}
/**
* 获取直属金牌经销商数量
*

View File

@ -43,6 +43,7 @@ class DealerWalletToBankLog extends Model
'pay_way',
'pay_at',
'failed_reason',
'manager_id',
];
/**
@ -59,6 +60,11 @@ class DealerWalletToBankLog extends Model
return $this->belongsTo(Dealer::class, 'user_id', 'user_id');
}
public function managerUserInfo()
{
return $this->belongsTo(UserInfo::class, 'manager_id', 'user_id');
}
/**
* 待打款状态
*

View File

@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddManagerIdToDealerWalletToBankLogsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('dealer_wallet_to_bank_logs', function (Blueprint $table) {
$table->unsignedBigInteger('manager_id')->nullable()->comment('管理者UID');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('dealer_wallet_to_bank_logs', function (Blueprint $table) {
$table->dropColumn(['manager_id']);
});
}
}

View File

@ -19,6 +19,7 @@ return [
'remarks' => '备注',
'failed_reason' => '失败原因',
'pay_way' => '支付方式',
'manager_id' => '管理者',
],
'options' => [
],