重写生产券码规则
This commit is contained in:
@@ -102,17 +102,28 @@ class Activity extends Model
|
|||||||
return $this->status;
|
return $this->status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getCode($code = 'YSD200907684743')
|
||||||
|
{
|
||||||
|
//判断生成何种码
|
||||||
|
if ($this->channel == self::CHANNEL_UNION) {
|
||||||
|
$code = '66406' . date('ymdHi') . mt_rand(10000, 99999);
|
||||||
|
} else {
|
||||||
|
$code = 'YSD' . substr(date('ymd'), 1) . mt_rand(100000000, 999999999);
|
||||||
|
}
|
||||||
|
|
||||||
|
$exists = ActivityCoupon::where('code', $code)->exists();
|
||||||
|
if ($exists) {
|
||||||
|
return $this->getCode(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $code;
|
||||||
|
}
|
||||||
|
|
||||||
//发券
|
//发券
|
||||||
public function grant($mobile, $outletId = null)
|
public function grant($mobile, $outletId = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//判断生成何种码
|
$code = $this->getCode();
|
||||||
if ($this->channel == self::CHANNEL_UNION) {
|
|
||||||
$code = '66406' . date('ymdHi') . mt_rand(10000, 99999);
|
|
||||||
} else {
|
|
||||||
$code = 'YSD' . substr(date('ymdHi'), 1) . mt_rand(100, 999);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->type == SELF::TYPE_EXTEND) {
|
if ($this->type == SELF::TYPE_EXTEND) {
|
||||||
$start_at = now();
|
$start_at = now();
|
||||||
|
|||||||
Reference in New Issue
Block a user