This commit is contained in:
2022-05-24 16:19:18 +08:00
5 changed files with 49 additions and 61 deletions

View File

@@ -13,7 +13,7 @@ class CouponController extends AdminController
protected $title = '卡券列表管理'; protected $title = '卡券列表管理';
protected function grid() protected function grid(): Grid
{ {
$grid = new Grid(new ActivityCoupon); $grid = new Grid(new ActivityCoupon);
$grid->model()->with(['outlet'])->latest(); $grid->model()->with(['outlet'])->latest();
@@ -25,9 +25,6 @@ class CouponController extends AdminController
$filter->equal('status', '状态')->select(ActivityCoupon::STATUS); $filter->equal('status', '状态')->select(ActivityCoupon::STATUS);
$filter->between('used_at', '核销时间')->datetime(); $filter->between('used_at', '核销时间')->datetime();
$users = User::whereHas('identity', function ($query) {
$query->where('identity_id', 1);
})->get()->pluck('nickname', 'id');
$filter->where(function ($query) { $filter->where(function ($query) {
$query->whereHas('outlet', function ($query) { $query->whereHas('outlet', function ($query) {

View File

@@ -36,9 +36,7 @@ class IndexController extends AdminController
$filter->between('start_at', '开始时间')->datetime(); $filter->between('start_at', '开始时间')->datetime();
$filter->between('end_at', '结束时间')->datetime(); $filter->between('end_at', '结束时间')->datetime();
$filter->equal('channel', '核销途径')->select(Activity::CHANNELS); $filter->equal('channel', '核销途径')->select(Activity::CHANNELS);
}); });
}); });
$grid->column('id', '#ID#'); $grid->column('id', '#ID#');
@@ -50,27 +48,22 @@ class IndexController extends AdminController
$grid->column('类型')->display(function () { $grid->column('类型')->display(function () {
return $this->type_text; return $this->type_text;
}); });
$grid->column('channel', '核销途径') $grid->column('channel', '核销途径')
->using(Activity::CHANNELS) ->using(Activity::CHANNELS)
->label([ ->label([
Activity::CHANNEL_YSD => 'info', Activity::CHANNEL_YSD => 'info',
Activity::CHANNEL_UNION => 'success', Activity::CHANNEL_UNION => 'success',
]); ]);
$grid->column('days', '延期(天)'); $grid->column('days', '延期(天)');
$grid->column('rule.full', '满足金额'); $grid->column('rule.full', '满足金额');
$grid->column('rule.take', '扣除金额'); $grid->column('rule.take', '扣除金额');
$grid->column('发券渠道')->display(function ($title, $column) { $grid->column('发券渠道')->display(function ($title, $column) {
return '查看'; return '查看';
})->modal(Grants::class); })->modal(Grants::class);
$grid->column('核券渠道')->display(function ($title, $column) { $grid->column('核券渠道')->display(function ($title, $column) {
return '查看'; return '查看';
})->modal(Verifications::class); })->modal(Verifications::class);
$grid->column('开始时间')->display(function () { $grid->column('开始时间')->display(function () {
return $this->type == Activity::TYPE_SCOPE ? $this->start_at->format('Y-m-d') : '---'; return $this->type == Activity::TYPE_SCOPE ? $this->start_at->format('Y-m-d') : '---';
}); });

View File

@@ -2,7 +2,6 @@
namespace App\Admin\Controllers\Activity; namespace App\Admin\Controllers\Activity;
use App\Admin\Renderable\Activity\Grants;
use App\Models\ActivityCouponLog; use App\Models\ActivityCouponLog;
use Encore\Admin\Controllers\HasResourceActions; use Encore\Admin\Controllers\HasResourceActions;
use Encore\Admin\Grid; use Encore\Admin\Grid;
@@ -18,19 +17,21 @@ class LogController extends AdminController
/** /**
* Get content title. * Get content title.
*
* @return string * @return string
*/ */
protected function title() protected function title(): string
{ {
return $this->title; return $this->title;
} }
/** /**
* Index interface. * Index interface.
*
* @param Content $content * @param Content $content
* @return Content * @return Content
*/ */
public function index(Content $content) public function index(Content $content): Content
{ {
return $content return $content
->title($this->title()) ->title($this->title())
@@ -38,7 +39,7 @@ class LogController extends AdminController
->body($this->grid()); ->body($this->grid());
} }
protected function grid() protected function grid(): Grid
{ {
$grid = new Grid(new ActivityCouponLog); $grid = new Grid(new ActivityCouponLog);
@@ -54,10 +55,8 @@ class LogController extends AdminController
$filter->column(1 / 2, function ($filter) { $filter->column(1 / 2, function ($filter) {
$filter->equal('status', '状态')->select(ActivityCouponLog::STATUS); $filter->equal('status', '状态')->select(ActivityCouponLog::STATUS);
$filter->between('created_at', '开始时间')->datetime(); $filter->between('created_at', '开始时间')->datetime();
}); });
}); });
$grid->column('id', '#ID#'); $grid->column('id', '#ID#');
@@ -79,10 +78,7 @@ class LogController extends AdminController
]); ]);
$grid->column('remark', '处理结果'); $grid->column('remark', '处理结果');
$grid->column('created_at', '操作时间'); $grid->column('created_at', '操作时间');
return $grid; return $grid;
} }
} }

View File

@@ -12,10 +12,9 @@ use RuLong\Identity\Models\Identity;
class RuleController extends AdminController class RuleController extends AdminController
{ {
protected $title = '规则管理'; protected $title = '规则管理';
protected function grid() protected function grid(): Grid
{ {
$grid = new Grid(new ActivityRule); $grid = new Grid(new ActivityRule);
@@ -34,15 +33,15 @@ class RuleController extends AdminController
]); ]);
$grid->column('created_at', '创建时间'); $grid->column('created_at', '创建时间');
return $grid; return $grid;
} }
/** /**
* Make a form builder. * Make a form builder.
*
* @return Form * @return Form
*/ */
protected function form() protected function form(): Form
{ {
$form = new Form(new ActivityRule); $form = new Form(new ActivityRule);
@@ -79,5 +78,4 @@ class RuleController extends AdminController
return $form; return $form;
} }
} }

View File

@@ -48,6 +48,7 @@ class Activity extends Model
/** /**
* 默认加载的关联 * 默认加载的关联
*
* @var array * @var array
*/ */
protected $with = ['rule']; protected $with = ['rule'];
@@ -87,6 +88,7 @@ class Activity extends Model
/** /**
* Notes: 关联可发券渠道中间表 * Notes: 关联可发券渠道中间表
*
* @Author: 玄尘 * @Author: 玄尘
* @Date : 2020/8/21 11:09 * @Date : 2020/8/21 11:09
*/ */
@@ -97,6 +99,7 @@ class Activity extends Model
/** /**
* Notes: 可发券的渠道 * Notes: 可发券的渠道
*
* @Author: 玄尘 * @Author: 玄尘
* @Date : 2021/4/25 11:36 * @Date : 2021/4/25 11:36
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
@@ -108,6 +111,7 @@ class Activity extends Model
/** /**
* Notes: 关联可核券网点中间表 * Notes: 关联可核券网点中间表
*
* @Author: 玄尘 * @Author: 玄尘
* @Date : 2020/8/21 11:09 * @Date : 2020/8/21 11:09
*/ */
@@ -118,6 +122,7 @@ class Activity extends Model
/** /**
* Notes: 关联可核销渠道 * Notes: 关联可核销渠道
*
* @Author: 玄尘 * @Author: 玄尘
* @Date : 2020/8/21 11:09 * @Date : 2020/8/21 11:09
*/ */
@@ -128,6 +133,7 @@ class Activity extends Model
/** /**
* Notes: 可核销的渠道 * Notes: 可核销的渠道
*
* @Author: 玄尘 * @Author: 玄尘
* @Date : 2021/4/25 11:37 * @Date : 2021/4/25 11:37
*/ */
@@ -138,6 +144,7 @@ class Activity extends Model
/** /**
* Notes: 是否可以发券 * Notes: 是否可以发券
*
* @Author: 玄尘 * @Author: 玄尘
* @Date : 2021/4/25 10:41 * @Date : 2021/4/25 10:41
* @return mixed * @return mixed
@@ -149,13 +156,13 @@ class Activity extends Model
/** /**
* Notes: 生成优惠券码 * Notes: 生成优惠券码
*
* @Author: 玄尘 * @Author: 玄尘
* @Date : 2021/4/25 10:41 * @Date : 2021/4/25 10:41
* @return mixed|string * @return mixed|string
*/ */
public function getCode() public function getCode()
{ {
//判断生成何种码 //判断生成何种码
if ($this->channel == self::CHANNEL_UNION) { if ($this->channel == self::CHANNEL_UNION) {
$code = '66406'.date('ymdHi').mt_rand(10000, 99999); $code = '66406'.date('ymdHi').mt_rand(10000, 99999);
@@ -217,10 +224,7 @@ class Activity extends Model
return $coupon; return $coupon;
} catch (\Exception $e) { } catch (\Exception $e) {
DB::rollback(); DB::rollback();
return $e->getMessage(); return $e->getMessage();
} }
} }
} }