更新代码
This commit is contained in:
66
app/Bonus/Full.php
Normal file
66
app/Bonus/Full.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Bonus;
|
||||
|
||||
use App\Events\ShareFullCompleted;
|
||||
use Carbon\Carbon;
|
||||
use RuLong\Bonus\Contracts\Settlement;
|
||||
use RuLong\Bonus\Traits\Settlementable;
|
||||
use RuLong\Identity\Models\UserIdentity;
|
||||
use RuLong\UserAccount\Models\UserAccountLog;
|
||||
|
||||
class Full implements Settlement
|
||||
{
|
||||
use Settlementable;
|
||||
|
||||
public $config;
|
||||
public $user;
|
||||
public $other = [];
|
||||
public $fullPoint;
|
||||
public function __construct($user, array $other = null)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->other = $other;
|
||||
}
|
||||
|
||||
/**
|
||||
* 直接推荐成单
|
||||
* @Author:<Leady>
|
||||
* @Date:2018-11-05T13:21:47+0800
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function fire()
|
||||
{
|
||||
if ($this->user->identity->identity_id == 0) {
|
||||
return false;
|
||||
}
|
||||
$this->config = $this->user->identity->info->configs; //获取当前身份配置
|
||||
$this->fullPoint = config('rulong_bonus.full_point'); //获取每日满仓数值,配置文件
|
||||
$timeBetween = [date('Y-m-d') . ' 00:00:00', date('Y-m-d') . ' 23:59:59']; //当前时间区域
|
||||
$childrenIds = $this->user->children()->pluck('id'); //拉入直推会员ID
|
||||
$directDay = UserIdentity::whereBetween('created_at', $timeBetween)
|
||||
->when($childrenIds, function ($query) use ($childrenIds) {
|
||||
$query->whereIn('user_id', $childrenIds);
|
||||
})->count() + ($this->other['sub'] ?? 1); //统计今天激活的会员数量
|
||||
if ($directDay === $this->fullPoint) {
|
||||
//满足当日满仓条件
|
||||
//准备执行赠送产品
|
||||
if ($this->user->account->act_a == 0) {
|
||||
//满仓记录等于0执行赠送商品流程
|
||||
event(new ShareFullCompleted($this->user));
|
||||
}
|
||||
//增加满仓记录
|
||||
$logs = UserAccountLog::where('user_id', $this->user->id)
|
||||
->where('type', 'act_a')
|
||||
->whereBetween('created_at', [Carbon::today()->toDateTimeString(), Carbon::tomorrow()->toDateTimeString()])
|
||||
->count() ?: 0;
|
||||
if ($logs == 0) {
|
||||
$this->user->rule('full', 1, false);
|
||||
}
|
||||
//判断是否连续满仓
|
||||
Continuous::settlement($this->user);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user