コード例 #1
0
ファイル: UserRankStatics.php プロジェクト: xiongjiewu/shui
 /**
  * 回收亲水值
  * 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
 /**
  * 计算黑水值
  * Execute the console command.
  * @return mixed
  */
 public function fire()
 {
     $i = 0;
     $black_water_val = (int) getenv('BLACK_WATER');
     while (true) {
         $result = UserBase::where('user_id', '>', $i)->orderBy('user_id', 'asc')->limit($this->limit)->get()->toArray();
         if (empty($result)) {
             break;
         }
         foreach ($result as $value) {
             $user_login_log = UserLoginLog::where('user_id', $value['user_id'])->where('date', date('Ymd', strtotime('-1 day')))->first();
             if (empty($user_login_log)) {
                 $user_black_water = new UserBlackWater();
                 $user_black_water_result = $user_black_water->where('user_id', $value['user_id'])->first();
                 if (empty($user_black_water_result)) {
                     $user_black_water->user_id = $value['user_id'];
                     $user_black_water->black_water = $black_water_val;
                     $user_black_water->save();
                 } else {
                     $user_black_water->where('user_id', $value['user_id'])->update(['black_water' => $user_black_water_result->black_water + $black_water_val]);
                 }
             }
             $i = $value['user_id'];
         }
     }
 }
コード例 #3
0
ファイル: ActivityService.php プロジェクト: xiongjiewu/shui
 /**
  * 亲水圈活动详情
  * @param $params
  * @param $user_id
  * @return array
  */
 public function circleDetail($params, $user_id)
 {
     if (!$params->get('circleID')) {
         return ['status' => false, 'message' => '活动ID不能为空!', 'info' => []];
     }
     /** @var $activity \App\Model\Activity */
     $activity = new Activity();
     $activity_result = $activity->where('activity_id', $params->get('circleID'))->StatusOk()->first();
     if (empty($activity_result)) {
         return ['status' => false, 'message' => '活动不存在!', 'info' => []];
     }
     $activity_comment = new ActivityComment();
     $data['active_id'] = $params->get('circleID');
     $data['video_url'] = ActivityImage::getImages($params->get('circleID'), ActivityImage::TYPE_IMAGE_IS_GIF);
     $data['title'] = $activity_result->title;
     $data['content'] = $activity_result->desc;
     $data['address'] = $activity_result->address;
     $data['create_time'] = (string) $activity_result->created_at;
     $data['is_focus'] = UserFocus::userIsFocus($params->get('circleID'), $user_id);
     $data['support_count'] = $activity_result->focus_count;
     $data['comment_count'] = $activity_comment->where('activity_id', $params->get('circleID'))->count();
     $data['focus_count'] = (new UserFocus())->where('activity_id', $params->get('circleID'))->count();
     $activity_comment_result = $activity_comment->where('activity_id', $params->get('circleID'))->orderBy('created_at', 'desc')->limit(2)->get();
     if (!empty($activity_comment_result)) {
         $user_ids = [];
         foreach ($activity_comment_result as $activity_comment_result_v) {
             array_push($user_ids, $activity_comment_result_v->user_id);
         }
         $user_base = new UserBase();
         $user_base_result = $user_base->whereIn('user_id', $user_ids)->get();
         $user_image = new UserImage();
         $user_image_result = $user_image->whereIn('user_id', $user_ids)->get();
         $user_image_list = [];
         foreach ($user_image_result as $user_image_result_v) {
             $user_image_list[$user_image_result_v->user_id] = $user_image_result_v->path();
         }
         $user_list = [];
         foreach ($user_base_result as $user_base_result_v) {
             $user_list[$user_base_result_v->user_id] = ['id' => $user_base_result_v->user_id, 'name' => $user_base_result_v->user_name, 'image_url' => isset($user_image_list[$user_base_result_v->user_id]) ? $user_image_list[$user_base_result_v->user_id] : ActivityImage::defaultImage()];
         }
         foreach ($activity_comment_result as $activity_comment_result_v_v) {
             if (isset($user_list[$activity_comment_result_v_v->user_id])) {
                 $data['comment_list'][] = ['comment_id' => $activity_comment_result_v_v->id, 'comment_name' => $user_list[$activity_comment_result_v_v->user_id]['name'], 'comment_image_url' => $user_list[$activity_comment_result_v_v->user_id]['image_url'], 'comment_date' => (string) $activity_comment_result_v_v->created_at, 'comment_detail' => $activity_comment_result_v_v->content];
             }
         }
     }
     return ['status' => true, 'message' => '获取成功!', 'info' => $data];
 }
コード例 #4
0
ファイル: BusinessService.php プロジェクト: xiongjiewu/shui
 /**
  * 为商户设置新密码
  * @param $params
  * @param $user_id
  * @return array
  */
 public function setBusinessNewPassword($params, $user_id)
 {
     $new_password = $params->get('newPassword');
     if (trim($new_password) == '') {
         return ['status' => false, 'message' => '你的新密码不能为空!', 'info' => []];
     }
     $result = UserBase::where('user_id', $user_id)->update(['password' => $this->encryptPassword($new_password)]);
     if ($result) {
         return ['status' => true, 'message' => 'success', 'info' => []];
     } else {
         return ['status' => false, 'message' => '修改失败!', 'info' => []];
     }
 }
コード例 #5
0
ファイル: OrderService.php プロジェクト: xiongjiewu/shui
 /**
  * 充值流水
  */
 public function getOrderList()
 {
     /** @var \App\Model\OrderLog */
     $order_log = new OrderLog();
     $order = $order_log->orderBy('order_id', 'desc')->paginate(20);
     $user_id = [];
     foreach ($order as $v) {
         $array = $v->toArray();
         array_push($user_id, $array['user_id']);
     }
     $user_list = [];
     if (!empty($user_id)) {
         $user_result = UserBase::whereIn('user_id', $user_id)->get()->toArray();
         if ($user_result) {
             foreach ($user_result as $u) {
                 $user_list[$u['user_id']] = $u['user_name'];
             }
         }
     }
     $list = [];
     foreach ($order as &$o) {
         $a = $o->toArray();
         $a['name'] = isset($user_list[$a['user_id']]) ? $user_list[$a['user_id']] : '不存在的用户';
         $list[] = $a;
         unset($a);
     }
     return ['list' => $list, 'obj' => $order];
 }
コード例 #6
0
ファイル: UserService.php プロジェクト: xiongjiewu/shui
 /**
  * 第三方平台注册
  * @param $params
  * @return array
  */
 public function otherRegister($params)
 {
     if (!$params->get('open_id')) {
         return ['status' => false, 'message' => '用户唯一标识不能为空!'];
     }
     if (!$params->get('type')) {
         return ['status' => false, 'message' => '登入来源标识不能为空!'];
     }
     $user_third_parth = new UserThirdParty();
     $rt = $user_third_parth->where('user_other_id', $params->get('open_id'))->where('type', $params->get('type'))->first();
     $user_base = new UserBase();
     $user_image = new UserImage();
     //如果没注册过
     if (empty($rt) && in_array($params->get('type'), [UserThirdParty::TX_QQ, UserThirdParty::WEI_XIN])) {
         $user_base->invite_code = time() . mt_rand(100, 999);
         if ($params->get('nick_name')) {
             $user_base->user_name = $params->get('nick_name');
         }
         $user_base->save();
         if ($user_base->user_id) {
             $user_third_parth->user_other_id = $params->get('open_id');
             $user_third_parth->type = $params->get('type');
             $user_third_parth->user_id = $user_base->user_id;
             $user_third_parth->save();
             $image = $user_image->where('user_id', $user_base->user_id)->head()->first();
             if (empty($image)) {
                 $user_image->image_url = $params->get('head_img') ?: UserImage::defaultImage();
                 $user_image->user_id = $user_base->user_id;
                 $user_image->is_completion = UserImage::IS_COMPLETION_TRUE;
                 $user_image->type = UserImage::TYPE_HEAD;
                 $user_image->save();
             } else {
                 $user_image->where('user_id', $user_base->user_id)->where('type', UserImage::TYPE_HEAD)->update(['image_url' => $params->get('head_img') ?: UserImage::defaultImage()]);
             }
             if (UserFinancial::getInitialize() > 0) {
                 $user_financial = new UserFinancial();
                 $user_financial->user_id = $user_base->user_id;
                 $user_financial->water_count = UserFinancial::getInitialize();
                 $user_financial->save();
             }
         } else {
             return ['status' => false, 'message' => '系统一个人去旅行了,请稍后重试!'];
         }
         $user = $user_base->where('user_id', $user_base->user_id)->IsOpen()->first()->toArray();
         if ($params->get('head_img')) {
             $user['user_head'] = $params->get('head_img');
         } else {
             $user['user_head'] = UserImage::defaultImage();
         }
         $user['token'] = TokenService::tokenEncode($user_base->user_id);
         UserLoginLog::insert_login_log($user_base->user_id);
         return $this->outputFormat(true, 'success', $this->formatUser($user));
     }
     //如果已经注册过
     $user = $user_base->where('user_id', $rt->user_id)->IsOpen()->first()->toArray();
     $image = $user_image->where('user_id', $rt->user_id)->head()->first();
     if ($image) {
         $user['user_head'] = $image->path();
     } else {
         $user['user_head'] = UserImage::defaultImage();
     }
     $user['token'] = TokenService::tokenEncode($rt->user_id);
     UserLoginLog::insert_login_log($rt->user_id);
     return $this->outputFormat(true, 'success', $this->formatUser($user));
 }
コード例 #7
0
ファイル: WaterService.php プロジェクト: xiongjiewu/shui
 /**
  * 亲水列表
  * @param $params
  * @param $user_id
  * @return array
  */
 public function bagList($params, $user_id)
 {
     $page = $params->get('page') ?: 1;
     $count = $params->get('count') ?: 10;
     $user_send_water = new UserSendWater();
     $result = [];
     $send_water = 0;
     if ($params->get('status')) {
         switch ($params->get('status')) {
             case 0:
                 $result = $user_send_water->where('accept_user_id', $user_id)->where('status', UserSendWater::STATUS_IS_FALSE)->where('overdue_date', '>=', time())->skip(($page - 1) * $count)->take($count)->get()->toArray();
                 $send_water = $user_send_water->where('accept_user_id', $user_id)->where('status', UserSendWater::STATUS_IS_FALSE)->count();
                 break;
             case 1:
                 $result = $user_send_water->where('accept_user_id', $user_id)->where('status', UserSendWater::STATUS_IS_TRUE)->where('overdue_date', '>=', time())->skip(($page - 1) * $count)->take($count)->get()->toArray();
                 $send_water = $user_send_water->where('accept_user_id', $user_id)->where('status', UserSendWater::STATUS_IS_FALSE)->count();
                 break;
             case 2:
                 $result = $user_send_water->where('accept_user_id', $user_id)->whereBetween('status', [0, 2])->where('overdue_date', '<', time())->skip(($page - 1) * $count)->take($count)->get()->toArray();
                 $send_water = $user_send_water->where('status', UserSendWater::STATUS_IS_FALSE)->count();
                 break;
         }
     } else {
         $result = $user_send_water->where('accept_user_id', $user_id)->skip(($page - 1) * $count)->take($count)->get()->toArray();
         $send_water = $user_send_water->where('accept_user_id', $user_id)->count();
     }
     $next_page = ($page - 1) * $count >= $send_water ? $page : $page + 1;
     $pager = ['page' => $page, 'count' => $count, 'total' => $send_water, 'next' => $next_page];
     if (empty($result)) {
         return ['status' => true, 'message' => 'success', 'info' => [], 'pager' => $pager];
     }
     $user_ids = [];
     foreach ($result as $value) {
         $user_ids[] = $value['user_id'];
     }
     $user_result = UserBase::whereIn('user_id', array_unique($user_ids))->get()->toArray();
     $user_list = [];
     foreach ($user_result as $user_result_val) {
         $user_list[$user_result_val['user_id']] = $user_result_val['user_name'] ?: '匿名';
     }
     $list = [];
     foreach ($result as $value) {
         $list[] = ['bag_id' => $value['id'], 'water_num' => $value['water_count'], 'from_id' => $value['user_id'], 'from_name' => $user_list[$value['user_id']], 'create_time' => $value['created_at'], 'get_time' => $value['updated_at'], 'status' => $value['status']];
     }
     return ['status' => true, 'message' => 'success', 'info' => $list, 'pager' => $pager];
 }
コード例 #8
0
ファイル: ShareService.php プロジェクト: xiongjiewu/shui
 /**
  * 展示领取的信息
  * @param $code
  * @return array
  */
 public function shareShow($code)
 {
     $e = explode('-', $code);
     if (count($e) == 2) {
         $user_share_log = new UserShareLog();
         $user_share_log_tr = $user_share_log->where('share_time', $e[0])->first();
         $user_share_receive_log = new UserShareReceiveLog();
         $u_s_r_l = $user_share_receive_log->where('share_id', $user_share_log_tr->id)->get()->toArray();
         $user_ids = [];
         foreach ($u_s_r_l as $v) {
             array_push($user_ids, $v['share_receive_user_id']);
         }
         $user_base = new UserBase();
         $user_rt = $user_base->whereIn('user_id', $user_ids)->get()->toArray();
         foreach ($u_s_r_l as &$r) {
             $r['created_at'] = date('m.d H:s', strtotime($r['created_at']));
             foreach ($user_rt as $u) {
                 if ($r['share_receive_user_id'] == $u['user_id']) {
                     $r['user_name'] = !empty($u['user_name']) ? $u['user_name'] : '匿名';
                 }
             }
         }
         return ['status' => true, 'message' => '返回成功', 'info' => $u_s_r_l];
     } else {
         return ['status' => false, 'message' => '非法参数', 'info' => []];
     }
 }
コード例 #9
0
ファイル: UserController.php プロジェクト: xiongjiewu/shui
 public function update($user_id, $type, Request $request)
 {
     $user = UserBase::find($user_id);
     if (!$user) {
         return $this->returnAddJs('用户不存在');
     }
     $user_name = $request->get('user_name');
     if (!$user_name) {
         return $this->returnAddJs('用户名不能为空');
     }
     if ($type == 2) {
         //商家编辑
         $water_count = $request->get('water_count');
         if (!$water_count) {
             return $this->returnAddJs('请输入亲水值!');
         }
         $send_water = $request->get('send_water');
         if (!$send_water) {
             return $this->returnAddJs('请输入护水值!');
         }
         $image_url_real1 = $request->file('image_url_real1');
         if (!$image_url_real1->isValid()) {
             return $this->returnAddJs('营业执照无效');
         }
         if (strpos($image_url_real1->getMimeType(), 'image/') === false) {
             return $this->returnAddJs('营业执照格式不正确');
         }
         $image_url_real1_w = $this->updateFile($image_url_real1);
         if (!$image_url_real1_w) {
             return $this->returnAddJs('营业执照上传失败,请重新上传!');
         }
         $image_url_real2 = $request->file('image_url_real2');
         if ($image_url_real2) {
             if (!$image_url_real2->isValid()) {
                 return $this->returnAddJs('店铺实景1无效');
             }
             if (strpos($image_url_real2->getMimeType(), 'image/') === false) {
                 return $this->returnAddJs('店铺实景1格式不正确');
             }
             $image_url_real2_w = $this->updateFile($image_url_real2);
             if (!$image_url_real2) {
                 return $this->returnAddJs('店铺实景1上传失败,请重新上传!');
             }
         }
         $image_url_real3 = $request->file('image_url_real3');
         if ($image_url_real3) {
             if (!$image_url_real3->isValid()) {
                 return $this->returnAddJs('店铺实景2无效');
             }
             if (strpos($image_url_real3->getMimeType(), 'image/') === false) {
                 return $this->returnAddJs('店铺实景2格式不正确');
             }
             $image_url_real3_w = $this->updateFile($image_url_real3);
             if (!$image_url_real3_w) {
                 return $this->returnAddJs('店铺实景2上传失败,请重新上传!');
             }
         }
     }
     $image = $request->file('image');
     if (!$image->isValid()) {
         return $this->returnAddJs('图片无效');
     }
     if (strpos($image->getMimeType(), 'image/') === false) {
         return $this->returnAddJs('图片格式不正确');
     }
     $image_w = $this->updateFile($image);
     if (!$image_w) {
         return $this->returnAddJs('图片上传失败,请重新上传!');
     }
     $user->user_name = $user_name;
     $user->save();
     $user_image = UserImage::where('user_id', $user_id)->where('type', 1)->first();
     if (!$user_image) {
         $user_image_model = new UserImage();
         $user_image_model->user_id = $user_id;
         $user_image_model->image_url = $image_w;
         $user_image_model->type = 1;
         $user_image_model->is_completion = 0;
         $user_image_model->save();
     } else {
         $user_image->image_url = $image_w;
         $user_image->save();
     }
     if ($type == 2) {
         $user_desc = $request->get('user_desc', '');
         $user_f = UserFinancial::where('user_id', $user_id)->first();
         if (!$user_f) {
             $user_f = new UserFinancial();
             $user_f->user_id = $user_id;
         }
         $user_f->water_count = $water_count;
         $user_f->send_water = $send_water;
         $user_f->save();
         $user_c = UserCompanyExtend::where('user_id', $user_id)->first();
         if (!$user_c) {
             $user_c = new UserCompanyExtend();
             $user_c->user_id = $user_id;
         }
         $user_c->user_desc = $user_desc;
         $user_c->save();
         $user_image = UserImage::where('user_id', $user_id)->where('type', 2)->first();
         if (!$user_image) {
             $user_image_model = new UserImage();
             $user_image_model->user_id = $user_id;
             $user_image_model->image_url = $image_url_real1_w;
             $user_image_model->type = 2;
             $user_image_model->is_completion = 0;
             $user_image_model->save();
         } else {
             $user_image->image_url = $image_url_real1_w;
             $user_image->save();
         }
         if ($image_url_real2_w) {
             $user_image = UserImage::where('user_id', $user_id)->where('type', 3)->first();
             if (!$user_image) {
                 $user_image_model = new UserImage();
                 $user_image_model->user_id = $user_id;
                 $user_image_model->image_url = $image_url_real2_w;
                 $user_image_model->type = 3;
                 $user_image_model->is_completion = 0;
                 $user_image_model->save();
             } else {
                 $user_image->image_url = $image_url_real2_w;
                 $user_image->save();
             }
         }
         if ($image_url_real3_w) {
             $user_image = UserImage::where('user_id', $user_id)->where('type', 3)->first();
             if (!$user_image) {
                 $user_image_model = new UserImage();
                 $user_image_model->user_id = $user_id;
                 $user_image_model->image_url = $image_url_real3_w;
                 $user_image_model->type = 3;
                 $user_image_model->is_completion = 0;
                 $user_image_model->save();
             } else {
                 $user_image->image_url = $image_url_real3_w;
                 $user_image->save();
             }
         }
     }
     return $this->returnAddJs('编辑成功!');
 }