修改活动规则

This commit is contained in:
2020-08-25 15:20:23 +08:00
parent 04a74e763e
commit e63e80ac46
2 changed files with 14 additions and 2 deletions

View File

@@ -3,6 +3,7 @@
namespace App\Observers;
use App\Models\ActivityRule;
use App\Models\UserCode;
use RuLong\Identity\Models\IdentityCode;
class ActivityRuleObserver
@@ -33,7 +34,16 @@ class ActivityRuleObserver
*/
public function updated(ActivityRule $rule)
{
//
info(json_encode($rule));
$info = IdentityCode::where('code', $rule->code)->exists();
if (!$info) {
IdentityCode::create([
'identity_id' => 1,
'name' => $rule->title,
'code' => $rule->code,
'profit' => 0,
]);
}
}
/**
@@ -43,7 +53,8 @@ class ActivityRuleObserver
*/
public function deleted(ActivityRule $rule)
{
IdentityCode::where('code', $rule->code)->delete();
UserCode::where('code', $rule->code)->delete();
}
/**

View File

@@ -29,6 +29,7 @@ class YsdQuery extends Init
throw new \Exception('操作失败,未查到活动信息');
}
//获取所有可核销渠道
$verifications = $activity->verifications()->pluck('user_id');
if ($verifications->isEmpty()) {