'拆分活动的校验权限,分为发券和核券。'
This commit is contained in:
@@ -68,6 +68,28 @@ class Activity extends Model
|
||||
return $this->hasMany(ActivityCoupon::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 关联可发券渠道
|
||||
* @Author: 玄尘
|
||||
* @Date : 2020/8/21 11:09
|
||||
*/
|
||||
public function grants()
|
||||
{
|
||||
return $this->hasMany(ActivityGrant::class);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 关联可核销渠道
|
||||
* @Author: 玄尘
|
||||
* @Date : 2020/8/21 11:09
|
||||
*/
|
||||
public function verifications()
|
||||
{
|
||||
return $this->hasMany(ActivityVerification::class);
|
||||
|
||||
}
|
||||
|
||||
//发券
|
||||
public function grant($mobile, $outletId = null)
|
||||
{
|
||||
|
||||
@@ -2,12 +2,13 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Traits\BelongsToActivity;
|
||||
use App\Models\Traits\BelongsToOutlet;
|
||||
|
||||
class ActivityCoupon extends Model
|
||||
{
|
||||
|
||||
use BelongsToOutlet;
|
||||
use BelongsToOutlet, BelongsToActivity;
|
||||
|
||||
protected $dates = [
|
||||
'start_at',
|
||||
@@ -30,17 +31,6 @@ class ActivityCoupon extends Model
|
||||
*/
|
||||
protected $with = ['activity'];
|
||||
|
||||
/**
|
||||
* Notes: 关联活动
|
||||
* @Author: 玄尘
|
||||
* @Date : 2020/6/30 9:40
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function activity()
|
||||
{
|
||||
return $this->belongsTo(Activity::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 卡券状态
|
||||
* @Author: 玄尘
|
||||
|
||||
12
app/Models/ActivityGrant.php
Normal file
12
app/Models/ActivityGrant.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Traits\BelongsToActivity;
|
||||
use App\Models\Traits\BelongsToUser;
|
||||
|
||||
class ActivityGrant extends Model
|
||||
{
|
||||
|
||||
use BelongsToActivity, BelongsToUser;
|
||||
}
|
||||
12
app/Models/ActivityVerification.php
Normal file
12
app/Models/ActivityVerification.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Traits\BelongsToActivity;
|
||||
use App\Models\Traits\BelongsToUser;
|
||||
|
||||
class ActivityVerification extends Model
|
||||
{
|
||||
|
||||
use BelongsToActivity, BelongsToUser;
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
class PinganToken extends Model
|
||||
{
|
||||
|
||||
protected $dates = [
|
||||
'get_token_time',
|
||||
];
|
||||
|
||||
23
app/Models/Traits/BelongsToActivity.php
Normal file
23
app/Models/Traits/BelongsToActivity.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Traits;
|
||||
|
||||
use App\Models\Activity;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
trait BelongsToActivity
|
||||
{
|
||||
|
||||
/**
|
||||
* Notes: 关联活动
|
||||
* @Author: 玄尘
|
||||
* @Date : 2020/6/30 9:40
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function activity()
|
||||
{
|
||||
return $this->belongsTo(Activity::class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,14 +16,12 @@ class User extends Authenticatable
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $guarded = [];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for arrays.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $hidden = [
|
||||
@@ -91,7 +89,7 @@ class User extends Authenticatable
|
||||
/**
|
||||
* Notes: 密码加密
|
||||
* @Author: <C.Jason>
|
||||
* @Date: 2019/9/6 11:37
|
||||
* @Date : 2019/9/6 11:37
|
||||
* @param $password
|
||||
*/
|
||||
protected function setPasswordAttribute($password)
|
||||
@@ -129,12 +127,12 @@ class User extends Authenticatable
|
||||
public function getCouponCount($type, $date = '')
|
||||
{
|
||||
return $this->coupons()
|
||||
->whereIn('status', [2])
|
||||
->where('thirdPartyGoodsId', $type)
|
||||
->when($date, function ($q) {
|
||||
$q->whereDate('created_at', now()->format('Y-m-d'));
|
||||
})
|
||||
->count();
|
||||
->whereIn('status', [2])
|
||||
->where('thirdPartyGoodsId', $type)
|
||||
->when($date, function ($q) {
|
||||
$q->whereDate('created_at', now()->format('Y-m-d'));
|
||||
})
|
||||
->count();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,8 +4,10 @@ namespace App\Models;
|
||||
|
||||
class UserCode extends Model
|
||||
{
|
||||
|
||||
protected $casts = [
|
||||
'codes' => 'array',
|
||||
'profit' => 'array',
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ class UserInfo extends Model
|
||||
/**
|
||||
* Notes: 获取性别的文字显示
|
||||
* @Author: <C.Jason>
|
||||
* @Date: 2019/9/12 09:46
|
||||
* @Date : 2019/9/12 09:46
|
||||
* @return string
|
||||
*/
|
||||
protected function getSexTextAttribute()
|
||||
@@ -35,7 +35,7 @@ class UserInfo extends Model
|
||||
/**
|
||||
* Notes: 处理默认头像
|
||||
* @Author: <C.Jason>
|
||||
* @Date: 2019/9/12 13:44
|
||||
* @Date : 2019/9/12 13:44
|
||||
* @param $avatar
|
||||
* @return string
|
||||
*/
|
||||
|
||||
@@ -6,6 +6,6 @@ use App\Models\Traits\BelongsToUser;
|
||||
|
||||
class UserPingan extends Model
|
||||
{
|
||||
use BelongsToUser;
|
||||
|
||||
use BelongsToUser;
|
||||
}
|
||||
|
||||
@@ -4,8 +4,10 @@ namespace App\Models;
|
||||
|
||||
class WoCouponLog extends Model
|
||||
{
|
||||
|
||||
public function coupon()
|
||||
{
|
||||
return $this->belongsTo(WoCoupon::class, 'wo_coupon_id', 'id');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user