Ejemplo n.º 1
0
 /**
  * 商户设置简介
  * @param $params
  * @param $user_id
  * @return mixed
  */
 public function setBusinessNewInfo($params, $user_id)
 {
     $business_info = $params->get('businessInfo');
     if (trim($business_info) == '') {
         return ['status' => false, 'message' => '简介不能为空!', 'info' => []];
     }
     $result = UserCompanyExtend::where('user_id', $user_id)->update(['user_desc' => $business_info]);
     if ($result) {
         return ['status' => true, 'message' => 'success', 'info' => ['business_id' => $user_id, 'business_info' => $business_info]];
     } else {
         return ['status' => false, 'message' => '修改失败!', 'info' => []];
     }
 }
Ejemplo n.º 2
0
 /**
  * 水地图列表
  * @param $params
  * @return array
  */
 public function mapList($params)
 {
     if ($params->get('longitude') && $params->get('latitude')) {
         //            $squares = $this->returnSquarePoint($params->get('longitude'), $params->get('latitude'), $params->get('radius') ?: null);
         //            $result = UserCompanyExtend::where('user_company_lat', '>', '0')
         //                ->where('user_company_lat', '>=', $squares['right-bottom']['lat'])
         //                ->where('user_company_lat', '<=', $squares['left-top']['lat'])
         //                ->where('user_company_lng', '>=', $squares['left-top']['lng'])
         //                ->where('user_company_lng', '<=', $squares['right-bottom']['lng'])
         //                ->get();
         $user_company_extend = new UserCompanyExtend();
         $result = $user_company_extend->get();
         if (empty($result)) {
             return ['status' => true, 'message' => '获取成功!', 'info' => []];
         }
         $user_ids = [];
         foreach ($result as $result_val) {
             $user_ids[] = $result_val->user_id;
         }
         $user_images_result = UserImage::whereIn('user_id', $user_ids)->Head()->get();
         $images = [];
         if (!empty($user_images_result)) {
             foreach ($user_images_result as $user_images_result_val) {
                 $images[$user_images_result_val->user_id] = $user_images_result_val->path();
             }
         }
         $user_financial_result = UserFinancial::whereIn('user_id', $user_ids)->get();
         $financial = [];
         if (!empty($user_financial_result)) {
             foreach ($user_financial_result as $user_financial_result_val) {
                 $financial[$user_financial_result_val->user_id] = $user_financial_result_val->water_count;
             }
         }
         $data = [];
         foreach ($result as $result_value) {
             $data[] = ['store_id' => $result_value->user_id, 'store_name' => $result_value->user_company_name, 'image_url' => isset($images[$result_value->user_id]) ? $images[$result_value->user_id] : '', 'left_num' => isset($financial[$result_value->user_id]) ? $financial[$result_value->user_id] : 0, 'latitude' => $result_value->user_company_lat, 'longitude' => $result_value->user_company_lng, 'distance' => $this->getDistance($params->get('latitude'), $params->get('longitude'), $result_value->user_company_lat, $result_value->user_company_lng)];
         }
         return ['status' => true, 'msg' => 'success', 'info' => $data];
     } else {
         return ['status' => false, 'message' => '缺少经纬度参数!', 'info' => []];
     }
 }
Ejemplo n.º 3
0
 protected function formatUsers($users)
 {
     if (!$users) {
         return [];
     }
     $user_list = [];
     $user_ids = [];
     foreach ($users as $user) {
         $user_ids[] = $user->user_id;
         if ($user->type == UserBase::TYPE_ADMIN) {
             $type_text = '管理员';
         } elseif ($user->type == UserBase::TYPE_BUSINESS) {
             $type_text = '商家';
         } else {
             $type_text = '用户';
         }
         $user_list[] = array_merge($user->toArray(), ['type_text' => $type_text, 'status_text' => $user->isOpen() ? '已激活' : '未激活', 'is_active' => $user->isOpen(), 'image_url' => '', 'image_url_real1' => '', 'image_url_real2' => '', 'image_url_real3' => '', 'water_count' => 0, 'black_water' => 0, 'send_water' => 0, 'public_count' => 0, 'giving' => 0, 'user_address' => '', 'user_desc' => '', 'user_http' => '', 'user_company_lat' => '', 'user_company_lng' => '']);
     }
     //获得头像信息
     $user_image_rt = UserImage::whereIn('user_id', $user_ids)->get();
     foreach ($user_list as &$user) {
         foreach ($user_image_rt as $user_image_rt_v) {
             if ($user_image_rt_v->type == 1 && $user['user_id'] == $user_image_rt_v->user_id) {
                 $user['image_url'] = $user_image_rt_v->path();
             } elseif ($user_image_rt_v->type == 2 && $user['user_id'] == $user_image_rt_v->user_id) {
                 $user['image_url_real1'] = $user_image_rt_v->path();
             } elseif (empty($user['image_url_real2']) && $user_image_rt_v->type == 3 && $user['user_id'] == $user_image_rt_v->user_id) {
                 $user['image_url_real2'] = $user_image_rt_v->path();
             } elseif ($user_image_rt_v->type == 3 && $user['user_id'] == $user_image_rt_v->user_id) {
                 $user['image_url_real3'] = $user_image_rt_v->path();
             }
         }
     }
     //获得亲水值
     $user_financial_rt = UserFinancial::whereIn('user_id', $user_ids)->get();
     foreach ($user_list as &$user) {
         foreach ($user_financial_rt as $user_financial_rt_v) {
             if ($user['user_id'] == $user_financial_rt_v->user_id) {
                 $user['water_count'] = $user_financial_rt_v->water_count;
                 $user['send_water'] = $user_financial_rt_v->send_water;
                 $user['public_count'] = $user_financial_rt_v->public_count;
                 $user['giving'] = $user_financial_rt_v->giving;
             }
         }
     }
     //获得黑水值
     $user_black_rt = UserBlackWater::whereIn('user_id', $user_ids)->get();
     foreach ($user_list as &$user) {
         foreach ($user_black_rt as $user_black_rt_v) {
             if ($user['user_id'] == $user_black_rt_v->user_id) {
                 $user['black_water'] = $user_black_rt_v->send_water;
             }
         }
     }
     //获得公司信息
     $user_company_extend_rt = UserCompanyExtend::whereIn('user_id', $user_ids)->get();
     foreach ($user_list as &$user) {
         foreach ($user_company_extend_rt as $user_company_extend_rt_v) {
             if ($user['user_id'] == $user_company_extend_rt_v->user_id) {
                 $user['user_address'] = $user_company_extend_rt_v->user_address;
                 $user['user_company_name'] = $user_company_extend_rt_v->user_company_name;
                 $user['user_desc'] = $user_company_extend_rt_v->user_desc;
                 $user['user_http'] = $user_company_extend_rt_v->user_http;
                 $user['user_company_lat'] = $user_company_extend_rt_v->user_company_lat;
                 $user['user_company_lng'] = $user_company_extend_rt_v->user_company_lng;
             }
         }
     }
     return $user_list;
 }
Ejemplo n.º 4
0
 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('编辑成功!');
 }