with('wallet') ->where('create_at','> time',$last_year) ->select()->toArray(); foreach ($user_list as $v) { // 一年内获得的经验值 $exp = UserExpLog::where('create_at','> time',$last_year) ->where('user_id','=',$v['id']) ->where('is_deleted','=',0) ->where('exp','>',0) ->sum('exp'); // 经验过期 if($exp < $v['wallet']['level_exp']) { UserWallet::userExpChange($v['id'],$v['wallet']['level_exp']-$exp,'经验过期',-1); $v['wallet']['level_exp'] = $exp; // 更新会员等级 UserIdentity::userLevel($v,$user_level,$v['id']); } //近一年获得的积分 $integral = UserIntegralLog::where('create_at','> time',$last_year) ->where('user_id','=',$v['id']) ->where('type','in',[5,6,7]) ->where('is_deleted','=',0) ->where('integral','>',0) ->sum('integral'); // 积分过期 if($integral < $v['wallet']['integral']) UserWallet::userIntegralChange($v['id'],$v['wallet']['integral']-$integral,'积分过期',8,-1); // 不是分销商跳过 if(!$v['is_partner']) continue; // 成长值 $growth = UserGrowthLog::where('create_at','> time',$last_year) ->where('user_id','=',$v['id']) ->where('growth','>',0) ->sum('growth'); // 成长值 过期 if($growth < $v['wallet']['growth']) { UserWallet::userGrowthChange($v['id'],$v['wallet']['growth']-$growth,8,'成长值过期',-1); $v['wallet']['growth'] = $growth; // 更新会员 UserIdentity::userPartnerLevel($v,$partner_level,$v['id']); } } $this->success('执行'.count($user_list).'条数据'); } // 会员优惠券过期定时 public function couponOverTime() { UserCouponList::where([['type','=',1],['end','< time',date('Y-m-d')],['status','=',0]])->update(['status'=>2]); } }