diff --git a/app/Admin/Controllers/Activity/IndexController.php b/app/Admin/Controllers/Activity/IndexController.php index c40ab6c..a227959 100644 --- a/app/Admin/Controllers/Activity/IndexController.php +++ b/app/Admin/Controllers/Activity/IndexController.php @@ -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)) { diff --git a/app/Models/Activity.php b/app/Models/Activity.php index b72befd..93e4edb 100644 --- a/app/Models/Activity.php +++ b/app/Models/Activity.php @@ -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(); diff --git a/app/Observers/ActivityRuleObserver.php b/app/Observers/ActivityRuleObserver.php new file mode 100644 index 0000000..61bd0b5 --- /dev/null +++ b/app/Observers/ActivityRuleObserver.php @@ -0,0 +1,69 @@ +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) + { + // + } + +} diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 5ea6a10..762872e 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -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); + } } diff --git a/packages/coupon/src/Action/ysd/YsdGrant.php b/packages/coupon/src/Action/ysd/YsdGrant.php index 0898464..067988b 100644 --- a/packages/coupon/src/Action/ysd/YsdGrant.php +++ b/packages/coupon/src/Action/ysd/YsdGrant.php @@ -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) { diff --git a/packages/coupon/src/Action/ysd/YsdVerification.php b/packages/coupon/src/Action/ysd/YsdVerification.php index bdc2cb1..689fdb7 100644 --- a/packages/coupon/src/Action/ysd/YsdVerification.php +++ b/packages/coupon/src/Action/ysd/YsdVerification.php @@ -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();