Example #1
0
 public function index()
 {
     $name = isset($_GET['searhkey']) ? htmlspecialchars($_GET['searhkey']) : '';
     $where = array('mer_id' => $this->mer_id, 'have_meal' => 1);
     if ($name) {
         $where['name'] = array('like', '%' . $name . '%');
     }
     $stores = D('Merchant_store')->field(true)->where($where)->select();
     $store_image_class = new store_image();
     $list = array();
     foreach ($stores as $row) {
         $temp = array();
         $temp['position'] = array('lng' => $row['long'], 'lat' => $row['lat']);
         $temp['name'] = $row['name'];
         $temp['btndisabled'] = 0;
         $temp['isShow'] = 0;
         $temp['seeURL'] = '';
         $temp['showList'] = array();
         $temp['btnText'] = '立即点菜';
         $temp['btnUrl'] = U('Food/menu', array('mer_id' => $row['mer_id'], 'store_id' => $row['store_id']));
         $temp['address'] = $row['adress'];
         $images = $store_image_class->get_allImage_by_path($row['pic_info']);
         $temp['imgurl'] = array_shift($images);
         $temp['storeDetailsURL'] = U('Food/shop', array('mer_id' => $row['mer_id'], 'store_id' => $row['store_id']));
         //'wap.php?mod=takeout&action=menu&com_id=' . $row['com_id'] . '&id=' . $row['id'];
         $list[] = $temp;
     }
     $this->assign('list', json_encode($list));
     $this->assign('total', count($list));
     $this->display();
 }
Example #2
0
 public function index()
 {
     if (empty($this->user_session)) {
     }
     $index_right_adver = D("Adver")->get_adver_by_key("index_right", 3);
     $this->assign("index_right_adver", $index_right_adver);
     $web_index_slider = D("Slider")->get_slider_by_key("web_slider");
     $this->assign("web_index_slider", $web_index_slider);
     $all_category_list = D("Group_category")->get_category();
     $this->assign("all_category_list", $all_category_list);
     $store_id = intval($_GET["store_id"]);
     $store = D("Merchant_store")->where(array("store_id" => $store_id))->find();
     if (empty($store)) {
         $this->group_noexit_tips();
     }
     $store["office_time"] = unserialize($store["office_time"]);
     $pre = $str = "";
     foreach ($store["office_time"] as $time) {
         $str = $pre . $time["open"] . "-" . $time["close"];
         $pre = ",";
     }
     $store["office_time"] = $str;
     $store_image_class = new store_image();
     $store["images"] = $store_image_class->get_allImage_by_path($store["pic_info"]);
     $store_meal = D("Merchant_store_meal")->where(array("store_id" => $store_id))->find();
     $store_meal["deliver_time"] = unserialize($store["deliver_time"]);
     $store_meal["width"] = 72 / 5 * $store_meal["score_mean"];
     $store = array_merge($store, $store_meal);
     $merchant = M("Merchant")->where(array("mer_id" => $store["mer_id"]))->find();
     $merchant_image = new merchant_image();
     $merchant["merchant_pic"] = $merchant_image->get_allImage_by_path($merchant["pic_info"]);
     $collect_count = D("User_collect")->where(array("type" => "meal_detail", "id" => $store_id))->count();
     $is_collect = 0;
     if ($collect = D("User_collect")->where(array("type" => "meal_detail", "id" => $store_id, "uid" => $this->user_session["uid"]))->find()) {
         $is_collect = 1;
     }
     $this->assign("collect_count", $collect_count);
     $this->assign("is_collect", $is_collect);
     $area = M("Area")->where(array("area_id" => $store["circle_id"]))->find();
     $this->assign("area", $area);
     $this->assign("merchant", $merchant);
     $this->assign("store", $store);
     $this->display();
 }
Example #3
0
 public function meal_list()
 {
     $status = isset($_GET['status']) ? intval($_GET['status']) : -1;
     $where = array('uid' => $this->now_user['uid'], 'status' => array('lt', 4));
     if ($status == 0) {
         $where['paid'] = 0;
     } elseif ($status == 1) {
         $where['status'] = 0;
     } elseif ($status == 2) {
         $where['status'] = 1;
     }
     import('@.ORG.user_page');
     $count = M("Meal_order")->where($where)->count();
     $p = new Page($count, 10);
     $orders = M("Meal_order")->where($where)->order('order_id DESC')->limit($p->firstRow . ',10')->select();
     $tmp = array();
     foreach ($orders as $o) {
         $tmp[] = $o['store_id'];
     }
     if ($tmp) {
         $store_image_class = new store_image();
         $store = D('Merchant_store')->where(array('store_id' => array('in', $tmp)))->select();
         $list = array();
         foreach ($store as $v) {
             $images = $store_image_class->get_allImage_by_path($v['pic_info']);
             $v['image'] = $images ? array_shift($images) : array();
             $list[$v['store_id']] = $v;
         }
     }
     foreach ($orders as &$or) {
         $or['image'] = isset($list[$or['store_id']]['image']) ? $list[$or['store_id']]['image'] : '';
         $or['s_name'] = isset($list[$or['store_id']]['name']) ? $list[$or['store_id']]['name'] : '';
         $or['url'] = C('config.site_url') . '/meal/' . $or['store_id'] . '.html';
     }
     $this->assign('order_list', $orders);
     $this->assign('status', $status);
     $this->assign('pagebar', $p->show());
     $this->display();
 }
Example #4
0
 public function __construct()
 {
     parent::__construct();
     $this->store_id = isset($_REQUEST['store_id']) ? intval($_REQUEST['store_id']) : 0;
     $this->assign('store_id', $this->store_id);
     /* 粉丝行为分析 */
     D('Merchant_request')->add_request($this->mer_id, array('meal_hits' => 1));
     $merchant_store = M("Merchant_store")->where(array('store_id' => $this->store_id, 'mer_id' => $this->mer_id))->find();
     $merchant_store['office_time'] = unserialize($merchant_store['office_time']);
     $store_image_class = new store_image();
     $merchant_store['images'] = $store_image_class->get_allImage_by_path($merchant_store['pic_info']);
     $t = $merchant_store['images'];
     $merchant_store['image'] = array_shift($t);
     $this->_store = $merchant_store;
     $this->assign('store', $this->_store);
     $this->redirect(U('Food/shop', array('mer_id' => $this->mer_id, 'store_id' => $this->store_id)));
     if ($services = D('Customer_service')->where(array('mer_id' => $this->mer_id))->select()) {
         $key = $this->get_im_encrypt_key(array('app_id' => $this->config['im_appid'], 'openid' => $_SESSION['openid']), $this->config['im_appkey']);
         $kf_url = 'http://im-link.meihua.com/?app_id=' . $this->config['im_appid'] . '&openid=' . $_SESSION['openid'] . '&key=' . $key . '#serviceList_' . $this->mer_id;
         $this->assign('kf_url', $kf_url);
     }
 }
Example #5
0
 public function store_list()
 {
     $searhkey = isset($_REQUEST['searhkey']) ? htmlspecialchars($_REQUEST['searhkey']) : '';
     $where = 's.have_meal=1 AND s.status=1';
     $searhkey && ($where .= " AND s.name like '%{$searhkey}%'");
     $model = new Model();
     $sql = "SELECT s.* FROM " . C('DB_PREFIX') . "merchant_store AS s INNER JOIN " . C('DB_PREFIX') . "merchant_store_meal AS m ON s.store_id=m.store_id WHERE {$where} ORDER BY s.store_id DESC";
     $stores = $model->query($sql);
     $store_image_class = new store_image();
     $now_time = time();
     $list = array();
     foreach ($stores as $row) {
         $row['position'] = array('lng' => $row['long'], 'lat' => $row['lat']);
         $row['state'] = 0;
         //根据营业时间判断
         foreach (unserialize($row['office_time']) as $time) {
             $open = strtotime(date("Y-m-d ") . $time['open'] . ':00');
             $close = strtotime(date("Y-m-d ") . $time['close'] . ':00');
             if ($open < $now_time && $now_time < $close) {
                 $row['state'] = 1;
                 //根据营业时间判断
                 break;
             }
         }
         $row['dist'] = 0;
         $row['ctime'] = 0;
         $row['tel'] = $row['phone'];
         $row['address'] = $row['adress'];
         $images = $store_image_class->get_allImage_by_path($row['pic_info']);
         $row['img'] = array_shift($images);
         $row['url'] = U('Takeout/menu', array('mer_id' => $row['mer_id'], 'store_id' => $row['store_id']));
         //'wap.php?mod=takeout&action=menu&com_id=' . $row['com_id'] . '&id=' . $row['id'];
         $list[] = $row;
     }
     exit(json_encode(array('result' => 1, 'message' => 'success', 'data' => $list)));
 }
Example #6
0
 private function special_keyword($key, $data = array())
 {
     $return = array();
     if ($key == '附近团购' || $key == '附近订餐') {
         $dateline = time() - 3600 * 2;
         if ($_lat = D("User__lat")->field(true)->where("`open_id`='{$data['FromUserName']}' AND `dateline`>'{$dateline}'")->find()) {
             import('@.ORG.lat');
             $lat_class = new lat();
             $location2 = $lat_class->gpsToBaidu($_lat['lat'], $_lat['']);
             //转换腾讯坐标到百度坐标
             $x = $location2['lat'];
             $y = $location2['lng'];
             if ($key == '附近订餐') {
                 $meals = D("Merchant_store")->field("*, ROUND(6378.138 * 2 * ASIN(SQRT(POW(SIN(({$x}*PI()/180-`lat`*PI()/180)/2),2)+COS({$x}*PI()/180)*COS(`lat`*PI()/180)*POW(SIN(({$y}*PI()/180-``*PI()/180)/2),2)))*1000) AS juli")->where('`have_meal`=1')->order("juli ASC")->limit("0, 10")->select();
                 $store_image_class = new store_image();
                 foreach ($meals as $meal) {
                     $images = $store_image_class->get_allImage_by_path($meal['pic_info']);
                     $meal['image'] = $images ? array_shift($images) : '';
                     $len = $meal['juli'] >= 1000 ? number_format($meal['juli'] / 1000, 1) . '千米' : $meal['juli'] . '米';
                     $return[] = array($meal['name'] . "[{$meal['adress']}]约{$len}", $meal['txt_info'], $meal['image'], $this->config['site_url'] . "/wap.php?g=Wap&c=Meal&a=menu&mer_id={$meal['mer_id']}&store_id={$meal['store_id']}");
                 }
             } else {
                 $meals = D("Merchant_store")->field("*, ROUND(6378.138 * 2 * ASIN(SQRT(POW(SIN(({$x}*PI()/180-`lat`*PI()/180)/2),2)+COS({$x}*PI()/180)*COS(`lat`*PI()/180)*POW(SIN(({$y}*PI()/180-``*PI()/180)/2),2)))*1000) AS juli")->where('`have_group`=1')->order("juli ASC")->limit("0, 10")->select();
                 $store_image_class = new store_image();
                 foreach ($meals as $meal) {
                     $images = $store_image_class->get_allImage_by_path($meal['pic_info']);
                     $meal['image'] = $images ? array_shift($images) : '';
                     $len = $meal['juli'] >= 1000 ? number_format($meal['juli'] / 1000, 1) . '千米' : $meal['juli'] . '米';
                     $return[] = array($meal['name'] . "[{$meal['adress']}]约{$len}", $meal['txt_info'], $meal['image'], $this->config['site_url'] . "/wap.php?g=Wap&c=Group&a=shop&store_id={$meal['store_id']}");
                 }
             }
         }
         if ($return) {
             return array($return, 'news');
         } else {
             return array("主人【小猪猪】已经接收到你的指令请发送您的地理位置(对话框右下角点击+号,然后点击“位置”)给我哈", 'text');
         }
     }
     if ($key == '交友') {
         $return[] = array("交友约会", "结交一些朋友吃喝玩乐", $this->config['site_url'] . '/static/images/jiaoyou.jpg', $this->config['site_url'] . "/wap.php?c=Invitation&a=datelist");
         return array($return, 'news');
     }
     $platform = D("Platform")->field(true)->where(array('key' => $key))->find();
     if ($platform) {
         $return[] = array($platform['title'], $platform['info'], getAttachmentUrl($platform['pic']), $platform['url']);
     } else {
         $keys = D("Keywords")->field(true)->where(array('keyword' => $key))->order('id DESC')->limit('0,9')->select();
         $lotteryids = $mealids = $groupids = array();
         foreach ($keys as $k) {
             if ($k['third_type'] == 'group') {
                 $groupids[] = $k['third_id'];
             } elseif ($k['third_type'] == 'Merchant_store') {
                 $mealids[] = $k['third_id'];
             } elseif ($k['third_type'] == 'lottery') {
                 $lotteryids[] = $k['third_id'];
             }
         }
         if ($groupids) {
             $list = D("Group")->field(true)->where(array('group_id' => array('in', $groupids)))->select();
             $group_image_class = new group_image();
             foreach ($list as $li) {
                 $image = $group_image_class->get_image_by_path($li['pic'], 's');
                 $return[] = array($li['s_name'], $li['name'], $image, $this->config['site_url'] . "/wap.php?g=Wap&c=Group&a=detail&group_id={$li['group_id']}");
             }
         }
         if ($mealids) {
             $list = D("Merchant_store")->field(true)->where(array('store_id' => array('in', $mealids)))->select();
             $store_image_class = new store_image();
             foreach ($list as $now_store) {
                 $images = $store_image_class->get_allImage_by_path($now_store['pic_info']);
                 $now_store['image'] = $images ? array_shift($images) : '';
                 if ($now_store['have_meal']) {
                     $return[] = array($now_store['name'], $now_store['txt_info'], $now_store['image'], $this->config['site_url'] . "/wap.php?g=Wap&c=Meal&a=menu&mer_id={$now_store['mer_id']}&store_id={$now_store['store_id']}");
                 } else {
                     $return[] = array($now_store['name'], $now_store['txt_info'], $now_store['image'], $this->config['site_url'] . "/wap.php?g=Wap&c=Group&a=shop&store_id={$now_store['store_id']}");
                 }
             }
         }
         if ($lotteryids) {
             $lotterys = D("Lottery")->field(true)->where(array('id' => array('in', $lotteryids), 'statdate' => array('lt', time()), 'enddate' => array('gt', time())))->select();
             foreach ($lotterys as $lottery) {
                 switch ($lottery['type']) {
                     case 1:
                         $return[] = array('[活动]' . $lottery['title'], $lottery['info'], $this->config['site_url'] . $lottery['starpicurl'], $this->config['site_url'] . "/wap.php?c=Lottery&a=index&token={$lottery['token']}&id={$lottery['id']}");
                         break;
                     case 2:
                         $return[] = array('[活动]' . $lottery['title'], $lottery['info'], $this->config['site_url'] . $lottery['starpicurl'], $this->config['site_url'] . "/wap.php?c=Guajiang&a=index&token={$lottery['token']}&id={$lottery['id']}");
                         break;
                     case 3:
                         $return[] = array('[活动]' . $lottery['title'], $lottery['info'], $this->config['site_url'] . $lottery['starpicurl'], $this->config['site_url'] . "/wap.php?c=Coupon&a=index&token={$lottery['token']}&id={$lottery['id']}");
                         break;
                     case 4:
                         $return[] = array('[活动]' . $lottery['title'], $lottery['info'], $this->config['site_url'] . $lottery['starpicurl'], $this->config['site_url'] . "/wap.php?c=LuckyFruit&a=index&token={$lottery['token']}&id={$lottery['id']}");
                         break;
                     case 5:
                         $return[] = array('[活动]' . $lottery['title'], $lottery['info'], $this->config['site_url'] . $lottery['starpicurl'], $this->config['site_url'] . "/wap.php?c=GoldenEgg&a=index&token={$lottery['token']}&id={$lottery['id']}");
                         break;
                 }
             }
         }
     }
     if ($return) {
         return array($return, 'news');
     }
     return array('亲,暂时没有找到与“' . $key . '”相关的内容!请更换内容。', 'text');
 }
 public function save_date()
 {
     $store_id = $_POST["store_id"] ? intval($_POST["store_id"]) : 0;
     $merchant_store = M("Merchant_store")->where(array("store_id" => $store_id))->find();
     if (empty($merchant_store)) {
         //反转
         exit(json_encode(array("error_code" => 1, "msg" => "不存在的门店")));
     }
     if ($invitation = D("Invitation")->field(true)->where(array("uid" => $this->user_session["uid"], "status" => 0, "invite_time" => array("gt", time())))->find()) {
         exit(json_encode(array("error_code" => 1, "msg" => "您已经有一个约会了,不能再发布约会了")));
     }
     $minute = $_POST["minute"] ? $_POST["minute"] : "";
     $hour = $_POST["hour"] ? $_POST["hour"] : "";
     $date = $_POST["date"] ? $_POST["date"] : "";
     $data["invite_time"] = strtotime($date . $hour . $minute . "00");
     $data["store_id"] = $merchant_store["store_id"];
     $store_image_class = new store_image();
     $merchant_store["images"] = $store_image_class->get_allImage_by_path($merchant_store["pic_info"]);
     $data["store_image"] = $merchant_store["images"] ? array_shift($merchant_store["images"]) : "";
     $data["address"] = $merchant_store["name"];
     $data["obj_sex"] = $_POST["obj_sex"] ? intval($_POST["obj_sex"]) : 0;
     $data["pay_type"] = $_POST["pay_type"] ? intval($_POST["pay_type"]) : 0;
     $data["activity_type"] = $_POST["activity_type"] ? intval($_POST["activity_type"]) : 0;
     $data["note"] = $_POST["note"] ? htmlspecialchars($_POST["note"]) : "";
     $data["uid"] = $this->user_session["uid"];
     $data["long"] = $this->_long;
     $data["lat"] = $this->_lat;
     if ($pigcms_id = D("Invitation")->add($data)) {
         exit(json_encode(array("error_code" => 0)));
     } else {
         exit(json_encode(array("error_code" => 1, "msg" => "发布失败")));
     }
 }
 public function around()
 {
     $long_lat["lat"] = $_COOKIE["meal_around_lat"];
     $long_lat["long"] = $_COOKIE["meal_around_long"];
     if ($long_lat["lat"] || $long_lat["long"]) {
         $_SESSION["openid"] && ($long_lat = D("User_long_lat")->field("long,lat")->where(array("open_id" => $_SESSION["openid"]))->find());
     }
     if ($long_lat["lat"] || $long_lat["long"]) {
         redirect(U("Meal_list/around_adress"));
     }
     $this->assign("lat_long", $long_lat["lat"] . "," . $long_lat["long"]);
     $around_range = $this->config["group_around_range"];
     $stores = D("Merchant_store")->field("*,ROUND(6378.138 * 2 * ASIN(SQRT(POW(SIN(({$long_lat["lat"]}*PI()/180-`lat`*PI()/180)/2),2)+COS({$long_lat["lat"]}*PI()/180)*COS(`lat`*PI()/180)*POW(SIN(({$long_lat["long"]}*PI()/180-`long`*PI()/180)/2),2)))*1000) AS juli")->where("`have_meal`='1' AND ROUND(6378.138 * 2 * ASIN(SQRT(POW(SIN(({$long_lat["lat"]}*PI()/180-`lat`*PI()/180)/2),2)+COS({$long_lat["lat"]}*PI()/180)*COS(`lat`*PI()/180)*POW(SIN(({$long_lat["long"]}*PI()/180-`long`*PI()/180)/2),2)))*1000) < '{$around_range}'")->select();
     $store_ids = array();
     $ids = array();
     $temp_store = array();
     $store_image_class = new store_image();
     foreach ($stores as $store) {
         if (!in_array($store["circle_id"], $ids)) {
             $ids[] = $store["circle_id"];
         }
         if (!in_array($store["store_id"], $store_ids)) {
             $store_ids[] = $store["store_id"];
         }
         $images = $store_image_class->get_allImage_by_path($store["pic_info"]);
         $store["image"] = $images ? array_shift($images) : array();
         $temp_store[] = $store;
     }
     $temp = array();
     if ($ids) {
         $areas = M("Area")->where(array("area_id" => array("in", $ids)))->select();
         foreach ($areas as $a) {
             $temp[$a["area_id"]] = $a;
         }
     }
     $t_store_meals = array();
     $store_meals = D("Merchant_store_meal")->field(true)->where(array("store_id" => array("in", $store_ids)))->select();
     foreach ($store_meals as $meal) {
         $t_store_meals[$meal["store_id"]] = $meal;
     }
     foreach ($temp_store as &$s) {
         if ($t_store_meals[$s["store_id"]]) {
             $s = array_merge($s, $t_store_meals[$s["store_id"]]);
         }
         $s["area_name"] = $temp[$s["circle_id"]] ? $temp[$s["circle_id"]]["area_name"] : "";
     }
     $this->assign("group_list", $temp_store);
     $this->display();
 }
Example #9
0
 public function detail()
 {
     $set = isset($_GET['set']) ? htmlspecialchars($_GET['set']) : '';
     $store_id = isset($_GET['store_id']) ? intval($_GET['store_id']) : 0;
     $merchant_store = M("Merchant_store")->where(array('store_id' => $store_id))->find();
     $merchant_store['office_time'] = unserialize($merchant_store['office_time']);
     $store_image_class = new store_image();
     $merchant_store['images'] = $store_image_class->get_allImage_by_path($merchant_store['pic_info']);
     $merchant_store_meal = M("Merchant_store_meal")->where(array('store_id' => $store_id))->find();
     $merchant_store_meal && ($merchant_store = array_merge($merchant_store, $merchant_store_meal));
     if ($merchant_store['have_group']) {
         $group_list = D('Group')->get_store_group_list($merchant_store['store_id'], 10, true);
         $this->assign('group_list', $group_list);
     }
     /* 粉丝行为分析 */
     $this->behavior(array('mer_id' => $this->mer_id, 'biz_id' => $this->store_id));
     $this->assign('store', $merchant_store);
     $this->assign('set', $set);
     $this->assign('title', '店铺介绍');
     $this->display();
 }
Example #10
0
 public function order_list()
 {
     $type = isset($_GET['type']) ? intval($_GET['type']) : 1;
     if ($type == 1) {
         $order_list = D('Group')->wap_get_order_list($this->user_session['uid']);
         $this->assign('order_list', $order_list);
     } else {
         $where = array('uid' => $this->user_session['uid'], 'status' => array('lt', 3));
         $order_list = D("Meal_order")->field(true)->where($where)->order('order_id DESC')->select();
         $temp = $store_ids = array();
         foreach ($order_list as $st) {
             $store_ids[] = $st['store_id'];
         }
         $m = array();
         if ($store_ids) {
             $store_image_class = new store_image();
             $merchant_list = D("Merchant_store")->where(array('store_id' => array('in', $store_ids)))->select();
             foreach ($merchant_list as $li) {
                 $images = $store_image_class->get_allImage_by_path($li['pic_info']);
                 $li['image'] = $images ? array_shift($images) : array();
                 unset($li['status']);
                 $m[$li['store_id']] = $li;
             }
         }
         $list = array();
         foreach ($order_list as $ol) {
             if (isset($m[$ol['store_id']]) && $m[$ol['store_id']]) {
                 $list[] = array_merge($ol, $m[$ol['store_id']]);
             } else {
                 $list[] = $ol;
             }
         }
         $this->assign('order_list', $list);
     }
     $this->assign('type', $type);
     $this->display();
 }
 public function wap_get_store_list_by_catid($cat_id, $area_id, $order, $lat, $long, $cat_url)
 {
     $stores = D('Store_category')->field('store_id')->where("cat_id='{$cat_id}'")->select();
     foreach ($stores as $s) {
         $store_ids[] = $s['store_id'];
     }
     $store_ids && ($where['store_id'] = array('in', $store_ids));
     if ($cat_url == 'dianying' && empty($store_ids)) {
         return false;
     }
     // 		$where['have_meal'] = 1;
     $where['status'] = 1;
     $area_id && ($where['area_id'] = $area_id);
     $count = D('Merchant_store')->where($where)->count();
     //排序
     switch ($order) {
         case 'distance':
             $order = "ROUND(6378.138 * 2 * ASIN(SQRT(POW(SIN(({$lat} * PI() / 180- `lat` * PI()/180)/2),2)+COS({$lat} *PI()/180)*COS(`lat`*PI()/180)*POW(SIN(({$long} *PI()/180- `long`*PI()/180)/2),2)))*1000) ASC";
             //'`g`.`price` ASC,`g`.`group_id` DESC';
             break;
             // 			case 'priceDesc':
             // 				$order = '`g`.`price` DESC,`g`.`group_id` DESC';
             // 				break;
             // 			case 'solds':
             // 				$order = '`g`.`sale_count` DESC,`g`.`group_id` DESC';
             // 				break;
             // 			case 'rating':
             // 				$order = '`g`.`score_mean` DESC,`g`.`group_id` DESC';
             // 				break;
             // 			case 'start':
             // 				$order = '`g`.`last_time` DESC,`g`.`group_id` DESC';
             // 				break;
         // 			case 'priceDesc':
         // 				$order = '`g`.`price` DESC,`g`.`group_id` DESC';
         // 				break;
         // 			case 'solds':
         // 				$order = '`g`.`sale_count` DESC,`g`.`group_id` DESC';
         // 				break;
         // 			case 'rating':
         // 				$order = '`g`.`score_mean` DESC,`g`.`group_id` DESC';
         // 				break;
         // 			case 'start':
         // 				$order = '`g`.`last_time` DESC,`g`.`group_id` DESC';
         // 				break;
         default:
             $order = '`store_id` DESC';
     }
     import('@.ORG.wap_group_page');
     $p = new Page($count, C('config.group_page_row'), C('config.group_page_val'));
     $list = D('Merchant_store')->field(true)->where($where)->order($order)->limit($p->firstRow . ',' . $p->listRows)->select();
     // 		echo D('Merchant_store')->_sql();
     $return['pagebar'] = $p->show();
     if ($list) {
         $store_image_class = new store_image();
         foreach ($list as &$v) {
             $images = $store_image_class->get_allImage_by_path($v['pic_info']);
             $v['image'] = $images ? array_shift($images) : '';
             $v['juli'] = ROUND(6378.138 * 2 * ASIN(SQRT(POW(SIN(($lat * PI() / 180 - $v['lat'] * PI() / 180) / 2), 2) + COS($lat * PI() / 180) * COS($v['lat'] * PI() / 180) * POW(SIN(($long * PI() / 180 - $v['long'] * PI() / 180) / 2), 2))) * 1000);
             $v['juli'] = $v['juli'] > 1000 ? number_format($v['juli'] / 1000, 1) . 'km' : ($v['juli'] < 100 ? '<100m' : $v['juli'] . 'm');
         }
     }
     $return['store_list'] = $list;
     return $return;
 }
Example #12
0
 public function store_edit()
 {
     $database_merchant_store = D('Merchant_store');
     if (IS_POST) {
         if (empty($_POST['name'])) {
             $this->error('店铺名称必填!');
         }
         if (empty($_POST['phone'])) {
             $this->error('联系电话必填!');
         }
         if (empty($_POST['long_lat'])) {
             $this->error('店铺经纬度必填!');
         }
         if (empty($_POST['adress'])) {
             $this->error('店铺地址必填!');
         }
         if (empty($_POST['pic'])) {
             $this->error('请至少上传一张图片');
         }
         $_POST['pic_info'] = implode(';', $_POST['pic']);
         if (empty($_POST['txt_info'])) {
             $this->error('请输入店铺描述信息');
         }
         $keywords = trim($_POST['keywords']);
         if (!empty($keywords)) {
             $tmp_key_arr = explode(' ', $keywords);
             $key_arr = array();
             foreach ($tmp_key_arr as $value) {
                 if (!empty($value)) {
                     array_push($key_arr, $value);
                 }
             }
             if (5 < count($key_arr)) {
                 $this->error('关键词最多5个。');
             }
         }
         $office_time = array();
         if ($_POST['office_start_time'] != '00:00' || $_POST['office_stop_time'] != '00:00') {
             array_push($office_time, array('open' => $_POST['office_start_time'], 'close' => $_POST['office_stop_time']));
         }
         if ($_POST['office_start_time2'] != '00:00' || $_POST['office_stop_time2'] != '00:00') {
             array_push($office_time, array('open' => $_POST['office_start_time2'], 'close' => $_POST['office_stop_time2']));
         }
         if ($_POST['office_start_time3'] != '00:00' || $_POST['office_stop_time3'] != '00:00') {
             array_push($office_time, array('open' => $_POST['office_start_time3'], 'close' => $_POST['office_stop_time3']));
         }
         $_POST['office_time'] = serialize($office_time);
         $_POST['sort'] = intval($_POST['sort']);
         $long_lat = explode(',', $_POST['long_lat']);
         $_POST['long'] = $long_lat[0];
         $_POST['lat'] = $long_lat[1];
         $_POST['last_time'] = $_SERVER['REQUEST_TIME'];
         $condition_merchant_store['store_id'] = $_POST['store_id'];
         $condition_merchant_store['mer_id'] = $this->merchant_session['mer_id'];
         unset($_POST['store_id']);
         if ($database_merchant_store->where($condition_merchant_store)->data($_POST)->save()) {
             $data_keywords['third_id'] = $condition_merchant_store['store_id'];
             $data_keywords['third_type'] = 'Merchant_store';
             $database_keywords = D('Keywords');
             $database_keywords->where($data_keywords)->delete();
             if (!empty($key_arr)) {
                 foreach ($key_arr as $value) {
                     $data_keywords['keyword'] = $value;
                     $database_keywords->data($data_keywords)->add();
                 }
             }
             $this->success('保存成功!');
         } else {
             $this->error('保存失败!!您是不是没做过修改?请重试~');
         }
     } else {
         $condition_merchant_store['store_id'] = $_GET['id'];
         $condition_merchant_store['mer_id'] = $this->merchant_session['mer_id'];
         $now_store = $database_merchant_store->where($condition_merchant_store)->find();
         if (empty($now_store)) {
             $this->error('店铺不存在!');
         }
         $now_store['office_time'] = unserialize($now_store['office_time']);
         if (!empty($now_store['pic_info'])) {
             $store_image_class = new store_image();
             $tmp_pic_arr = explode(';', $now_store['pic_info']);
             foreach ($tmp_pic_arr as $key => $value) {
                 $now_store['pic'][$key]['title'] = $value;
                 $now_store['pic'][$key]['url'] = $store_image_class->get_image_by_path($value);
             }
         }
         $keywords = D('Keywords')->where(array('third_type' => 'Merchant_store', 'third_id' => $condition_merchant_store['store_id']))->select();
         $str = '';
         foreach ($keywords as $key) {
             $str .= $key['keyword'] . ' ';
         }
         $now_store['keywords'] = $str;
         $this->assign('now_store', $now_store);
         $this->display();
     }
 }
Example #13
0
 public function get_rate_order_list($uid, $is_rate = false, $is_wap = false)
 {
     $condition_where = "`o`.`uid`='{$uid}' AND `o`.`store_id`=`s`.`store_id`";
     if ($is_rate) {
         $condition_where .= " AND `o`.`paid`='1'";
         $condition_where .= " AND `o`.`status`='2'";
         $condition_where .= " AND `r`.`order_type`='1' AND `r`.`order_id`=`o`.`order_id`";
         $condition_table = array(C('DB_PREFIX') . 'merchant_store' => 's', C('DB_PREFIX') . 'meal_order' => 'o', C('DB_PREFIX') . 'reply' => 'r');
         $condition_field = '`o`.*,`s`.`name`,`s`.`pic_info`,`r`.*';
         $condition_order = '`r`.`pigcms_id` DESC';
     } else {
         $condition_where .= " AND `o`.`paid`='1'";
         $condition_where .= " AND `o`.`status`<2";
         $condition_table = array(C('DB_PREFIX') . 'merchant_store' => 's', C('DB_PREFIX') . 'meal_order' => 'o');
         $condition_field = '`o`.*,`s`.`name`,`s`.`pic_info`';
         $condition_order = '`o`.`dateline` DESC';
     }
     $order_list = $this->field($condition_field)->where($condition_where)->table($condition_table)->order($condition_order)->select();
     $store_image_class = new store_image();
     foreach ($order_list as &$v) {
         $images = $store_image_class->get_allImage_by_path($v['pic_info']);
         $v['image'] = $images ? array_shift($images) : array();
         $v['url'] = C('config.site_url') . '/meal/' . $v['store_id'] . '.html';
         $v['comment'] = stripslashes($v['comment']);
         if ($v['pic']) {
             $tmp_array = explode(',', $v['pic']);
             $v['pic_count'] = count($tmp_array);
         }
     }
     return $order_list;
 }
Example #14
0
 public function index()
 {
     $where['token'] = $this->token;
     //
     $allflash = M('Flash')->where($where)->order('id DESC')->select();
     $allflash = $this->convertLinks($allflash);
     if ($allflash == NULL) {
         $allflash = array(array("info" => "广告位描述", "img" => "/tpl/Wap/static/images/tour/4.jpg", "url" => "", "tip" => 1), array("info" => "广告位描述", "img" => "/tpl/Wap/static/images/tour/3.jpg", "url" => "", "tip" => 1));
     }
     // 		dump($allflash);
     //
     $flash = array();
     $flashbg = array();
     foreach ($allflash as $af) {
         if ($af['url'] == '') {
             $af['url'] = 'javascript:void(0)';
         }
         if ($af['tip'] == 1) {
             array_push($flash, $af);
         } elseif ($af['tip'] == 2) {
             array_push($flashbg, $af);
         }
     }
     $this->assign('flashbg', $flashbg);
     if (!$flashbg && $this->homeInfo['homeurl']) {
         $flash_db = M('Flash');
         $arr = array();
         $arr['token'] = $this->token;
         $arr['img'] = $this->homeInfo['homeurl'];
         $arr['url'] = '';
         $arr['info'] = '';
         $arr['tip'] = 2;
         if ($arr['img']) {
             $flash_db->add($arr);
         }
     }
     $info = $this->info;
     //$info = $this->convertLinks($info);
     $tpldata = $this->merchant_info;
     $tpldata['color_id'] = intval($tpldata['color_id']);
     //获取模板信息
     include './cms/Lib/ORG/index.Tpl.php';
     foreach ($tpl as $k => $v) {
         if ($v['tpltypeid'] == $tpldata['tpltypeid']) {
             $tplinfo = $v;
         }
     }
     $tpldata['tpltypeid'] = $tplinfo['tpltypeid'];
     $tpldata['tpltypename'] = $tplinfo['tpltypename'];
     foreach ($info as $k => $v) {
         if ($info[$k]['url'] == '') {
             $info[$k]['url'] = U('Index/lists', array('classid' => $v['id'], 'token' => $where['token']));
         }
         //解决二级分类
         if ($v['sub'] != NULL) {
             foreach ($v['sub'] as $ke => $va) {
                 if ($v['sub'][$ke]['url'] == '') {
                     $info[$k]['sub'][$ke]['url'] = U('Index/lists', array('classid' => $v['sub'][$ke]['id'], 'token' => $where['token']));
                 }
             }
         }
     }
     if ($tpldata['tpltypename'] == 'ktv_list' || $tpldata['tpltypename'] == 'yl_list') {
         //控制模板中的不同字段
         foreach ($info as $key => $val) {
             $info[$key]['title'] = $val['name'];
             $info[$key]['pic'] = $val['img'];
             if ($info[$key]['url'] == '') {
                 $info[$key]['url'] = U('Index/lists', array('classid' => $val['id'], 'token' => $where['token']));
             }
             $info[$key]['info'] = strip_tags(htmlspecialchars_decode($val['info']));
         }
     }
     if (empty($info)) {
         //$info = array(array('url' => '', 'name' => '', 'info' => ''));
         //1.看商家支持订餐还是团购
         $stores = D("Merchant_store")->field(true)->where(array('mer_id' => $this->token, 'status' => 1))->select();
         $store_image_class = new store_image();
         foreach ($stores as $store) {
             if ($store['have_meal']) {
                 $images = $store_image_class->get_allImage_by_path($store['pic_info']);
                 $img = array_shift($images);
                 $info[] = array('url' => U('Meal/menu', array('mer_id' => $store['mer_id'], 'store_id' => $store['store_id'])), 'name' => $store['name'], 'info' => $store['txt_info'], 'img' => $img);
             }
         }
         $groups = D("Group")->field(true)->where(array('mer_id' => $this->token, 'begin_time' => array('lt', time()), 'end_time' => array('gt', time()), 'status' => 1))->select();
         $group_image_class = new group_image();
         foreach ($groups as $group) {
             $tmp_pic_arr = explode(';', $group['pic']);
             $img = $group_image_class->get_image_by_path($tmp_pic_arr[0], 's');
             $info[] = array('url' => U('Group/detail', array('group_id' => $group['group_id'])), 'name' => $group['s_name'], 'info' => $group['name'], 'img' => $img);
         }
         //2.会员卡
         $card = D("Member_card_set")->field(true)->where(array('token' => $this->token))->limit("0,1")->find();
         if ($card) {
             $info[] = array('url' => U('Card/index', array('token' => $this->token)), 'name' => $card['cardname'], 'info' => $card['msg'], 'img' => $this->config['site_url'] . $card['logo']);
         }
         //3.活动
         $lotterys = D("Lottery")->field(true)->where(array('token' => $this->token, 'statdate' => array('lt', time()), 'enddate' => array('gt', time())))->select();
         foreach ($lotterys as $lottery) {
             switch ($lottery['type']) {
                 case 1:
                     $info[] = array('url' => U('Lottery/index', array('token' => $this->token, 'id' => $lottery['id'])), 'name' => $lottery['title'], 'info' => $lottery['info'], 'img' => $lottery['starpicurl']);
                     break;
                 case 2:
                     $info[] = array('url' => U('Guajiang/index', array('token' => $this->token, 'id' => $lottery['id'])), 'name' => $lottery['title'], 'info' => $lottery['info'], 'img' => $lottery['starpicurl']);
                     break;
                 case 3:
                     $info[] = array('url' => U('Coupon/index', array('token' => $this->token, 'id' => $lottery['id'])), 'name' => $lottery['title'], 'info' => $lottery['info'], 'img' => $lottery['starpicurl']);
                     break;
                 case 4:
                     $info[] = array('url' => U('LuckyFruit/index', array('token' => $this->token, 'id' => $lottery['id'])), 'name' => $lottery['title'], 'info' => $lottery['info'], 'img' => $lottery['starpicurl']);
                     break;
                 case 5:
                     $info[] = array('url' => U('GoldenEgg/index', array('token' => $this->token, 'id' => $lottery['id'])), 'name' => $lottery['title'], 'info' => $lottery['info'], 'img' => $lottery['starpicurl']);
                     break;
             }
         }
     }
     if (empty($info)) {
         $info[] = array('url' => '', 'name' => '商家餐饮店铺', 'info' => '描述店铺简介', 'img' => '/tpl/Wap/static/images/tour/meal.jpg');
         $info[] = array('url' => '', 'name' => '商家发布的' . $this->config['group_alias_name'], 'info' => '描述' . $this->config['group_alias_name'] . '内容', 'img' => '/tpl/Wap/static/images/tour/group.jpg');
         $info[] = array('url' => '', 'name' => '商家创建的会员卡', 'info' => '描述会员卡详情', 'img' => '/tpl/Wap/static/images/tour/card.png');
         $info[] = array('url' => '', 'name' => '商家发布的促销活动', 'info' => '介绍活动内容', 'img' => '/tpl/Wap/static/images/tour/lottery.jpg');
     }
     D('Merchant')->where(array('mer_id' => $this->token))->setInc('hits', 1);
     $count = count($flash);
     $this->assign('flash', $flash);
     $this->assign('homeInfo', $this->homeInfo);
     $this->assign('info', $info);
     $this->assign('num', $count);
     $this->assign('flashbgcount', count($flashbg));
     $this->assign('tpl', $this->tpl);
     $this->assign('copyright', $this->copyright);
     $this->display($this->tpl['tpltypename']);
 }
Example #15
0
 public function near_info()
 {
     $condition_where = "`status`='1'";
     switch ($_POST['type']) {
         case 'merchant':
             //                 $condition_where  = '';
             break;
         case 'meal':
             $condition_where .= " AND `have_meal`='1'";
             break;
         case 'group':
             $condition_where .= " AND `have_group`='1'";
             break;
         default:
             $this->error('非法访问!');
     }
     $x = $_POST['lat'];
     $y = $_POST['long'];
     import('@.ORG.longlat');
     $longlat_class = new longlat();
     $location = $longlat_class->gpsToBaidu($x, $y);
     //转换腾讯坐标到百度坐标
     $x = $location['lat'];
     $y = $location['lng'];
     if ($this->is_wexin_browser && !empty($_SESSION['openid'])) {
         $condition_user_long_lat['open_id'] = $_SESSION['openid'];
         $data_user_long_lat['lat'] = $x;
         $data_user_long_lat['long'] = $y;
         $data_user_long_lat['dateline'] = $_SERVER['REQUEST_TIME'];
         $database_user_long_lat = D('User_long_lat');
         if ($database_user_long_lat->field('`open_id`')->where($condition_user_long_lat)->find()) {
             $database_user_long_lat->where($condition_user_long_lat)->data($data_user_long_lat)->save();
         } else {
             $data_user_long_lat['open_id'] = $_SESSION['openid'];
             $database_user_long_lat->data($data_user_long_lat)->add();
         }
     }
     $store_list = D("Merchant_store")->field("*, ROUND(6378.138 * 2 * ASIN(SQRT(POW(SIN(({$x}*PI()/180-`lat`*PI()/180)/2),2)+COS({$x}*PI()/180)*COS(`lat`*PI()/180)*POW(SIN(({$y}*PI()/180-`long`*PI()/180)/2),2)))*1000) AS juli")->where($condition_where)->order('`juli` ASC')->limit('0,6')->select();
     if (!empty($store_list)) {
         $store_image_class = new store_image();
         foreach ($store_list as &$store) {
             $images = $store_image_class->get_allImage_by_path($store['pic_info']);
             $store['image'] = $images ? array_shift($images) : '';
             if ($store['juli'] > 1000) {
                 $store['juli'] = ' ' . floatval(round($store['juli'] / 1000, 1)) . ' 千米';
             } else {
                 $store['juli'] = ' ' . $store['juli'] . ' 米';
             }
             switch ($_POST['type']) {
                 case 'merchant':
                     $store['url'] = U('Index/index', array('token' => $store['mer_id']));
                     break;
                 case 'meal':
                     $store['url'] = U('Meal/menu', array('mer_id' => $store['mer_id'], 'store_id' => $store['store_id']));
                     break;
                 case 'group':
                     $store['url'] = U('Group/shop', array('store_id' => $store['store_id']));
                     break;
                 default:
                     $this->error('非法访问!');
             }
         }
         echo json_encode(array('error' => 0, 'store_list' => $store_list));
     } else {
         echo json_encode(array('error' => 1));
     }
 }
Example #16
0
 private function special_keyword($key, $data)
 {
     $return = array();
     if ($key == "附近团购" || $key == "附近订餐") {
         $dateline = time() - 3600 * 2;
         if ($long_lat = D("User_long_lat")->field(true)->where("`open_id`='{$data["FromUserName"]}' AND `dateline`>'{$dateline}'")->find()) {
             import("@.ORG.longlat");
             $longlat_class = new longlat();
             $location2 = $longlat_class->gpsToBaidu($long_lat["lat"], $long_lat["long"]);
             $x = $location2["lat"];
             $y = $location2["lng"];
             if ($key == "附近订餐") {
                 $meals = D("Merchant_store")->field("*, ROUND(6378.138 * 2 * ASIN(SQRT(POW(SIN(({$x}*PI()/180-`lat`*PI()/180)/2),2)+COS({$x}*PI()/180)*COS(`lat`*PI()/180)*POW(SIN(({$y}*PI()/180-`long`*PI()/180)/2),2)))*1000) AS juli")->where("`have_meal`=1")->order("juli ASC")->limit("0, 10")->select();
                 $store_image_class = new store_image();
                 foreach ($meals as $meal) {
                     $images = $store_image_class->get_allImage_by_path($meal["pic_info"]);
                     $meal["image"] = $images ? array_shift($images) : "";
                     $len = 1000 <= $meal["juli"] ? number_format($meal["juli"] / 1000, 1) . "千米" : $meal["juli"] . "米";
                     $return[] = array($meal["name"] . "[" . $meal["adress"] . "]约{$len}", $meal["txt_info"], $meal["image"], $this->config["site_url"] . "/wap.php?g=Wap&c=Meal&a=menu&mer_id=" . $meal["mer_id"] . "&store_id=" . $meal["store_id"] . "");
                 }
             } else {
                 $meals = D("Merchant_store")->field("*, ROUND(6378.138 * 2 * ASIN(SQRT(POW(SIN(({$x}*PI()/180-`lat`*PI()/180)/2),2)+COS({$x}*PI()/180)*COS(`lat`*PI()/180)*POW(SIN(({$y}*PI()/180-`long`*PI()/180)/2),2)))*1000) AS juli")->where("`have_group`=1")->order("juli ASC")->limit("0, 10")->select();
                 $store_image_class = new store_image();
                 foreach ($meals as $meal) {
                     $images = $store_image_class->get_allImage_by_path($meal["pic_info"]);
                     $meal["image"] = $images ? array_shift($images) : "";
                     $len = 1000 <= $meal["juli"] ? number_format($meal["juli"] / 1000, 1) . "千米" : $meal["juli"] . "米";
                     $return[] = array($meal["name"] . "[" . $meal["adress"] . "]约{$len}", $meal["txt_info"], $meal["image"], $this->config["site_url"] . "/wap.php?g=Wap&c=Group&a=shop&store_id=" . $meal["store_id"] . "");
                 }
             }
         }
         if ($return) {
             return array($return, "news");
         } else {
             return array("主人【微赢】已经接收到你的指令请发送您的地理位置(对话框右下角点击+号,然后点击“位置”)给我哈", "text");
         }
     }
     if ($key == "交友") {
         $return[] = array("交友约会", "结交一些朋友吃喝玩乐", $this->config["site_url"] . "/static/images/jiaoyou.jpg", $this->config["site_url"] . "/wap.php?c=Invitation&a=datelist");
         return array($return, "news");
     }
     $platform = D("Platform")->field(true)->where(array("key" => $key))->find();
     if ($platform) {
         $return[] = array($platform["title"], $platform["info"], $this->config["site_url"] . $platform["pic"], $platform["url"]);
     } else {
         $keys = D("Keywords")->field(true)->where(array("keyword" => $key))->order("id DESC")->limit("0,9")->select();
         $lotteryids = $mealids = $groupids = array();
         foreach ($keys as $k) {
             if ($k["third_type"] == "group") {
                 $groupids[] = $k["third_id"];
             } else {
                 if ($k["third_type"] == "Merchant_store") {
                     $mealids[] = $k["third_id"];
                 } else {
                     if ($k["third_type"] == "lottery") {
                         $lotteryids[] = $k["third_id"];
                     }
                 }
             }
         }
         if ($groupids) {
             $list = D("Group")->field(true)->where(array("group_id" => array("in", $groupids)))->select();
             $group_image_class = new group_image();
             foreach ($list as $li) {
                 $image = $group_image_class->get_image_by_path($li["pic"], "s");
                 $return[] = array($li["s_name"], $li["name"], $image, $this->config["site_url"] . "/wap.php?g=Wap&c=Group&a=detail&group_id=" . $li["group_id"] . "");
             }
         }
         if ($mealids) {
             $list = D("Merchant_store")->field(true)->where(array("store_id" => array("in", $mealids)))->select();
             $store_image_class = new store_image();
             foreach ($list as $now_store) {
                 $images = $store_image_class->get_allImage_by_path($now_store["pic_info"]);
                 $now_store["image"] = $images ? array_shift($images) : "";
                 if ($now_store["have_meal"]) {
                     $return[] = array($now_store["name"], $now_store["txt_info"], $now_store["image"], $this->config["site_url"] . "/wap.php?g=Wap&c=Meal&a=menu&mer_id=" . $now_store["mer_id"] . "&store_id=" . $now_store["store_id"] . "");
                 } else {
                     $return[] = array($now_store["name"], $now_store["txt_info"], $now_store["image"], $this->config["site_url"] . "/wap.php?g=Wap&c=Group&a=shop&store_id=" . $now_store["store_id"] . "");
                 }
             }
         }
         if ($lotteryids) {
             $lotterys = D("Lottery")->field(true)->where(array("id" => array("in", $lotteryids), "statdate" => array("lt", time()), "enddate" => array("gt", time())))->select();
             foreach ($lotterys as $lottery) {
                 switch ($lottery["type"]) {
                     case 1:
                         $return[] = array("[活动]" . $lottery["title"], $lottery["info"], $this->config["site_url"] . $lottery["starpicurl"], $this->config["site_url"] . "/wap.php?c=Lottery&a=index&token=" . $lottery["token"] . "&id=" . $lottery["id"] . "");
                         break;
                     case 2:
                         $return[] = array("[活动]" . $lottery["title"], $lottery["info"], $this->config["site_url"] . $lottery["starpicurl"], $this->config["site_url"] . "/wap.php?c=Guajiang&a=index&token=" . $lottery["token"] . "&id=" . $lottery["id"] . "");
                         break;
                     case 3:
                         $return[] = array("[活动]" . $lottery["title"], $lottery["info"], $this->config["site_url"] . $lottery["starpicurl"], $this->config["site_url"] . "/wap.php?c=Coupon&a=index&token=" . $lottery["token"] / "&id=" . $lottery["id"] . "");
                         break;
                     case 4:
                         $return[] = array("[活动]" . $lottery["title"], $lottery["info"], $this->config["site_url"] . $lottery["starpicurl"], $this->config["site_url"] . "/wap.php?c=LuckyFruit&a=index&token=" . $lottery["token"] . "&id=" . $lottery["id"] . "");
                         break;
                     case 5:
                         $return[] = array("[活动]" . $lottery["title"], $lottery["info"], $this->config["site_url"] . $lottery["starpicurl"], $this->config["site_url"] . "/wap.php?c=GoldenEgg&a=index&token=" . $lottery["token"] . "&id=" . $lottery["id"] . "");
                         break;
                 }
             }
         }
     }
     if ($return) {
         return array($return, "news");
     }
     return array("亲,暂时没有找到与“" . $key . "”相关的内容!请更换内容。", "text");
 }
Example #17
0
 public function index()
 {
     //判断登录
     if (empty($this->user_session)) {
         //     		$this->assign('jumpUrl',U('Index/Login/index'));
         //     		$this->error('请先登录!');
     }
     //右侧广告
     $index_right_adver = D('Adver')->get_adver_by_key('index_right', 3);
     $this->assign('index_right_adver', $index_right_adver);
     //导航条
     $web_index_slider = D('Slider')->get_slider_by_key('web_slider');
     $this->assign('web_index_slider', $web_index_slider);
     $all_category_list = D('Group_category')->get_category();
     $this->assign('all_category_list', $all_category_list);
     $store_id = intval($_GET['store_id']);
     //店铺信息
     $store = D('Merchant_store')->where(array('store_id' => $store_id))->find();
     if (empty($store)) {
         $this->group_noexit_tips();
     }
     $store['office_time'] = unserialize($store['office_time']);
     $pre = $str = '';
     $store['state'] = 0;
     $now_time = time();
     foreach ($store['office_time'] as $time) {
         $str = $pre . $time['open'] . '-' . $time['close'];
         $pre = ',';
         $open = strtotime(date("Y-m-d ") . $time['open'] . ':00');
         $close = strtotime(date("Y-m-d ") . $time['close'] . ':00');
         if ($open < $now_time && $now_time < $close) {
             $store['state'] = 1;
             //根据营业时间判断
         }
     }
     $store['office_time'] = $str;
     $store_image_class = new store_image();
     $store['images'] = $store_image_class->get_allImage_by_path($store['pic_info']);
     $store_meal = D('Merchant_store_meal')->where(array('store_id' => $store_id))->find();
     $store_meal['deliver_time'] = unserialize($store['deliver_time']);
     $store_meal['width'] = 72 / 5 * $store_meal['score_mean'];
     $store = array_merge($store, $store_meal);
     //商家信息
     $merchant = M("Merchant")->where(array('mer_id' => $store['mer_id']))->find();
     $merchant_image = new merchant_image();
     $merchant['merchant_pic'] = $merchant_image->get_allImage_by_path($merchant['pic_info']);
     $sorts = M("Meal_sort")->where(array('store_id' => $store_id))->order('sort ASC')->select();
     $list = $temp = array();
     $id = 0;
     $sids = array();
     foreach ($sorts as $sort) {
         if ($sort['is_weekshow']) {
             $week = explode(",", $sort['week']);
             if (in_array(date("w"), $week)) {
                 $sids[] = $sort['sort_id'];
             }
         } else {
             $sids[] = $sort['sort_id'];
         }
     }
     $sort_type = isset($_GET['sort_type']) ? intval($_GET['sort_type']) : 0;
     $this->assign('sort_type', $sort_type);
     switch ($sort_type) {
         case 0:
             $order = 'meal_id DESC';
             break;
         case 1:
             $order = 'price DESC';
             break;
         case 2:
             $order = 'price ASC';
             break;
     }
     //菜单信息
     $meals = M('Meal')->field(true)->where(array('store_id' => $store_id, 'sort_id' => array('in', $sids), 'status' => 1))->order($order)->select();
     $meal_image_class = new meal_image();
     $txt = $pic = array();
     foreach ($meals as &$m) {
         $m['image'] = $meal_image_class->get_image_by_path($m['image'], $this->config['site_url'], 's');
         // 			$temp[$m['sort_id']] = isset($temp[$m['sort_id']]) ? $temp[$m['sort_id']] : array();
         // 			if ($m['image']) {
         // 				array
         // 			}
         $pic[$m['sort_id']] = isset($pic[$m['sort_id']]) ? $pic[$m['sort_id']] : array();
         $txt[$m['sort_id']] = isset($txt[$m['sort_id']]) ? $txt[$m['sort_id']] : array();
         $lst[$m['sort_id']] = isset($lst[$m['sort_id']]) ? $lst[$m['sort_id']] : array();
         if ($m['image']) {
             $pic[$m['sort_id']][] = $m;
         } else {
             $txt[$m['sort_id']][] = $m;
         }
         $lst[$m['sort_id']][] = $m;
     }
     $list = array();
     foreach ($sorts as &$s) {
         $s['meals']['pic'] = isset($pic[$s['sort_id']]) ? $pic[$s['sort_id']] : '';
         $s['meals']['txt'] = isset($txt[$s['sort_id']]) ? $txt[$s['sort_id']] : '';
         $s['meals']['list'] = isset($lst[$s['sort_id']]) ? $lst[$s['sort_id']] : '';
     }
     //被收藏的次数
     $collect_count = D('User_collect')->where(array('type' => 'meal_detail', 'id' => $store_id))->count();
     $is_collect = 0;
     if ($collect = D('User_collect')->where(array('type' => 'meal_detail', 'id' => $store_id, 'uid' => $this->user_session['uid']))->find()) {
         $is_collect = 1;
     }
     $this->assign('collect_count', $collect_count);
     $this->assign('is_collect', $is_collect);
     //菜品分类信息
     // 		$sorts = M('Meal_sort')->where(array('store_id' => $store_id))->select();
     $area = M("Area")->where(array('area_id' => $store['circle_id']))->find();
     $this->assign('area', $area);
     $this->assign('merchant', $merchant);
     $this->assign('store', $store);
     $this->assign('sorts', $sorts);
     $this->display();
 }