示例#1
0
 public function index()
 {
     $database_merchant = D('Merchant');
     $condition_merchant['mer_id'] = $this->merchant_session['mer_id'];
     $now_merchant = $database_merchant->field(true, 'pwd')->where($condition_merchant)->find();
     if (!empty($now_merchant['pic_info'])) {
         $merchant_image_class = new merchant_image();
         $tmp_pic_arr = explode(';', $now_merchant['pic_info']);
         foreach ($tmp_pic_arr as $key => $value) {
             $now_merchant['pic'][$key]['title'] = $value;
             $now_merchant['pic'][$key]['url'] = $merchant_image_class->get_image_by_path($value);
         }
     }
     $this->assign('now_merchant', $now_merchant);
     $merchant_group_list = D('Group')->get_grouplist_by_MerchantId($now_merchant['mer_id']);
     $this->assign('merchant_group_list', $merchant_group_list);
     $this->display();
 }
示例#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();
 }
示例#3
0
 public function get_merchants_by_long_lat($lat, $long, $around_range = 2000)
 {
     import('@.ORG.longlat');
     $longlat_class = new longlat();
     $location2 = $longlat_class->gpsToBaidu($lat, $long);
     //转换腾讯坐标到百度坐标
     $lat = $location2['lat'];
     $long = $location2['lng'];
     $Model = new Model();
     $sql = "SELECT s.lat, s.long, s.mer_id, s.name as sname, s.store_id, m.name, m.phone, s.adress, m.pic_info, ROUND(6378.138 * 2 * ASIN(SQRT(POW(SIN(({$lat}*PI()/180-`s`.`lat`*PI()/180)/2),2)+COS({$lat}*PI()/180)*COS(`s`.`lat`*PI()/180)*POW(SIN(({$long}*PI()/180-`s`.`long`*PI()/180)/2),2)))*1000) as juli FROM " . C('DB_PREFIX') . "merchant_store AS s INNER JOIN " . C('DB_PREFIX') . "merchant AS m ON s.mer_id=m.mer_id WHERE `s`.`status`=1 AND ROUND(6378.138 * 2 * ASIN(SQRT(POW(SIN(({$lat}*PI()/180-`s`.`lat`*PI()/180)/2),2)+COS({$lat}*PI()/180)*COS(`s`.`lat`*PI()/180)*POW(SIN(({$long}*PI()/180-`s`.`long`*PI()/180)/2),2)))*1000) < '{$around_range}'";
     $result = $Model->query($sql);
     $merchant_image_class = new merchant_image();
     foreach ($result as &$r) {
         $images = explode(";", $r['pic_info']);
         $images = explode(";", $images[0]);
         $r['img'] = $merchant_image_class->get_image_by_path($images[0]);
         $r['url'] = C('config.site_url') . '/wap.php?c=Index&a=index&token=' . $r['mer_id'];
     }
     return $result;
 }
示例#4
0
 private function scan($id, $openid)
 {
     if (4000000000 < $id && $openid) {
         $id -= 4000000000;
         if ($lottery = D("Lottery")->field(true)->where(array("id" => $id))->find()) {
             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["mer_id"] . "&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["mer_id"] . "&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["mer_id"] . "&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["mer_id"] . "&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["mer_id"] . "&id=" . $lottery["id"] . "");
                     break;
             }
             return array($return, "news");
         }
         return array("很抱歉,暂时获取不到该二维码的信息!", "text");
     } else {
         if (3000000000 < $id && $openid) {
             $id -= 3000000000;
             if ($meal_order = D("Meal_order")->field("order_id, mer_id, store_id")->where(array("order_id" => $id))->find()) {
                 return array("<a href=\"" . $this->config["site_url"] . "/wap.php?c=Meal&a=detail&orderid=" . $id . "&mer_id=" . $meal_order["mer_id"] . "&store_id=" . $meal_order["store_id"] . "&otherrm=1\">查看订餐订单详情</a>", "text");
             } else {
                 return array("获取不到该订单信息", "text");
             }
         } else {
             if (2000000000 < $id && $openid) {
                 $id -= 2000000000;
                 return array("<a href=\"" . $this->config["site_url"] . "/wap.php?c=My&a=group_order&order_id=" . $id . "&otherrm=1\">查看团购订单详情</a>", "text");
             } else {
                 if (1000000000 < $id && $openid) {
                     if ($user = D("User")->field("uid")->where(array("openid" => $openid))->find()) {
                         D("Login_qrcode")->where(array("id" => $id))->save(array("uid" => $user["uid"]));
                         return array("登陆成功", "text");
                     } else {
                         D("Login_qrcode")->where(array("id" => $id))->save(array("uid" => -1));
                         $return[] = array("点击授权登录", "", $this->config["site_logo"], $this->config["site_url"] . "/wap.php?c=Web_bind&a=ajax_web_login&qrcode_id=" . $id);
                         return array($return, "news");
                     }
                 }
             }
         }
     }
     if ($recognition = M("Recognition")->field(true)->where(array("id" => $id))->find()) {
         switch ($recognition["third_type"]) {
             case "group":
                 $now_group = D("Group")->field(true)->where(array("group_id" => $recognition["third_id"]))->find();
                 $group_image_class = new group_image();
                 $tmp_pic_arr = explode(";", $now_group["pic"]);
                 $image = $group_image_class->get_image_by_path($tmp_pic_arr[0], "s");
                 $return[] = array("[团购]" . $now_group["s_name"], $now_group["name"], $image, $this->config["site_url"] . "/wap.php?g=Wap&c=Group&a=detail&group_id=" . $now_group["group_id"] . "");
                 $this->saverelation($openid, $now_group["mer_id"], 0);
                 $return = $this->other_message($return, $now_group["mer_id"], $now_group["group_id"]);
                 break;
             case "merchant":
                 $now_merchant = D("Merchant")->field(true)->where(array("mer_id" => $recognition["third_id"]))->find();
                 $pic = "";
                 if ($now_merchant["pic_info"]) {
                     $images = explode(";", $now_merchant["pic_info"]);
                     $merchant_image_class = new merchant_image();
                     $images = explode(";", $images[0]);
                     $pic = $merchant_image_class->get_image_by_path($images[0]);
                 }
                 $return[] = array("[商家]" . $now_merchant["name"], $now_merchant["txt_info"], $pic, $this->config["site_url"] . "/wap.php?g=Wap&c=Index&a=index&token={$recognition["third_id"]}");
                 $return = $this->other_message($return, $now_merchant["mer_id"]);
                 $this->saverelation($openid, $now_merchant["mer_id"], 1);
                 break;
             case "meal":
                 $now_store = D("Merchant_store")->field(true)->where(array("store_id" => $recognition["third_id"]))->find();
                 if ($now_store["have_meal"]) {
                     $store_image_class = new store_image();
                     $images = $store_image_class->get_allImage_by_path($now_store["pic_info"]);
                     $now_store["image"] = $images ? array_shift($images) : "";
                     $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"] . "");
                 }
                 $this->saverelation($openid, $now_store["mer_id"], 0);
                 $return = $this->other_message($return, $now_store["mer_id"], 0, $now_store["store_id"]);
                 break;
             case "lottery":
                 $lottery = D("Lottery")->field(true)->where(array("id" => $recognition["third_id"]))->find();
                 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;
                 }
                 break;
         }
     }
     if ($return) {
         return array($return, "news");
     }
     return array("很抱歉,暂时获取不到该二维码的信息!", "text");
 }
示例#5
0
 public function __construct()
 {
     parent::__construct();
     /* 粉丝行为分析 */
     D('Merchant_request')->add_request($this->token, array('website_hits' => 1));
     $homeInfo = M('Home')->where(array('token' => $this->token))->find();
     $this->homeInfo = $homeInfo;
     $catemenu = M('Catemenu')->where(array('token' => $this->token, 'status' => 1))->order('orderss desc')->select();
     $menures = array();
     if ($catemenu) {
         $res = array();
         $rescount = 0;
         foreach ($catemenu as $val) {
             $val['url'] = $this->getLink($val['url']);
             $res[$val['id']] = $val;
             if ($val['fid'] == 0) {
                 $val['vo'] = array();
                 $menures[$val['id']] = $val;
                 $menures[$val['id']]['k'] = $rescount;
                 $rescount++;
             }
         }
         foreach ($catemenu as $val) {
             $val['url'] = $this->getLink($val['url']);
             if ($val['fid'] > 0) {
                 array_push($menures[$val['fid']]['vo'], $val);
             }
         }
     }
     $catemenu = $menures;
     $this->bottomeMenus = $catemenu;
     $this->assign('catemenu', $this->bottomeMenus);
     //判断菜单风格
     $radiogroup = $homeInfo['radiogroup'];
     // 		dump($homeInfo);die;
     if ($radiogroup == false) {
         $radiogroup = 0;
     }
     $cateMenuFileName = 'tpl/Wap/Index/menuStyle' . $radiogroup . '.php';
     $this->assign('cateMenuFileName', $cateMenuFileName);
     $this->assign('radiogroup', $radiogroup);
     $this->assign('iscopyright', 1);
     //是否允许自定义版权
     $this->assign('siteCopyright', C('copyright'));
     //站点版权信息
     $where['token'] = $this->token;
     $tpl = $this->merchant_info;
     $this->weixinUser = $tpl;
     //父类信息
     $allClasses = M('Classify')->where(array('token' => $this->token, 'status' => 1))->order('sorts desc')->select();
     $allClasses = $this->convertLinks($allClasses);
     $info = array();
     if ($allClasses) {
         $classByID = array();
         $firstGradeCatCount = 0;
         foreach ($allClasses as $c) {
             $classByID[$c['id']] = $c;
             if ($c['fid'] == 0) {
                 $c['sub'] = array();
                 $info[$c['id']] = $c;
                 $firstGradeCatCount++;
             }
         }
         foreach ($allClasses as $c) {
             if ($c['fid'] > 0 && $info[$c['fid']]) {
                 array_push($info[$c['fid']]['sub'], $c);
             }
         }
         //
         if ($info) {
             foreach ($info as $c) {
                 $info[$c['id']]['key'] = $firstGradeCatCount--;
             }
         }
     }
     $this->homeInfo['info'] = str_replace(array("\r\n", "\"", "&quot;"), array(' ', '', ''), $this->homeInfo['info']);
     $this->info = $info;
     $tpl['color_id'] = intval($tpl['color_id']);
     $merchant = D('Merchant')->field(true)->where(array('mer_id' => $this->token))->find();
     if (empty($tpl['wxname'])) {
         D('Merchant_info')->where(array('token' => $this->token))->save(array('wxname' => $merchant['name']));
     }
     $tpl['wxname'] = $merchant['name'];
     $this->tpl = $tpl;
     if (empty($this->homeInfo['title'])) {
         $this->homeInfo['title'] = $merchant['name'];
     }
     if (empty($this->homeInfo['info'])) {
         $this->homeInfo['info'] = $merchant['txt_info'];
     }
     if (empty($this->homeInfo['picurl'])) {
         if (!empty($merchant['pic_info'])) {
             $merchant_image_class = new merchant_image();
             $tmp_pic_arr = explode(';', $merchant['pic_info']);
             foreach ($tmp_pic_arr as $key => $value) {
                 $this->homeInfo['picurl'] = $merchant_image_class->get_image_by_path($value);
                 break;
             }
         }
     }
     $this->assign('homeInfo', $this->homeInfo);
     /* 粉丝行为分析 */
     $this->behavior(array('mer_id' => $this->token, 'biz_id' => $this->homeInfo['id']));
 }
示例#6
0
 private function scan($id, $openid = '')
 {
     //获取粉丝信息
     import('subscribe', './source/class/');
     $subscribe = new subscribe();
     $subscribe->sub($openid);
     if ($id > 400000000 && $openid) {
         //return array($id.'_'.$openid, 'text');
         D('Location_qrcode')->where(array('id' => $id))->data(array('openid' => $openid, 'status' => 1))->save();
         return array('正在获取您的地理位置,如果十秒内没有响应,请点击左下角的加号将您的“位置”发送给我们', 'text');
     } elseif ($id > 300000000 && $openid) {
         $id -= 300000000;
         if ($order = M('Order')->field('`order_no`,`status`')->where(array('order_id' => $id))->find()) {
             if ($order['status'] < 2) {
                 return array('<a href="' . $this->config['wap_site_url'] . '/pay.php?id=' . $this->config['orderid_prefix'] . $order['order_no'] . '">查看订单详情</a>', 'text');
             } else {
                 return array('<a href="' . $this->config['wap_site_url'] . '/order.php?orderno=' . $this->config['orderid_prefix'] . $order['order_no'] . '">查看订单详情</a>', 'text');
             }
         } else {
             return array('获取不到该订单信息', 'text');
         }
         //https://api.weixin.qq.com/cgi-bin/user/info?access_token=ACCESS_TOKEN&openid=OPENID
     } else {
         if ($id > 290000000 && $openid) {
             $id -= 290000000;
             //if ($user = D('User')->field('uid')->where(array('openid' => $openid))->find()){
             if (D('Service')->where(array('store_id' => $id, 'openid' => $openid))->find()) {
                 return array('您已经绑定过客服,请不要重新绑定', 'text');
             } else {
                 D('Service')->data(array('store_id' => $id, 'openid' => $openid, 'add_time' => time()))->add();
                 return array('绑定客服成功,请前往补全客服信息', 'text');
             }
             //}
         } elseif ($id > 100000000 && $openid) {
             if ($user = D('User')->field('uid')->where(array('openid' => $openid))->find()) {
                 D('Login_qrcode')->where(array('id' => $id))->save(array('uid' => $user['uid']));
                 //获取地理位置
                 return array('登陆成功', 'text');
             } else {
                 D('Login_qrcode')->where(array('id' => $id))->save(array('uid' => -1));
                 $return[] = array('点击授权登录', '' . $openid . '', $this->config['site_logo'], $this->config['wap_site_url'] . '/weixin_bind.php?qrcode_id=' . $id);
                 return array($return, 'news');
             }
         }
     }
     if ($recognition = M("Recognition")->field(true)->where(array('id' => $id))->find()) {
         switch ($recognition['third_type']) {
             case 'group':
                 $now_group = D("Group")->field(true)->where(array('group_id' => $recognition['third_id']))->find();
                 $group_image_class = new group_image();
                 $tmp_pic_arr = explode(';', $now_group['pic']);
                 $image = $group_image_class->get_image_by_path($tmp_pic_arr[0], 's');
                 $return[] = array('[团购]' . $now_group['s_name'], $now_group['name'], $image, $this->config['site_url'] . "/wap.php?g=Wap&c=Group&a=detail&group_id={$now_group['group_id']}");
                 $this->saverelation($openid, $now_group['mer_id'], 0);
                 $return = $this->other_message($return, $now_group['mer_id'], $now_group['group_id']);
                 break;
             case 'merchant':
                 $now_merchant = D("Merchant")->field(true)->where(array('mer_id' => $recognition['third_id']))->find();
                 $pic = '';
                 if ($now_merchant['pic_info']) {
                     $images = explode(";", $now_merchant['pic_info']);
                     $merchant_image_class = new merchant_image();
                     $images = explode(";", $images[0]);
                     $pic = $merchant_image_class->get_image_by_path($images[0]);
                 }
                 $return[] = array('[商家]' . $now_merchant['name'], $now_merchant['txt_info'], $pic, $this->config['site_url'] . "/wap.php?g=Wap&c=Index&a=index&token={$recognition['third_id']}");
                 $return = $this->other_message($return, $now_merchant['mer_id']);
                 $this->saverelation($openid, $now_merchant['mer_id'], 1);
                 break;
             case 'meal':
                 $now_store = D("Merchant_store")->field(true)->where(array('store_id' => $recognition['third_id']))->find();
                 if ($now_store['have_meal']) {
                     $store_image_class = new store_image();
                     $images = $store_image_class->get_allImage_by_path($now_store['pic_info']);
                     $now_store['image'] = $images ? array_shift($images) : '';
                     $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']}");
                 }
                 $this->saverelation($openid, $now_store['mer_id'], 0);
                 $return = $this->other_message($return, $now_store['mer_id'], 0, $now_store['store_id']);
                 break;
             case 'lottery':
                 $lottery = D("Lottery")->field(true)->where(array('id' => $recognition['third_id']))->find();
                 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;
                 }
                 break;
         }
     }
     if ($return) {
         return array($return, 'news');
     }
     return array("很抱歉,暂时获取不到该二维码的信息!", 'text');
 }
示例#7
0
 private function scan($id, $openid = '', $mer_id = 0)
 {
     //     	return array($id, 'text');
     if ($id > 4000000000 && $openid) {
         $id -= 4000000000;
         if ($lottery = D("Lottery")->field(true)->where(array('id' => $id))->find()) {
             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['mer_id']}&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['mer_id']}&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['mer_id']}&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['mer_id']}&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['mer_id']}&id={$lottery['id']}");
                     break;
             }
             return array($return, 'news');
         }
         return array("很抱歉,暂时获取不到该二维码的信息!", 'text');
     } elseif ($id > 3000000000 && $openid) {
         $id -= 3000000000;
         if ($meal_order = D('Meal_order')->field('order_id, mer_id, store_id')->where(array('order_id' => $id))->find()) {
             return array('<a href="' . $this->config['site_url'] . '/wap.php?c=Meal&a=detail&orderid=' . $id . '&mer_id=' . $meal_order['mer_id'] . '&store_id=' . $meal_order['store_id'] . '">查看' . $this->config['meal_alias_name'] . '订单详情</a>', 'text');
         } else {
             return array('获取不到该订单信息', 'text');
         }
     } elseif ($id > 2000000000 && $openid) {
         $id -= 2000000000;
         return array('<a href="' . $this->config['site_url'] . '/wap.php?c=My&a=group_order&order_id=' . $id . '">查看' . $this->config['group_alias_name'] . '订单详情</a>', 'text');
     } elseif ($id > 1000000000 && $openid) {
         if ($user = D('User')->field('uid')->where(array('openid' => $openid))->find()) {
             D('Login_qrcode')->where(array('id' => $id))->save(array('uid' => $user['uid']));
             return array('登陆成功', 'text');
         } else {
             D('Login_qrcode')->where(array('id' => $id))->save(array('uid' => -1));
             $return[] = array('点击授权登录', '', $this->config['site_url'] . '/static/logo.jpg', $this->config['site_url'] . '/wap.php?c=Web_bind&a=ajax_web_login&qrcode_id=' . $id);
             return array($return, 'news');
         }
     }
     if ($recognition = M("Recognition")->field(true)->where(array('id' => $id))->find()) {
         switch ($recognition['third_type']) {
             case 'group':
                 $now_group = D("Group")->field(true)->where(array('group_id' => $recognition['third_id']))->find();
                 $group_image_class = new group_image();
                 $tmp_pic_arr = explode(';', $now_group['pic']);
                 $image = $group_image_class->get_image_by_path($tmp_pic_arr[0], 's');
                 $return[] = array('[' . $this->config['group_alias_name'] . ']' . $now_group['s_name'], $now_group['name'], $image, $this->config['site_url'] . "/wap.php?g=Wap&c=Group&a=detail&group_id={$now_group['group_id']}");
                 $this->saverelation($openid, $now_group['mer_id'], 0);
                 $return = $this->other_message($return, $now_group['mer_id'], $now_group['group_id']);
                 break;
             case 'merchant':
                 $now_merchant = D("Merchant")->field(true)->where(array('mer_id' => $recognition['third_id']))->find();
                 $pic = '';
                 if ($now_merchant['pic_info']) {
                     $images = explode(";", $now_merchant['pic_info']);
                     $merchant_image_class = new merchant_image();
                     $images = explode(";", $images[0]);
                     $pic = $merchant_image_class->get_image_by_path($images[0]);
                 }
                 $return[] = array('[商家]' . $now_merchant['name'], $now_merchant['txt_info'], $this->config['site_url'] . $pic, $this->config['site_url'] . "/wap.php?g=Wap&c=Index&a=index&token={$recognition['third_id']}");
                 $return = $this->other_message($return, $now_merchant['mer_id']);
                 $this->saverelation($openid, $now_merchant['mer_id'], 1);
                 break;
             case 'meal':
                 $now_store = D("Merchant_store")->field(true)->where(array('store_id' => $recognition['third_id']))->find();
                 $store_image_class = new store_image();
                 $images = $store_image_class->get_allImage_by_path($now_store['pic_info']);
                 $now_store['image'] = $images ? array_shift($images) : '';
                 $return[] = array('[' . $this->config['meal_alias_name'] . ']' . $now_store['name'], $now_store['txt_info'], $this->config['site_url'] . $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']}");
                 $this->saverelation($openid, $now_store['mer_id'], 0);
                 $return = $this->other_message($return, $now_store['mer_id'], 0, $now_store['store_id']);
                 break;
         }
     }
     if ($return) {
         return array($return, 'news');
     }
     return array("很抱歉,暂时获取不到该二维码的信息!", 'text');
 }
示例#8
0
 public function index()
 {
     //判断是否是微信浏览器,如果是则跳转微信授权获得openid,从而读取微信提供的位置信息。
     if ($this->is_wexin_browser && !empty($_SESSION['openid'])) {
         $database_user_long_lat = D('User_long_lat');
         $condition_user_long_lat['open_id'] = $_SESSION['openid'];
         $user_long_lat = $database_user_long_lat->where($condition_user_long_lat)->find();
         if (!empty($user_long_lat) && $user_long_lat['long'] && $user_long_lat['dateline'] > $_SERVER['REQUEST_TIME'] - 3600) {
             $this->assign('user_long_lat', $user_long_lat);
         }
     }
     //手动首页排序团购
     $index_sort_group_list = D('Group')->get_group_list('index_sort', 3, true);
     $this->assign('index_sort_group_list', $index_sort_group_list);
     //顶部广告
     $wap_index_top_adver = D('Adver')->get_adver_by_key('wap_index_top', 5);
     $this->assign('wap_index_top_adver', $wap_index_top_adver);
     //中间广告
     $wap_index_center_adver = D('Adver')->get_adver_by_key('wap_index_center', 4);
     $this->assign('wap_index_center_adver', $wap_index_center_adver);
     //导航条
     $tmp_wap_index_slider = D('Slider')->get_slider_by_key('wap_slider', 0);
     $wap_index_slider = array();
     foreach ($tmp_wap_index_slider as $key => $value) {
         $tmp_i = floor($key / 8);
         $wap_index_slider[$tmp_i][] = $value;
     }
     $this->assign('wap_index_slider', $wap_index_slider);
     //最新20条团购
     // $new_group_list = D('Group')->get_group_list('new',15,true);
     $new_group_list = D('Group')->get_group_list('index_sort', 15, true);
     $this->assign('new_group_list', $new_group_list);
     //分类信息分类
     if ($this->config['wap_home_show_classify']) {
         $database_Classify_category = D('Classify_category');
         $Zcategorys = $database_Classify_category->field('`cid`,`cat_name`')->where(array('subdir' => 1, 'cat_status' => 1))->order('`cat_sort` DESC,`cid` ASC')->select();
         if (!empty($Zcategorys)) {
             $newtmp = array();
             foreach ($Zcategorys as $vv) {
                 unset($vv['cat_field']);
                 $subdir_info = $this->get_Subdirectory($vv['cid'], 1);
                 if (!empty($subdir_info)) {
                     $vv['subdir'] = $subdir_info;
                     $newtmp[$vv['cid']] = $vv;
                     if (count($vv['subdir']) % 3 != 0) {
                         $newtmp[$vv['cid']]['subEmptyCount'] = 3 - count($vv['subdir']) % 3;
                     }
                 }
             }
             $Zcategorys = $newtmp;
         }
         $this->assign('classify_Zcategorys', $Zcategorys);
         // dump($Zcategorys);
     }
     /* 粉丝行为分析 */
     //$this->behavior(array('model'=>'Home_index'),true);
     $model = new Model();
     $sql = " select m.pic_info, m.name, m.mer_id, m.share_open from " . C('DB_PREFIX') . "merchant as m inner join " . C('DB_PREFIX') . "merchant_user_relation as r on r.mer_id=m.mer_id where r.openid='{$_SESSION['openid']}' order by r.dateline asc limit 1";
     $result = $model->query($sql);
     $now_merchant = isset($result[0]) && $result[0] ? $result[0] : null;
     if ($now_merchant) {
         $pic = '';
         if ($now_merchant['pic_info']) {
             $images = explode(";", $now_merchant['pic_info']);
             $merchant_image_class = new merchant_image();
             $images = explode(";", $images[0]);
             $pic = $merchant_image_class->get_image_by_path($images[0]);
         }
         switch ($this->config['home_share_show_open']) {
             case 0:
                 //总关闭
                 if ($now_merchant['share_open'] == 1) {
                     $share = D('Home_share')->where(array('mer_id' => $now_merchant['mer_id']))->find();
                     if (empty($share)) {
                         $share = array('title' => str_replace('{title}', $now_merchant['name'], $this->config['home_share_txt']), 'a_name' => '进入', 'a_href' => $this->config['site_url'] . '/wap.php?c=Index&a=index&token=' . $now_merchant['mer_id']);
                     }
                     $share['image'] = $pic;
                     $this->assign('share', $share);
                 } elseif ($now_merchant['share_open'] == 2) {
                     header('Location:' . $this->config['site_url'] . '/wap.php?c=Index&a=index&token=' . $now_merchant['mer_id']);
                     exit;
                 }
                 break;
             case 1:
                 //全开启首页广告
                 $share = D('Home_share')->where(array('mer_id' => $now_merchant['mer_id']))->find();
                 if (empty($share)) {
                     $share = array('title' => str_replace('{title}', $now_merchant['name'], $this->config['home_share_txt']), 'a_name' => '进入', 'a_href' => $this->config['site_url'] . '/wap.php?c=Index&a=index&token=' . $now_merchant['mer_id']);
                 }
                 $share['image'] = $pic;
                 $this->assign('share', $share);
                 break;
             case 2:
                 //全开启跳转到首页
                 header('Location:' . $this->config['site_url'] . '/wap.php?c=Index&a=index&token=' . $now_merchant['mer_id']);
                 exit;
                 break;
         }
     }
     $this->display();
 }
示例#9
0
 public function follow_merchant()
 {
     $mod = new Model();
     //$_SESSION['openid'] = 'onfo6tySRgO5tYJtkJ4tAueQI51g';
     $sql = "SELECT b.* FROM  " . C('DB_PREFIX') . "merchant_user_relation AS a INNER JOIN  " . C('DB_PREFIX') . "merchant as b ON a.mer_id=b.mer_id WHERE a.openid='{$_SESSION['openid']}'";
     $res = $mod->query($sql);
     $merchant_image_class = new merchant_image();
     foreach ($res as &$r) {
         $images = explode(";", $r['pic_info']);
         $images = explode(";", $images[0]);
         $r['img'] = $merchant_image_class->get_image_by_path($images[0]);
         $r['url'] = C('config.site_url') . '/wap.php?c=Index&a=index&token=' . $r['mer_id'];
     }
     $this->assign('follow_list', $res);
     $this->display();
 }
示例#10
0
 public function ajax_del_pic()
 {
     $merchant_image_class = new merchant_image();
     $merchant_image_class->del_image_by_path($_POST['path']);
 }
示例#11
0
 public function index()
 {
     //右侧广告
     //     	$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);
     //所有分类 包含2级分类
     $all_category_list = D('Group_category')->get_category();
     $this->assign('all_category_list', $all_category_list);
     //热门搜索词
     $search_hot_list = D('Search_hot')->get_list(12, 0);
     $this->assign('search_hot_list', $search_hot_list);
     $now_group = D('Group')->get_group_by_groupId($_GET['group_id'], 'hits-setInc');
     if (empty($now_group)) {
         $this->group_noexit_tips($this->config['group_alias_name'] . '不存在。');
     }
     //商家的活动
     $lotterys = D("Lottery")->field(true)->where(array('token' => $now_group['mer_id'], 'statdate' => array('lt', time()), 'enddate' => array('gt', time())))->select();
     foreach ($lotterys as $lottery) {
         $index_right_adver[] = array('name' => $lottery['title'], 'pic' => $lottery['starpicurl'], 'url' => 'javascript:void(0);', 'id' => $lottery['id']);
     }
     $this->assign('index_right_adver', $index_right_adver);
     if ($now_group['cue']) {
         $now_group['cue_arr'] = unserialize($now_group['cue']);
     }
     if (!empty($now_group['pic_info'])) {
         $merchant_image_class = new merchant_image();
         $now_group['merchant_pic'] = $merchant_image_class->get_allImage_by_path($now_group['pic_info']);
     }
     if (!empty($this->user_session)) {
         $database_user_collect = D('User_collect');
         $condition_user_collect['type'] = 'group_detail';
         $condition_user_collect['id'] = $now_group['group_id'];
         $condition_user_collect['uid'] = $this->user_session['uid'];
         if ($database_user_collect->where($condition_user_collect)->find()) {
             $now_group['is_collect'] = true;
         }
     }
     $this->assign('now_group', $now_group);
     $f_category = D('Group_category')->get_category_by_id($now_group['cat_fid']);
     if (empty($f_category)) {
         $this->group_noexit_tips($this->config['group_alias_name'] . '上级分类不存在。');
     }
     $this->assign('f_category', $f_category);
     $s_category = D('Group_category')->get_category_by_id($now_group['cat_id']);
     if (empty($s_category)) {
         $this->group_noexit_tips($this->config['group_alias_name'] . '分类不存在。');
     }
     $this->assign('s_category', $s_category);
     if ($now_group['packageid'] > 0) {
         $packages = M('Group_packages')->where(array('id' => $now_group['packageid'], 'mer_id' => $now_group['mer_id']))->find();
         if (!empty($packages['groupidtext'])) {
             $mpackages = unserialize($packages['groupidtext']);
         } else {
             $mpackages = false;
         }
         $this->assign('mpackages', $mpackages);
     }
     //商家团购列表
     $merchant_group_list = D('Group')->get_grouplist_by_MerchantId($now_group['mer_id'], 0, false, $now_group['group_id']);
     $this->assign('merchant_group_list', $merchant_group_list);
     //猜您喜欢
     $like_group_list = D('Group')->get_grouplist_by_catId($now_group['cat_id'], $now_group['cat_fid'], 5);
     foreach ($like_group_list as $key => $value) {
         if ($value['group_id'] == $now_group['group_id']) {
             unset($like_group_list[$key]);
         }
     }
     $this->assign('like_group_list', $like_group_list);
     //分类下最热门团购,销售量
     $category_hot_group_list = D('Group')->get_grouplist_by_catId($now_group['cat_id'], $now_group['cat_fid'], 4, false, '`sale_count` DESC');
     foreach ($category_hot_group_list as $key => $value) {
         if ($value['group_id'] == $now_group['group_id']) {
             unset($category_hot_group_list[$key]);
         }
     }
     $this->assign('category_hot_group_list', $category_hot_group_list);
     $this->display();
 }
示例#12
0
 public function set()
 {
     $now_group = D('Group')->get_group_by_groupId($_GET['group_id'], 'hits-setInc');
     if (empty($now_group)) {
         $this->error_tips('当前' . $this->config['group_alias_name'] . '不存在!');
     }
     if ($now_group['cue']) {
         $now_group['cue_arr'] = unserialize($now_group['cue']);
     }
     if (!empty($now_group['pic_info'])) {
         $merchant_image_class = new merchant_image();
         $now_group['merchant_pic'] = $merchant_image_class->get_allImage_by_path($now_group['pic_info']);
     }
     if (!empty($this->user_session)) {
         $database_user_collect = D('User_collect');
         $condition_user_collect['type'] = 'group_detail';
         $condition_user_collect['id'] = $now_group['group_id'];
         $condition_user_collect['uid'] = $this->user_session['uid'];
         if ($database_user_collect->where($condition_user_collect)->find()) {
             $now_group['is_collect'] = true;
         }
     }
     $this->assign('now_group', $now_group);
     if ($now_group['reply_count']) {
         $reply_list = D('Reply')->get_reply_list($now_group['group_id'], 0, count($now_group['store_list']), 3);
         $this->assign('reply_list', $reply_list);
     }
     $merchant_group_list = D('Group')->get_grouplist_by_MerchantId($now_group['mer_id'], 3, true, $now_group['group_id']);
     $this->assign('merchant_group_list', $merchant_group_list);
     //分类下其他团购
     $category_group_list = D('Group')->get_grouplist_by_catId($now_group['cat_id'], $now_group['cat_fid'], 3, true);
     foreach ($category_group_list as $key => $value) {
         if ($value['group_id'] == $now_group['group_id']) {
             unset($category_group_list[$key]);
         }
     }
     $this->assign('category_group_list', $category_group_list);
     /* 粉丝行为分析 */
     D('Merchant_request')->add_request($now_group['mer_id'], array('group_hits' => 1));
     /* 粉丝行为分析 */
     $this->behavior(array('mer_id' => $now_group['mer_id'], 'biz_id' => $now_group['group_id'], 'keyword' => strval($_GET['keywords'])));
     $this->display();
 }
示例#13
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();
 }