微调
This commit is contained in:
@@ -13,7 +13,7 @@ class CouponController extends AdminController
|
||||
|
||||
protected $title = '卡券列表管理';
|
||||
|
||||
protected function grid()
|
||||
protected function grid(): Grid
|
||||
{
|
||||
$grid = new Grid(new ActivityCoupon);
|
||||
$grid->model()->with(['outlet'])->latest();
|
||||
@@ -25,9 +25,6 @@ class CouponController extends AdminController
|
||||
$filter->equal('status', '状态')->select(ActivityCoupon::STATUS);
|
||||
$filter->between('used_at', '核销时间')->datetime();
|
||||
|
||||
$users = User::whereHas('identity', function ($query) {
|
||||
$query->where('identity_id', 1);
|
||||
})->get()->pluck('nickname', 'id');
|
||||
|
||||
$filter->where(function ($query) {
|
||||
$query->whereHas('outlet', function ($query) {
|
||||
@@ -52,12 +49,12 @@ class CouponController extends AdminController
|
||||
}, '优惠政策', 'rule_code')->select(ActivityRule::where('status', 1)->pluck('title', 'code'));
|
||||
|
||||
$users = User::query()
|
||||
->whereHas('identity', function ($query) {
|
||||
$query->where('identity_id', 1);
|
||||
})
|
||||
->get()
|
||||
->pluck('nickname', 'id');
|
||||
|
||||
->whereHas('identity', function ($query) {
|
||||
$query->where('identity_id', 1);
|
||||
})
|
||||
->get()
|
||||
->pluck('nickname', 'id');
|
||||
|
||||
$filter->where(function ($query) {
|
||||
$query->whereHas('outlet', function ($query) {
|
||||
$query->whereHas('parent', function ($query) {
|
||||
@@ -81,12 +78,12 @@ class CouponController extends AdminController
|
||||
|
||||
$grid->column('code', '卡券编号');
|
||||
$grid->column('status', '状态')
|
||||
->using(ActivityCoupon::STATUS)
|
||||
->label([
|
||||
1 => 'default',
|
||||
2 => 'warning',
|
||||
3 => 'info',
|
||||
]);
|
||||
->using(ActivityCoupon::STATUS)
|
||||
->label([
|
||||
1 => 'default',
|
||||
2 => 'warning',
|
||||
3 => 'info',
|
||||
]);
|
||||
|
||||
$grid->column('used_at', '核销时间');
|
||||
$grid->column('created_at', '创建时间');
|
||||
@@ -98,10 +95,10 @@ class CouponController extends AdminController
|
||||
return strip_tags($value);
|
||||
});
|
||||
$export->column('mobile', function ($value, $original) {
|
||||
return $value . "\t";
|
||||
return $value."\t";
|
||||
});
|
||||
|
||||
$export->filename($this->title . date("YmdHis"));
|
||||
$export->filename($this->title.date("YmdHis"));
|
||||
});
|
||||
|
||||
return $grid;
|
||||
|
||||
@@ -36,9 +36,7 @@ class IndexController extends AdminController
|
||||
$filter->between('start_at', '开始时间')->datetime();
|
||||
$filter->between('end_at', '结束时间')->datetime();
|
||||
$filter->equal('channel', '核销途径')->select(Activity::CHANNELS);
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$grid->column('id', '#ID#');
|
||||
@@ -50,27 +48,22 @@ class IndexController extends AdminController
|
||||
$grid->column('类型')->display(function () {
|
||||
return $this->type_text;
|
||||
});
|
||||
|
||||
$grid->column('channel', '核销途径')
|
||||
->using(Activity::CHANNELS)
|
||||
->label([
|
||||
Activity::CHANNEL_YSD => 'info',
|
||||
Activity::CHANNEL_UNION => 'success',
|
||||
]);
|
||||
|
||||
$grid->column('days', '延期(天)');
|
||||
$grid->column('rule.full', '满足金额');
|
||||
$grid->column('rule.take', '扣除金额');
|
||||
|
||||
$grid->column('发券渠道')->display(function ($title, $column) {
|
||||
return '查看';
|
||||
})->modal(Grants::class);
|
||||
|
||||
$grid->column('核券渠道')->display(function ($title, $column) {
|
||||
return '查看';
|
||||
})->modal(Verifications::class);
|
||||
|
||||
|
||||
$grid->column('开始时间')->display(function () {
|
||||
return $this->type == Activity::TYPE_SCOPE ? $this->start_at->format('Y-m-d') : '---';
|
||||
});
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Admin\Controllers\Activity;
|
||||
|
||||
use App\Admin\Renderable\Activity\Grants;
|
||||
use App\Models\ActivityCouponLog;
|
||||
use Encore\Admin\Controllers\HasResourceActions;
|
||||
use Encore\Admin\Grid;
|
||||
@@ -18,19 +17,21 @@ class LogController extends AdminController
|
||||
|
||||
/**
|
||||
* Get content title.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function title()
|
||||
protected function title(): string
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Index interface.
|
||||
*
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function index(Content $content)
|
||||
public function index(Content $content): Content
|
||||
{
|
||||
return $content
|
||||
->title($this->title())
|
||||
@@ -38,7 +39,7 @@ class LogController extends AdminController
|
||||
->body($this->grid());
|
||||
}
|
||||
|
||||
protected function grid()
|
||||
protected function grid(): Grid
|
||||
{
|
||||
$grid = new Grid(new ActivityCouponLog);
|
||||
|
||||
@@ -54,35 +55,30 @@ class LogController extends AdminController
|
||||
|
||||
$filter->column(1 / 2, function ($filter) {
|
||||
$filter->equal('status', '状态')->select(ActivityCouponLog::STATUS);
|
||||
|
||||
$filter->between('created_at', '开始时间')->datetime();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$grid->column('id', '#ID#');
|
||||
$grid->column('code', '卡券编号');
|
||||
$grid->column('type', '分类')
|
||||
->using(ActivityCouponLog::TYPES)
|
||||
->label([
|
||||
1 => 'default',
|
||||
2 => 'warning',
|
||||
3 => 'info',
|
||||
]);
|
||||
->using(ActivityCouponLog::TYPES)
|
||||
->label([
|
||||
1 => 'default',
|
||||
2 => 'warning',
|
||||
3 => 'info',
|
||||
]);
|
||||
|
||||
$grid->column('status', '状态')
|
||||
->using(ActivityCouponLog::STATUS)
|
||||
->label([
|
||||
1 => 'default',
|
||||
2 => 'warning',
|
||||
3 => 'info',
|
||||
]);
|
||||
->using(ActivityCouponLog::STATUS)
|
||||
->label([
|
||||
1 => 'default',
|
||||
2 => 'warning',
|
||||
3 => 'info',
|
||||
]);
|
||||
|
||||
$grid->column('remark', '处理结果');
|
||||
|
||||
$grid->column('created_at', '操作时间');
|
||||
|
||||
return $grid;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,10 +12,9 @@ use RuLong\Identity\Models\Identity;
|
||||
|
||||
class RuleController extends AdminController
|
||||
{
|
||||
|
||||
protected $title = '规则管理';
|
||||
|
||||
protected function grid()
|
||||
protected function grid(): Grid
|
||||
{
|
||||
$grid = new Grid(new ActivityRule);
|
||||
|
||||
@@ -34,15 +33,15 @@ class RuleController extends AdminController
|
||||
]);
|
||||
|
||||
$grid->column('created_at', '创建时间');
|
||||
|
||||
return $grid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a form builder.
|
||||
*
|
||||
* @return Form
|
||||
*/
|
||||
protected function form()
|
||||
protected function form(): Form
|
||||
{
|
||||
$form = new Form(new ActivityRule);
|
||||
|
||||
@@ -58,7 +57,7 @@ class RuleController extends AdminController
|
||||
$code = $form->code;
|
||||
|
||||
$ticket = explode('-', $code);
|
||||
if (!is_array($ticket) || count($ticket) != 3) {
|
||||
if (! is_array($ticket) || count($ticket) != 3) {
|
||||
$error = new MessageBag([
|
||||
'title' => '错误',
|
||||
'message' => '规则编号格式错误',
|
||||
@@ -79,5 +78,4 @@ class RuleController extends AdminController
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ class Activity extends Model
|
||||
|
||||
/**
|
||||
* 默认加载的关联
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $with = ['rule'];
|
||||
@@ -57,7 +58,7 @@ class Activity extends Model
|
||||
parent::boot();
|
||||
|
||||
self::creating(function ($model) {
|
||||
$model->code = 'ysd' . date('Ym') . mt_rand(100, 999);
|
||||
$model->code = 'ysd'.date('Ym').mt_rand(100, 999);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -87,6 +88,7 @@ class Activity extends Model
|
||||
|
||||
/**
|
||||
* Notes: 关联可发券渠道中间表
|
||||
*
|
||||
* @Author: 玄尘
|
||||
* @Date : 2020/8/21 11:09
|
||||
*/
|
||||
@@ -97,6 +99,7 @@ class Activity extends Model
|
||||
|
||||
/**
|
||||
* Notes: 可发券的渠道
|
||||
*
|
||||
* @Author: 玄尘
|
||||
* @Date : 2021/4/25 11:36
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
@@ -108,6 +111,7 @@ class Activity extends Model
|
||||
|
||||
/**
|
||||
* Notes: 关联可核券网点中间表
|
||||
*
|
||||
* @Author: 玄尘
|
||||
* @Date : 2020/8/21 11:09
|
||||
*/
|
||||
@@ -118,6 +122,7 @@ class Activity extends Model
|
||||
|
||||
/**
|
||||
* Notes: 关联可核销渠道
|
||||
*
|
||||
* @Author: 玄尘
|
||||
* @Date : 2020/8/21 11:09
|
||||
*/
|
||||
@@ -128,6 +133,7 @@ class Activity extends Model
|
||||
|
||||
/**
|
||||
* Notes: 可核销的渠道
|
||||
*
|
||||
* @Author: 玄尘
|
||||
* @Date : 2021/4/25 11:37
|
||||
*/
|
||||
@@ -138,6 +144,7 @@ class Activity extends Model
|
||||
|
||||
/**
|
||||
* Notes: 是否可以发券
|
||||
*
|
||||
* @Author: 玄尘
|
||||
* @Date : 2021/4/25 10:41
|
||||
* @return mixed
|
||||
@@ -149,28 +156,28 @@ class Activity extends Model
|
||||
|
||||
/**
|
||||
* Notes: 生成优惠券码
|
||||
*
|
||||
* @Author: 玄尘
|
||||
* @Date : 2021/4/25 10:41
|
||||
* @return mixed|string
|
||||
*/
|
||||
public function getCode()
|
||||
{
|
||||
|
||||
//判断生成何种码
|
||||
if ($this->channel == self::CHANNEL_UNION) {
|
||||
$code = '66406' . date('ymdHi') . mt_rand(10000, 99999);
|
||||
$code = '66406'.date('ymdHi').mt_rand(10000, 99999);
|
||||
} else {
|
||||
$code_length = config('pingan.code_length');
|
||||
|
||||
switch ($code_length) {
|
||||
case 17://17位长度
|
||||
$code = 'YSD' . substr(date('ymdHi'), 1) . mt_rand(10000, 99999);
|
||||
$code = 'YSD'.substr(date('ymdHi'), 1).mt_rand(10000, 99999);
|
||||
break;
|
||||
case 15://15位长度
|
||||
$code = 'YSD' . substr(date('ymdH'), 1) . mt_rand(10000, 99999);
|
||||
$code = 'YSD'.substr(date('ymdH'), 1).mt_rand(10000, 99999);
|
||||
break;
|
||||
default://默认15位长度
|
||||
$code = 'YSD' . substr(date('ymdH'), 1) . mt_rand(10000, 99999);
|
||||
$code = 'YSD'.substr(date('ymdH'), 1).mt_rand(10000, 99999);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -217,10 +224,7 @@ class Activity extends Model
|
||||
return $coupon;
|
||||
} catch (\Exception $e) {
|
||||
DB::rollback();
|
||||
|
||||
return $e->getMessage();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user