购买会员卡赠送积分
parent
cd63ae1636
commit
5916ebcb72
|
|
@ -62,7 +62,6 @@ class VipController extends AdminController
|
||||||
$grid->column('status')->switch();
|
$grid->column('status')->switch();
|
||||||
|
|
||||||
$grid->tools(function (Grid\Tools $tools) {
|
$grid->tools(function (Grid\Tools $tools) {
|
||||||
// x
|
|
||||||
if (Admin::user()->can('dcat.admin.vip.mp_qrcode')) {
|
if (Admin::user()->can('dcat.admin.vip.mp_qrcode')) {
|
||||||
$tools->append('<a class="btn btn-primary btn-outline" href="'.route('dcat.admin.vip.mp_qrcode').'" target="_blank"><i class="feather grid-action-icon icon-download"></i> 下载小程序码</a>');
|
$tools->append('<a class="btn btn-primary btn-outline" href="'.route('dcat.admin.vip.mp_qrcode').'" target="_blank"><i class="feather grid-action-icon icon-download"></i> 下载小程序码</a>');
|
||||||
}
|
}
|
||||||
|
|
@ -125,6 +124,9 @@ class VipController extends AdminController
|
||||||
$form->switch('status')->default(1);
|
$form->switch('status')->default(1);
|
||||||
$form->textarea('description');
|
$form->textarea('description');
|
||||||
|
|
||||||
|
$form->currency('points', '赠送积分')
|
||||||
|
->symbol('¥')
|
||||||
|
->customFormat(fn () => data_get($this->gift, 'points'));
|
||||||
$form->table('coupon', function ($table) {
|
$form->table('coupon', function ($table) {
|
||||||
$table->select('id', '优惠券')->options(Coupon::class)->ajax('api/coupons');
|
$table->select('id', '优惠券')->options(Coupon::class)->ajax('api/coupons');
|
||||||
$table->number('amount', '数量')->min(1)->default(1);
|
$table->number('amount', '数量')->min(1)->default(1);
|
||||||
|
|
@ -138,6 +140,14 @@ class VipController extends AdminController
|
||||||
|
|
||||||
$form->saving(function (Form $form) {
|
$form->saving(function (Form $form) {
|
||||||
$gift = $form->model()?->gift ?: [];
|
$gift = $form->model()?->gift ?: [];
|
||||||
|
|
||||||
|
$points = str_replace(',', '', $form->input('points'));
|
||||||
|
if ($points > 0) {
|
||||||
|
$gift['points'] = $points;
|
||||||
|
} else {
|
||||||
|
unset($gift['points']);
|
||||||
|
}
|
||||||
|
|
||||||
if ($form->coupon) {
|
if ($form->coupon) {
|
||||||
// [id, amount, name]
|
// [id, amount, name]
|
||||||
$couponList = [];
|
$couponList = [];
|
||||||
|
|
@ -149,8 +159,9 @@ class VipController extends AdminController
|
||||||
}
|
}
|
||||||
$gift['coupon'] = $couponList;
|
$gift['coupon'] = $couponList;
|
||||||
}
|
}
|
||||||
|
|
||||||
$form->gift = $gift;
|
$form->gift = $gift;
|
||||||
$form->deleteInput('coupon');
|
$form->deleteInput(['points', 'coupon']);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,10 @@
|
||||||
|
|
||||||
namespace App\Services;
|
namespace App\Services;
|
||||||
|
|
||||||
use App\Models\{User, Vip, UserVip, PayLog, Coupon};
|
use App\Enums\PointLogAction;
|
||||||
use App\Exceptions\BizException;
|
|
||||||
use App\Enums\{PayWay, SocialiteType, WxpayTradeType};
|
use App\Enums\{PayWay, SocialiteType, WxpayTradeType};
|
||||||
|
use App\Exceptions\BizException;
|
||||||
|
use App\Models\{User, Vip, UserVip, PayLog, Coupon};
|
||||||
use App\Services\Payment\WxpayService;
|
use App\Services\Payment\WxpayService;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
|
@ -128,6 +129,15 @@ class VipService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($gift['points']) && bccomp($gift['points'], 0, 2) === 1) {
|
||||||
|
(new PointService())->change(
|
||||||
|
$user,
|
||||||
|
bcmul($gift['points'], 100),
|
||||||
|
PointLogAction::Recharge,
|
||||||
|
"购买会员卡【{$userVip->name}】赠送积分",
|
||||||
|
$userVip,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,10 @@
|
||||||
-->
|
-->
|
||||||
|
|
||||||
@if($value)
|
@if($value)
|
||||||
@foreach($value as $key => $list)
|
|
||||||
<div class="list-group">
|
<div class="list-group">
|
||||||
@foreach($list as $item)
|
@foreach($value as $k => $v)
|
||||||
|
@if ($k === 'coupon')
|
||||||
|
@foreach($v as $item)
|
||||||
@if(is_array($item))
|
@if(is_array($item))
|
||||||
<div class="list-group-item">
|
<div class="list-group-item">
|
||||||
{{ $item['name'] }}
|
{{ $item['name'] }}
|
||||||
|
|
@ -21,6 +22,13 @@
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
||||||
|
@elseif ($k === 'points')
|
||||||
|
<div class="list-group-item">
|
||||||
|
积分
|
||||||
|
<span class="badge bg-primary">{{ $v }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
@endif
|
||||||
@endforeach
|
@endforeach
|
||||||
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue