购买会员卡赠送积分
parent
cd63ae1636
commit
5916ebcb72
|
|
@ -62,7 +62,6 @@ class VipController extends AdminController
|
|||
$grid->column('status')->switch();
|
||||
|
||||
$grid->tools(function (Grid\Tools $tools) {
|
||||
// x
|
||||
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>');
|
||||
}
|
||||
|
|
@ -125,6 +124,9 @@ class VipController extends AdminController
|
|||
$form->switch('status')->default(1);
|
||||
$form->textarea('description');
|
||||
|
||||
$form->currency('points', '赠送积分')
|
||||
->symbol('¥')
|
||||
->customFormat(fn () => data_get($this->gift, 'points'));
|
||||
$form->table('coupon', function ($table) {
|
||||
$table->select('id', '优惠券')->options(Coupon::class)->ajax('api/coupons');
|
||||
$table->number('amount', '数量')->min(1)->default(1);
|
||||
|
|
@ -138,6 +140,14 @@ class VipController extends AdminController
|
|||
|
||||
$form->saving(function (Form $form) {
|
||||
$gift = $form->model()?->gift ?: [];
|
||||
|
||||
$points = str_replace(',', '', $form->input('points'));
|
||||
if ($points > 0) {
|
||||
$gift['points'] = $points;
|
||||
} else {
|
||||
unset($gift['points']);
|
||||
}
|
||||
|
||||
if ($form->coupon) {
|
||||
// [id, amount, name]
|
||||
$couponList = [];
|
||||
|
|
@ -149,8 +159,9 @@ class VipController extends AdminController
|
|||
}
|
||||
$gift['coupon'] = $couponList;
|
||||
}
|
||||
|
||||
$form->gift = $gift;
|
||||
$form->deleteInput('coupon');
|
||||
$form->deleteInput(['points', 'coupon']);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,9 +2,10 @@
|
|||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\{User, Vip, UserVip, PayLog, Coupon};
|
||||
use App\Exceptions\BizException;
|
||||
use App\Enums\PointLogAction;
|
||||
use App\Enums\{PayWay, SocialiteType, WxpayTradeType};
|
||||
use App\Exceptions\BizException;
|
||||
use App\Models\{User, Vip, UserVip, PayLog, Coupon};
|
||||
use App\Services\Payment\WxpayService;
|
||||
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,21 +6,29 @@
|
|||
-->
|
||||
|
||||
@if($value)
|
||||
@foreach($value as $key => $list)
|
||||
<div class="list-group">
|
||||
@foreach($list as $item)
|
||||
@if(is_array($item))
|
||||
<div class="list-group-item">
|
||||
{{ $item['name'] }}
|
||||
<span class="badge bg-primary">{{ $item['amount'] }}</span>
|
||||
</div>
|
||||
@else
|
||||
<div class="list-group-item">
|
||||
{{ \App\Models\Coupon::where('id', $item)->value('name') }}
|
||||
<span class="badge bg-primary">1</span>
|
||||
</div>
|
||||
@endif
|
||||
@foreach($value as $k => $v)
|
||||
@if ($k === 'coupon')
|
||||
@foreach($v as $item)
|
||||
@if(is_array($item))
|
||||
<div class="list-group-item">
|
||||
{{ $item['name'] }}
|
||||
<span class="badge bg-primary">{{ $item['amount'] }}</span>
|
||||
</div>
|
||||
@else
|
||||
<div class="list-group-item">
|
||||
{{ \App\Models\Coupon::where('id', $item)->value('name') }}
|
||||
<span class="badge bg-primary">1</span>
|
||||
</div>
|
||||
@endif
|
||||
@endforeach
|
||||
|
||||
@elseif ($k === 'points')
|
||||
<div class="list-group-item">
|
||||
积分
|
||||
<span class="badge bg-primary">{{ $v }}</span>
|
||||
</div>
|
||||
@endif
|
||||
@endforeach
|
||||
</div>
|
||||
@endforeach
|
||||
@endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue