public function getCities() { $key = Input::get('key', ''); $province = Input::get('province', ''); $ver = Input::get('ver', 0); $currentVer = \DicCity::VER; if ($ver >= $currentVer && !$key) { return Response::json(['result' => 2000, 'data' => [], 'info' => '获取城市成功', 'ver' => $currentVer]); } try { $query = \DicCity::where('c_id', '>', 0); if ($key) { $query = $query->where('c_name', 'LIKE', '%' . $key . '%'); } if ($province) { $query = $query->where('c_province_id', '=', $province); } $list = $query->get(); $data = []; foreach ($list as $key => $city) { $data[] = $city->showInList(); } $paginate = ['total_record' => $list->count(), 'total_page' => 1, 'per_page' => $list->count(), 'current_page' => 1]; $re = ['result' => 2000, 'data' => $data, 'info' => '获取城市成功', 'ver' => $currentVer, 'pagination' => $paginate]; } catch (Exception $e) { $re = ['result' => 2001, 'data' => [], 'info' => '获取城市失败:' . $e->getMessage(), 'ver' => $currentVer]; } return Response::json($re); }
public function city() { $city = DicCity::where('c_id', '=', $this->c_id)->where('c_province_id', '=', $this->p_id)->first(); if (empty($city)) { $data['id'] = ''; $data['name'] = ''; $data['province_id'] = ''; } else { $data = $city->showInList(); } return $data; }
public function login($u_id) { $user = User::find($u_id); if (empty($user)) { throw new Exception("没有找到用户", 3005); } if ($user->u_status != 1) { throw new Exception("您的账号不可用, 请联系客服", 3005); } $re = []; $re['token'] = $user->u_token; $now = new Datetime(); $now->modify('+ 30 days'); $re['expire'] = $now->format('Y-m-d H:i:s'); $re['id'] = $user->u_id; $re['name'] = $user->u_name = $this->u_nickname; $re['nickname'] = $user->u_nickname = $this->u_nickname; $re['invite_code'] = $user->u_invite_code; $re['head_img'] = $user->u_head_img = $this->u_head_img; $re['biograph'] = $user->u_biograph; $school = DicSchool::find($user->u_school_id); if (empty($school)) { $re['city'] = null; $re['school'] = null; } else { $re['city'] = DicCity::where('c_id', '=', $school->t_city)->where('c_province_id', '=', $school->t_province)->first()->showInList(); $re['school'] = $school->showInList(); } $user->save(); $re['gender'] = $user->u_sex; $user->load('booths'); $booths = null; if (!empty($user->booths)) { foreach ($user->booths as $key => $booth) { $booths[] = $booth->showInLogin(); } } $re['boohts'] = $booths; return $re; }
public function showDetail() { $this->loadImg(); $data = []; $data['id'] = $this->b_id; $data['title'] = $this->b_title; $data['desc'] = $this->b_desc; $data['type'] = $this->b_type; $data['category'] = $this->b_product_category; $data['source'] = $this->b_product_source; $data['logo'] = $this->getLogo(); $data['cover_img'] = Img::filterKey('cover_img', $this->_imgs); $data['fans'] = $this->b_fans_count; $data['status'] = $this->b_status; $data['lng'] = $this->longitude; $data['lat'] = $this->latitude; $data['cust_group'] = $this->b_customer_group; $data['promo_strategy'] = $this->b_promo_strategy; $data['is_fund'] = $this->b_with_fund; $data['open'] = $this->b_open; $data['open_from'] = $this->b_open_from; $data['open_to'] = $this->b_open_to; $data['open_on'] = $this->open_on; $data['status'] = $this->b_status; $data['remark'] = $this->remark; $data['praise_count'] = $this->b_praise_count; $user = null; if (!empty($this->user)) { $user = $this->user->showInList(); } $data['user'] = $user; if (!empty($this->school)) { $data['school'] = $this->school->showInList(); $data['city'] = DicCity::where('c_id', '=', $this->school->t_city)->where('c_province_id', '=', $this->school->t_province)->first()->showInList(); } return $data; }
public function showDetail() { $data = $this->showBaseData(); $data['content'] = $this->getContent(); $date = new DateTime($this->created_at); $data['created_at'] = $date->format('Y-m-d'); $data['yield_time'] = $this->c_yield_time; $data['shipping'] = $this->c_shipping; $data['shipping_fee'] = $this->c_shipping_fee; $data['mobile'] = $this->u_mobile; $data['yield_desc'] = $this->c_yield_desc; $data['current_time'] = Tools::getNow(); $data['is_schedule'] = $this->c_is_schedule; $data['open_file'] = $this->c_open_file; if ($this->product) { $data['p_id'] = $this->product->p_id; $data['price'] = $this->product->p_price; $data['percentage'] = $this->product->getPercentage(); $data['sold_quantity'] = $this->product->p_sold_quantity; $data['target_quantity'] = $this->product->p_target_quantity; if ($this->product->p_max_quantity == $this->product->p_target_quantity) { $data['is_limit'] = 1; } else { $data['is_limit'] = 0; } } if (!empty($this->user)) { $data['user'] = $this->user->showInList(); if (!empty($this->user->school)) { $data['school'] = $this->user->school->showInList(); $data['city'] = DicCity::where('c_id', '=', $this->user->school->t_city)->where('c_province_id', '=', $this->user->school->t_province)->first()->showInList(); } } if ($this->replies) { $tmp = []; foreach ($this->replies as $key => $reply) { $tmp[] = $reply->showInList(); } $data['replies'] = $tmp; } return $data; }
/** * show detailed data * @author Kydz 2015-06-24 * @return array detai info */ public function showDetail() { if (!isset($this->u_id)) { throw new Exception("no such user", 1); } $data = []; $data['id'] = $this->u_id; $data['mobile'] = $this->u_mobile; $data['nickname'] = $this->u_nickname; $data['age'] = $this->u_age; $data['name'] = $this->u_name; $data['gender'] = $this->u_sex; $data['sex'] = $this->u_sex; $data['praise_count'] = $this->u_praise_count; if (!empty($this->u_birthday)) { $birthday = new DateTime($this->u_birthday); $birthday = $birthday->format('Y-m-d'); } else { $birthday = ''; } $data['birth'] = $birthday; $data['head_img'] = $this->getHeadImg(); $data['school_id'] = $this->u_school_id; $data['created_at'] = $this->created_at->format('Y-m-d H:i:s'); $data['follower_count'] = $this->u_follower_count; $data['following_count'] = $this->u_following_count; $data['status'] = $this->u_status; $data['remark'] = $this->u_remark; $data['home_imgs'] = Img::toArray($this->u_home_img, true); $data['is_verified'] = $this->u_is_verified; $data['verify'] = $this->getVerify(); $data['biograph'] = $this->u_biograph; $data['age'] = $this->u_age; $data['lat'] = $this->latitude; $data['lng'] = $this->longitude; if (!empty($this->school)) { $data['school'] = $this->school->showInList(); $data['city'] = DicCity::where('c_id', '=', $this->school->t_city)->where('c_province_id', '=', $this->school->t_province)->first()->showInList(); } return $data; }