[更新] 调整活动

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

@@ -10,6 +10,11 @@ class Activity extends Model
use BelongsToUser;
protected $dates = [
'start_at',
'end_at',
];
const TYPE_EXTEND = 1;
const TYPE_SCOPE = 2;
const TYPES = [
@@ -24,9 +29,11 @@ class Activity extends Model
self::STATUS_CLOSE => '关闭',
];
protected $dates = [
'start_at',
'end_at',
const CHANNEL_YSD = 1;
const CHANNEL_UNION = 2;
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] ?? '未知';
}
@@ -100,8 +107,13 @@ class Activity extends Model
{
try {
// $code = 'YSD' . date('ymd') . mt_rand(100000, 999999);
$code = '66406' . date('ymdH') . mt_rand(1000000, 9999999);
//判断生成何种码
if ($this->channel == self::CHANNEL_UNION) {
$code = '66406' . date('ymdH') . mt_rand(1000000, 9999999);
} else {
$code = 'YSD' . date('ymd') . mt_rand(100000, 999999);
}
if ($this->type == SELF::TYPE_EXTEND) {
$start_at = now();
$end_at = now()->addDays($this->days);