增加添加活到规则自动添加到身份权限里
This commit is contained in:
@@ -47,7 +47,7 @@ class IndexController extends AdminController
|
||||
$grid->column('code', '活动编号');
|
||||
$grid->column('rule.code', '卡券规则');
|
||||
$grid->column('所属')->display(function () {
|
||||
return $this->user_id ? $this->user->nickname : '系统券';
|
||||
return $this->user_id ? $this->user->nickname : '系统';
|
||||
});
|
||||
|
||||
$grid->column('类型')->display(function () {
|
||||
@@ -90,7 +90,8 @@ class IndexController extends AdminController
|
||||
return User::with('info')->whereHas('identity', function ($q) {
|
||||
$q->where('identity_id', 1);
|
||||
})->orderBy('id', 'desc')->get()->pluck('nickname', 'id');
|
||||
});
|
||||
})
|
||||
->help('活动是否专属,不选择为所有渠道都可使用。');
|
||||
|
||||
$form->select('activity_rule_id', '所属规则')
|
||||
->options(function ($option, $info) {
|
||||
@@ -109,7 +110,10 @@ class IndexController extends AdminController
|
||||
->required();
|
||||
|
||||
$form->switch('status', '状态')->default(1);
|
||||
$form->switch('need_check', '校验')->default(1);
|
||||
$form->switch('need_check', '多次校验')
|
||||
->default(1)
|
||||
->help('同一订单,多次核销时校验,订单每满100元可核销一笔。');
|
||||
|
||||
$form->saving(function (Form $form) {
|
||||
$request = request();
|
||||
if ($request->type == Activity::TYPE_EXTEND && empty($request->days)) {
|
||||
|
||||
@@ -73,7 +73,7 @@ class Activity extends Model
|
||||
{
|
||||
|
||||
try {
|
||||
$code = 'YSD' . date('ymd') . mt_rand(100, 999);
|
||||
$code = 'YSD' . date('ymd') . mt_rand(100000, 999999);
|
||||
|
||||
if ($this->type == SELF::TYPE_EXTEND) {
|
||||
$start_at = now();
|
||||
|
||||
69
app/Observers/ActivityRuleObserver.php
Normal file
69
app/Observers/ActivityRuleObserver.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Observers;
|
||||
|
||||
use App\Models\ActivityRule;
|
||||
use RuLong\Identity\Models\IdentityCode;
|
||||
|
||||
class ActivityRuleObserver
|
||||
{
|
||||
|
||||
/**
|
||||
* Handle the ActivityRule "created" event.
|
||||
* @param ActivityRule $rule
|
||||
* @return void
|
||||
*/
|
||||
public function created(ActivityRule $rule)
|
||||
{
|
||||
$info = IdentityCode::where('code', $rule->code)->exists();
|
||||
if (!$info) {
|
||||
IdentityCode::create([
|
||||
'identity_id' => 1,
|
||||
'name' => $rule->title,
|
||||
'code' => $rule->code,
|
||||
'profit' => 0,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the ActivityRule "updated" event.
|
||||
* @param ActivityRule $rule
|
||||
* @return void
|
||||
*/
|
||||
public function updated(ActivityRule $rule)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the ActivityRule "deleted" event.
|
||||
* @param ActivityRule $rule
|
||||
* @return void
|
||||
*/
|
||||
public function deleted(ActivityRule $rule)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the ActivityRule "restored" event.
|
||||
* @param ActivityRule $rule
|
||||
* @return void
|
||||
*/
|
||||
public function restored(ActivityRule $rule)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the ActivityRule "force deleted" event.
|
||||
* @param ActivityRule $rule
|
||||
* @return void
|
||||
*/
|
||||
public function forceDeleted(ActivityRule $rule)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Models\ActivityRule;
|
||||
use App\Observers\ActivityRuleObserver;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
@@ -9,7 +11,6 @@ class AppServiceProvider extends ServiceProvider
|
||||
|
||||
/**
|
||||
* Register any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
@@ -19,11 +20,12 @@ class AppServiceProvider extends ServiceProvider
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
ActivityRule::observe(ActivityRuleObserver::class);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,13 +15,13 @@ class YsdGrant extends Init
|
||||
|
||||
$activity = Activity::where('code', $this->activityId)->first();
|
||||
if (!$activity) {
|
||||
return '没有找到这个活动。';
|
||||
return '发券失败,没有找到这个活动。';
|
||||
}
|
||||
|
||||
if ($activity->user) {
|
||||
$info = User::where('outlet_id', $this->outletId)->first();
|
||||
if (!$info) {
|
||||
return '未查询到此网点信息。';
|
||||
return '发券失败,未查询到此网点信息。';
|
||||
}
|
||||
|
||||
if ($info->parent_id != $activity->user_id) {
|
||||
|
||||
@@ -27,7 +27,7 @@ class YsdVerification extends Init
|
||||
return $res;
|
||||
}
|
||||
|
||||
//查询卡券信息 返回model string 说明报错
|
||||
//查询卡券信息 返回model 返回string 说明报错
|
||||
$this->query_coupon = (new YsdQuery)->setOutletId($this->outletId)
|
||||
->setCode($this->redemptionCode)
|
||||
->start();
|
||||
|
||||
Reference in New Issue
Block a user