예제 #1
0
 /**
  * 回收亲水值
  * Execute the console command.
  * @return mixed
  */
 public function fire()
 {
     $i = 0;
     $rank = UserRank::getDefaultRank();
     while (true) {
         $user_financial_result = \DB::select('select * from user_financial where user_id > ? order by (water_count+0) desc limit ?', [$i, $this->limit]);
         if (empty($user_financial_result)) {
             break;
         }
         $user_base = new UserBase();
         foreach ($user_financial_result as $v) {
             $r = $user_base->where('user_id', $v->user_id)->first();
             if ($r['type'] == UserBase::TYPE_USER) {
                 $user_rank = new UserRank();
                 $rt = $user_rank->where('user_id', $v->user_id)->where('date', Carbon::now()->format('Ymd'))->first();
                 if (empty($rt)) {
                     $user_rank->user_id = $v->user_id;
                     $user_rank->rank = $rank;
                     $user_rank->date = Carbon::now()->format('Ymd');
                     $user_rank->save();
                     $rank += 1;
                 }
             }
             $i = $v->user_id;
         }
     }
 }
예제 #2
0
 /**
  * 水银行信息
  * @param $user_id
  * @return array
  */
 public function bankInfo($user_id)
 {
     $data = [];
     $user_black_water = UserBlackWater::where('user_id', $user_id)->first();
     $data['water_num'] = empty($user_black_water) ? 0 : $user_black_water->black_water;
     $user_financial = new UserFinancial();
     $data['person_water'] = $user_financial->sum('water_count');
     $user_financial_result = $user_financial->where('user_id', $user_id)->first();
     $data['protect_num'] = $user_financial_result ? $user_financial_result->water_count : 0;
     $data['water_rank'] = UserRank::getUserRank($user_id);
     return ['status' => true, 'message' => 'success', 'info' => $data];
 }