调整活动
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -8,3 +8,4 @@
|
||||
/storage/framework
|
||||
/storage/debugbar/
|
||||
/bootstrap/cache
|
||||
./composer.lock
|
||||
|
||||
@@ -24,11 +24,6 @@ class CouponController extends AdminController
|
||||
$filter->column(1 / 2, function ($filter) {
|
||||
$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) {
|
||||
$query->whereHas('info', function ($query) {
|
||||
@@ -98,10 +93,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;
|
||||
|
||||
@@ -94,6 +94,7 @@ class IndexController extends AdminController
|
||||
|
||||
/**
|
||||
* Make a form builder.
|
||||
*
|
||||
* @return Form
|
||||
*/
|
||||
protected function form(): Form
|
||||
@@ -122,6 +123,7 @@ class IndexController extends AdminController
|
||||
->when(Activity::TYPE_SCOPE, function (Form $form) {
|
||||
$form->dateRange('start_at', 'end_at', '有效时间');
|
||||
})
|
||||
->help('当月券,领取的月底到期')
|
||||
->required();
|
||||
|
||||
$form->radio('channel', '核销途径')
|
||||
@@ -130,6 +132,8 @@ class IndexController extends AdminController
|
||||
->help('券码核销的途径:亿时代是自己核销,银联是银联pos核销')
|
||||
->required();
|
||||
|
||||
$form->number('day_times','每天可用次数')->default(0)->help('每天可用次数,0未不限制');
|
||||
|
||||
$form->switch('status', '状态')->default(1);
|
||||
$form->switch('need_check', '多次校验')
|
||||
->default(1)
|
||||
@@ -222,11 +226,11 @@ class IndexController extends AdminController
|
||||
}
|
||||
|
||||
if (request()->start) {
|
||||
$form->start_at = $form->start_at . ' 00:00:01';
|
||||
$form->start_at = $form->start_at.' 00:00:01';
|
||||
}
|
||||
|
||||
if (request()->end_at) {
|
||||
$form->end_at = $form->end_at . ' 23:59:59';
|
||||
$form->end_at = $form->end_at.' 23:59:59';
|
||||
}
|
||||
|
||||
$shops = isset(request()->shops) ? array_filter(request()->shops['user_id']) : [];
|
||||
@@ -274,7 +278,7 @@ class IndexController extends AdminController
|
||||
|
||||
$shops = isset(request()->shops) ? array_filter(request()->shops['user_id']) : [];
|
||||
|
||||
if (!empty($shops)) {
|
||||
if (! empty($shops)) {
|
||||
//设置核销网点
|
||||
$users = [];
|
||||
foreach ($form->shops['user_id'] as $key => $user_id) {
|
||||
|
||||
@@ -20,9 +20,11 @@ class Activity extends Model
|
||||
|
||||
const TYPE_EXTEND = 1;
|
||||
const TYPE_SCOPE = 2;
|
||||
const TYPE_MONTH = 3;
|
||||
const TYPES = [
|
||||
self::TYPE_EXTEND => '延期',
|
||||
self::TYPE_SCOPE => '固定',
|
||||
self::TYPE_MONTH => '当月',
|
||||
];
|
||||
|
||||
const STATUS_OPEN = 1;
|
||||
@@ -48,6 +50,7 @@ class Activity extends Model
|
||||
|
||||
/**
|
||||
* 默认加载的关联
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $with = ['rule'];
|
||||
@@ -57,7 +60,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 +90,7 @@ class Activity extends Model
|
||||
|
||||
/**
|
||||
* Notes: 关联可发券渠道中间表
|
||||
*
|
||||
* @Author: 玄尘
|
||||
* @Date : 2020/8/21 11:09
|
||||
*/
|
||||
@@ -97,6 +101,7 @@ class Activity extends Model
|
||||
|
||||
/**
|
||||
* Notes: 可发券的渠道
|
||||
*
|
||||
* @Author: 玄尘
|
||||
* @Date : 2021/4/25 11:36
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
@@ -108,6 +113,7 @@ class Activity extends Model
|
||||
|
||||
/**
|
||||
* Notes: 关联可核券网点中间表
|
||||
*
|
||||
* @Author: 玄尘
|
||||
* @Date : 2020/8/21 11:09
|
||||
*/
|
||||
@@ -118,6 +124,7 @@ class Activity extends Model
|
||||
|
||||
/**
|
||||
* Notes: 关联可核销渠道
|
||||
*
|
||||
* @Author: 玄尘
|
||||
* @Date : 2020/8/21 11:09
|
||||
*/
|
||||
@@ -128,6 +135,7 @@ class Activity extends Model
|
||||
|
||||
/**
|
||||
* Notes: 可核销的渠道
|
||||
*
|
||||
* @Author: 玄尘
|
||||
* @Date : 2021/4/25 11:37
|
||||
*/
|
||||
@@ -138,6 +146,7 @@ class Activity extends Model
|
||||
|
||||
/**
|
||||
* Notes: 是否可以发券
|
||||
*
|
||||
* @Author: 玄尘
|
||||
* @Date : 2021/4/25 10:41
|
||||
* @return mixed
|
||||
@@ -149,28 +158,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;
|
||||
}
|
||||
|
||||
@@ -194,6 +203,9 @@ class Activity extends Model
|
||||
if ($this->type == SELF::TYPE_EXTEND) {
|
||||
$start_at = now();
|
||||
$end_at = now()->addDays($this->days);
|
||||
} elseif ($this->type == self::TYPE_MONTH) {
|
||||
$start_at = now();
|
||||
$end_at = now()->endOfMonth();
|
||||
} else {
|
||||
$start_at = $this->start_at->startOfDay();
|
||||
$end_at = $this->end_at->endOfDay();
|
||||
@@ -220,7 +232,5 @@ class Activity extends Model
|
||||
|
||||
return $e->getMessage();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ class ActivityCoupon extends Model
|
||||
* @Date : 2020/6/30 9:40
|
||||
* @return string
|
||||
*/
|
||||
public function getStatusTextAttribute()
|
||||
public function getStatusTextAttribute(): string
|
||||
{
|
||||
return self::STATUS[$this->status] ?? '未知';
|
||||
}
|
||||
@@ -48,7 +48,7 @@ class ActivityCoupon extends Model
|
||||
* @Date : 2020/6/30 9:41
|
||||
* @return bool
|
||||
*/
|
||||
public function canRedemption()
|
||||
public function canRedemption(): bool
|
||||
{
|
||||
return $this->status == ActivityCoupon::STATUS_INIT;
|
||||
}
|
||||
@@ -59,7 +59,7 @@ class ActivityCoupon extends Model
|
||||
* @Date : 2020/6/30 9:41
|
||||
* @return bool
|
||||
*/
|
||||
public function canDestroy()
|
||||
public function canDestroy(): bool
|
||||
{
|
||||
return $this->canRedemption();
|
||||
}
|
||||
@@ -70,7 +70,7 @@ class ActivityCoupon extends Model
|
||||
* @Date : 2020/10/12 11:57
|
||||
* @return bool
|
||||
*/
|
||||
public function canReversal()
|
||||
public function canReversal(): bool
|
||||
{
|
||||
return $this->status == self::STATUS_USED;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Models;
|
||||
|
||||
use App\Models\Traits\BelongsToOutlet;
|
||||
use App\Models\Traits\BelongsToUser;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
|
||||
class Coupon extends Model
|
||||
{
|
||||
@@ -22,7 +23,7 @@ class Coupon extends Model
|
||||
];
|
||||
|
||||
//状态
|
||||
public function getStatusTextAttribute()
|
||||
public function getStatusTextAttribute(): string
|
||||
{
|
||||
switch ($this->status) {
|
||||
case 0:
|
||||
@@ -46,7 +47,7 @@ class Coupon extends Model
|
||||
}
|
||||
}
|
||||
|
||||
public function getProfitTextAttribute()
|
||||
public function getProfitTextAttribute(): string
|
||||
{
|
||||
switch ($this->is_profit) {
|
||||
case 0:
|
||||
@@ -63,23 +64,25 @@ class Coupon extends Model
|
||||
|
||||
/**
|
||||
* 是否可以分润
|
||||
* @author 玄尘 2020-03-13
|
||||
*
|
||||
* @return bool [type] [description]
|
||||
* @author 玄尘 2020-03-13
|
||||
*/
|
||||
public function canProfit()
|
||||
public function canProfit(): bool
|
||||
{
|
||||
return ($this->is_profit === 0 && $this->status == 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分润
|
||||
* @author 玄尘 2020-03-13
|
||||
*
|
||||
* @return bool|string [type] [description]
|
||||
* @author 玄尘 2020-03-13
|
||||
*/
|
||||
public function profit()
|
||||
{
|
||||
$log = AccountLog::where('source->coupon_id', $this->id)->first();
|
||||
if (!$log && $this->user && $this->profit) {
|
||||
if (! $log && $this->user && $this->profit) {
|
||||
return $this->user->account->rule('freeze', $this->profit, false, [
|
||||
'coupon_id' => $this->id,
|
||||
'redemptionCode' => $this->redemptionCode,
|
||||
@@ -93,6 +96,7 @@ class Coupon extends Model
|
||||
|
||||
/**
|
||||
* Notes: 撤销
|
||||
*
|
||||
* @Author: 玄尘
|
||||
* @Date : 2020/10/12 13:56
|
||||
*/
|
||||
@@ -114,6 +118,7 @@ class Coupon extends Model
|
||||
|
||||
/**
|
||||
* Notes: 撤销分润
|
||||
*
|
||||
* @Author: 玄尘
|
||||
* @Date : 2020/10/9 14:07
|
||||
*/
|
||||
@@ -132,8 +137,9 @@ class Coupon extends Model
|
||||
|
||||
/**
|
||||
* 打款
|
||||
* @author 玄尘 2020-03-13
|
||||
*
|
||||
* @return bool|string [type] [description]
|
||||
* @author 玄尘 2020-03-13
|
||||
*/
|
||||
public function sendMoney()
|
||||
{
|
||||
@@ -160,6 +166,7 @@ class Coupon extends Model
|
||||
|
||||
/**
|
||||
* Notes: 格式化时间 年-月-日
|
||||
*
|
||||
* @Author: 玄尘
|
||||
* @Date : 2020/4/7 16:24
|
||||
* @return mixed
|
||||
@@ -169,4 +176,12 @@ class Coupon extends Model
|
||||
return $this->created_at->format('Y-m-d');
|
||||
}
|
||||
|
||||
/*
|
||||
* 关联自有券
|
||||
*/
|
||||
public function activityCoupon(): HasOne
|
||||
{
|
||||
return $this->hasOne(ActivityCoupon::class, 'code', 'redemptionCode');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
3671
composer.lock
generated
3671
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddDayTimesToActivitiesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('activities', function (Blueprint $table) {
|
||||
$table->integer('day_times')->default(0)->comment('每天可用次数');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('activities', function (Blueprint $table) {
|
||||
//
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user