'拆分活动的校验权限,分为发券和核券。'
This commit is contained in:
@@ -18,15 +18,18 @@ class YsdGrant extends Init
|
||||
return '发券失败,没有找到这个活动。';
|
||||
}
|
||||
|
||||
if ($activity->user) {
|
||||
$info = User::where('outlet_id', $this->outletId)->first();
|
||||
if (!$info) {
|
||||
return '发券失败,未查询到此网点信息。';
|
||||
}
|
||||
$outlet = User::where('outlet_id', $this->outletId)->first();
|
||||
if (!$outlet) {
|
||||
return '发券失败,未查询到此网点信息。';
|
||||
}
|
||||
|
||||
if ($info->parent_id != $activity->user_id) {
|
||||
return '发券失败,您没有权限参加这个活动!';
|
||||
}
|
||||
$grants = $activity->grants()->pluck('user_id');
|
||||
if ($grants->isEmpty()) {
|
||||
return '发券失败,此活动还没有配置可发券渠道,请联系相关人员进行配置。';
|
||||
}
|
||||
|
||||
if (!in_array($outlet->parent_id, $grants->toArray())) {
|
||||
return '发券失败,您没有权限发此类优惠券。';
|
||||
}
|
||||
|
||||
$coupon = $activity->grant($this->mobile, $this->outletId);
|
||||
|
||||
@@ -24,8 +24,19 @@ class YsdQuery extends Init
|
||||
throw new \Exception('卡券编号错误,未查询到卡券信息');
|
||||
}
|
||||
|
||||
if ($coupon->activity->user_id > 0 && $info->parent_id != $coupon->activity->user_id) {
|
||||
throw new \Exception('您没有权限查询此卡券信息。');
|
||||
$activity = $coupon->activity;
|
||||
if (!$activity) {
|
||||
throw new \Exception('操作失败,未查到活动信息');
|
||||
}
|
||||
|
||||
$verifications = $activity->verifications()->pluck('user_id');
|
||||
|
||||
if ($verifications->isEmpty()) {
|
||||
throw new \Exception('操作失败,此活动还没有配置可核券渠道,请联系相关人员进行配置。');
|
||||
}
|
||||
|
||||
if (!in_array($info->parent_id, $verifications->toArray())) {
|
||||
throw new \Exception('操作失败,您没有权限查询此卡券信息。');
|
||||
}
|
||||
|
||||
return $coupon;
|
||||
|
||||
@@ -104,10 +104,6 @@ class YsdVerification extends Init
|
||||
return '核销失败,优惠券不可核销';
|
||||
}
|
||||
|
||||
if ($this->query_coupon->activity->user_id > 0 && $this->user->id !== $this->query_coupon->activity->user_id) {
|
||||
return '核销失败,您没有权限核销此优惠券。';
|
||||
}
|
||||
|
||||
$now = now();
|
||||
|
||||
if ($this->query_coupon->start_at->gt($now)) {
|
||||
|
||||
Reference in New Issue
Block a user