Exemplo n.º 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();
 }
Exemplo n.º 2
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;
 }
Exemplo n.º 3
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");
 }
Exemplo n.º 4
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']));
 }
Exemplo n.º 5
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');
 }
Exemplo n.º 6
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');
 }
Exemplo n.º 7
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();
 }
Exemplo n.º 8
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();
 }
Exemplo n.º 9
0
 public function ajax_upload_pic()
 {
     if ($_FILES['imgFile']['error'] != 4) {
         $img_mer_id = sprintf('%09d', $this->merchant_session['mer_id']);
         $rand_num = mt_rand(10, 99) . '/' . substr($img_mer_id, 0, 3) . '/' . substr($img_mer_id, 3, 3) . '/' . substr($img_mer_id, 6, 3);
         $upload_dir = './upload/merchant/' . $rand_num . '/';
         if (!is_dir($upload_dir)) {
             mkdir($upload_dir, 511, true);
         }
         import('ORG.Net.UploadFile');
         $upload = new UploadFile();
         $upload->maxSize = 3 * 1024 * 1024;
         $upload->allowExts = array('jpg', 'jpeg', 'png', 'gif');
         $upload->allowTypes = array('image/png', 'image/jpg', 'image/jpeg', 'image/gif');
         $upload->savePath = $upload_dir;
         $upload->saveRule = 'uniqid';
         if ($upload->upload()) {
             $uploadList = $upload->getUploadFileInfo();
             $title = $rand_num . ',' . $uploadList[0]['savename'];
             $merchant_image_class = new merchant_image();
             $url = $merchant_image_class->get_image_by_path($title);
             exit(json_encode(array('error' => 0, 'url' => $url, 'title' => $title)));
         } else {
             exit(json_encode(array('error' => 1, 'message' => $upload->getErrorMsg())));
         }
     } else {
         exit(json_encode(array('error' => 1, 'message' => '没有选择图片')));
     }
 }