/** * 获取我收藏的店铺,最多5个 * @return */ public function getMyStore() { if (!Auth::check()) { return array('url' => 'personal/collection/shop', 'data' => array()); } $user = Auth::user(); $stores = CollectShop::where('uid', $user->front_uid)->orderBy('uptime', 'desc')->take(5)->lists('shop_id'); $my_store = array(); $my_store['url'] = 'personal/collection/shop'; $my_store['data'] = array(); foreach ($stores as $store) { $onestore = array(); $shop = Shop::find($store); $onestore['shop_id'] = $shop->id; #TODO:place_id不需要 $onestore['place_id'] = '123'; // ----------------------------------------后期可能是x和y $onestore['shop_url'] = 'shop/' . $shop->id; // 点击跳转到相应商家 $onestore['shop_logo'] = $shop->pic; // 商家的logo图片地址 $onestore['deliver_time'] = $shop->interval; // 送货时间间隔 $onestore['deliver_start'] = $shop->operation_time; // ----------------------------没有开始时间,只有一个时间字符串 $onestore['shop_name'] = $shop->name; // 商家名称 $onestore['shop_type'] = $shop->type; // 商家类型,以逗号分隔的字符串---------------------------这个还是问一下 $Level = $this->getLevel($shop); $onestore['shop_level'] = $Level['thing_total']; // 商家评级 $onestore['order_count'] = $shop->sold_num; // 订单总量 $onestore['is_opening'] = $shop->state; // 营业状态 $onestore['is_ready_for_order'] = $shop->reserve; // 是否接受预定 array_push($my_store['data'], $onestore); } return $my_store; }
/** * 取消收藏某个商家 * * 请求类型:POST */ public function cancelShop() { if (!Auth::check()) { return Redirect::to('http://weibo.com'); } $user = Auth::user(); $rules = array('uid' => 'required | integer', 'shop_id' => 'required | integer'); $new_collect = array('uid' => $user->front_uid, 'shop_id' => Input::get('shop_id')); $v = Validator::make($new_collect, $rules); if ($v->fails()) { return Redirect::to('http://baidu.com'); return Redirect::to('error')->with('user', Auth::user())->withErrors($v)->withInput(); } if (CollectShop::where('shop_id', Input::get('shop_id'))->where('uid', $user->front_uid)->delete()) { $output = array(); $output['success'] = 'true'; $output['state'] = 200; $output['nextSrc'] = ''; $output['errMsg'] = ''; $output['no'] = 0; Response::json($output); } }
/** * 获取我收藏的店铺,最多5个 */ public function getMyStore() { if (!Auth::check()) { return array('url' => url('personal/collection/shop'), 'data' => array()); } $user = Auth::user(); $stores = CollectShop::where('uid', $user->front_uid)->orderBy('uptime', 'desc')->take(5)->lists('shop_id'); $my_store = array(); $my_store['url'] = url('personal/collection/shop'); $my_store['data'] = array(); foreach ($stores as $store) { $onestore = array(); $shop = Shop::find($store); $onestore['shop_id'] = $shop->id; $onestore['place_id'] = 'null'; // 地址ID,暂时不用 $onestore['shop_url'] = url('shop/' . $shop->id); // 点击跳转到相应商家 $onestore['shop_logo'] = $shop->pic; // 商家的logo图片地址 $onestore['deliver_time'] = (double) $shop->interval; // 送货时间间隔 $onestore['deliver_start'] = $shop->operation_time; // ----------------------------没有开始时间,只有一个时间字符串 $onestore['shop_name'] = mb_strlen($shop->name, 'utf8') > 5 ? mb_substr($shop->name, 0, 8, 'utf8') : $shop->name; // 商家名称 $onestore['shop_type'] = $shop->type; // 商家类型,以逗号分隔的字符串---------------------------这个还是问一下 $Level = $this->getLevel($shop); $onestore['shop_level'] = $Level['thing_total']; // 商家评级 $onestore['order_count'] = (double) $shop->sold_num; // 订单总量 $onestore['is_opening'] = $this->isOnline($shop->operation_time, date('H:i')) ? 0 : 1; // 营业状态 $onestore['is_ready_for_order'] = $shop->reserve; // 是否接受预定 array_push($my_store['data'], $onestore); } return $my_store; }