[更新] 调整活动

This commit is contained in:
2021-01-22 16:05:15 +08:00
parent cad079a9a7
commit 0c4c8f7a00
2 changed files with 37 additions and 10 deletions

View File

@@ -93,6 +93,8 @@ class IndexController extends AdminController
$filter->column(1 / 2, function ($filter) { $filter->column(1 / 2, function ($filter) {
$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);
}); });
}); });
@@ -107,6 +109,13 @@ class IndexController extends AdminController
return $this->type_text; return $this->type_text;
}); });
$grid->column('channel', '核销途径')
->using(Activity::CHANNELS)
->label([
Activity::CHANNEL_YSD => 'info',
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', '扣除金额');
@@ -173,6 +182,12 @@ class IndexController extends AdminController
}) })
->required(); ->required();
$form->radio('channel', '核销途径')
->options(Activity::CHANNELS)
->default(Activity::CHANNEL_YSD)
->help('券码核销的途径亿时代是自己核销银联是银联pos核销')
->required();
$form->switch('status', '状态')->default(1); $form->switch('status', '状态')->default(1);
$form->switch('need_check', '多次校验') $form->switch('need_check', '多次校验')
->default(1) ->default(1)

View File

@@ -10,6 +10,11 @@ class Activity extends Model
use BelongsToUser; use BelongsToUser;
protected $dates = [
'start_at',
'end_at',
];
const TYPE_EXTEND = 1; const TYPE_EXTEND = 1;
const TYPE_SCOPE = 2; const TYPE_SCOPE = 2;
const TYPES = [ const TYPES = [
@@ -24,9 +29,11 @@ class Activity extends Model
self::STATUS_CLOSE => '关闭', self::STATUS_CLOSE => '关闭',
]; ];
protected $dates = [ const CHANNEL_YSD = 1;
'start_at', const CHANNEL_UNION = 2;
'end_at', const CHANNELS = [
self::CHANNEL_YSD => '亿时代',
self::CHANNEL_UNION => '银联',
]; ];
/** /**
@@ -51,7 +58,7 @@ class Activity extends Model
} }
//活动状态 //活动状态
public function getStatusTextAttribute() public function getStatusTextAttribute(): string
{ {
return self::STATUS[$this->status] ?? '未知'; return self::STATUS[$this->status] ?? '未知';
} }
@@ -100,8 +107,13 @@ class Activity extends Model
{ {
try { try {
// $code = 'YSD' . date('ymd') . mt_rand(100000, 999999); //判断生成何种码
if ($this->channel == self::CHANNEL_UNION) {
$code = '66406' . date('ymdH') . mt_rand(1000000, 9999999); $code = '66406' . date('ymdH') . mt_rand(1000000, 9999999);
} else {
$code = 'YSD' . date('ymd') . mt_rand(100000, 999999);
}
if ($this->type == SELF::TYPE_EXTEND) { if ($this->type == SELF::TYPE_EXTEND) {
$start_at = now(); $start_at = now();
$end_at = now()->addDays($this->days); $end_at = now()->addDays($this->days);