Ejemplo n.º 1
0
 public function get_list($lat, $long, $page, $pagesize, $activity_type)
 {
     $where = array("status" => 0, "invite_time" => array("gt", time()));
     if ($activity_type !== false) {
         $sql = "SELECT i.*, u.* FROM " . C("DB_PREFIX") . "user as u INNER JOIN " . C("DB_PREFIX") . "invitation as i ON i.uid=u.uid WHERE i.status=0 AND i.activity_type=" . $activity_type . " AND i.invite_time>" . time() . " ORDER BY i.pigcms_id DESC, u.sex DESC";
         $where["activity_type"] = intval($activity_type);
     } else {
         $sql = "SELECT i.*, u.* FROM " . C("DB_PREFIX") . "user as u INNER JOIN " . C("DB_PREFIX") . "invitation as i ON i.uid=u.uid WHERE i.status=0 AND i.invite_time>" . time() . " ORDER BY i.pigcms_id DESC, u.sex DESC";
     }
     $start = ($page - 1) * $pagesize;
     $count = $this->where($where)->count();
     $sql .= " limit {$start}, {$pagesize}";
     $mode = new Model();
     $res = $mode->query($sql);
     $today = strtotime(date("Y-m-d")) + 86400;
     $tomorrow = $today + 86400;
     $lastday = $tomorrow + 86400;
     foreach ($res as &$v) {
         $v["_time"] = date("Y-m-d H:i", $v["invite_time"]);
         $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"] = 1000 < $v["juli"] ? number_format($v["juli"] / 1000, 1) . "km" : ($v["juli"] < 100 ? "<100m" : $v["juli"] . "m");
         $v["invite_time"] = $v["invite_time"] < $today ? "今天 " . date("H:i", $v["invite_time"]) : ($v["invite_time"] < $tomorrow ? "明天  " . date("H:i", $v["invite_time"]) : ($v["invite_time"] < $lastday ? "后天  " . date("H:i", $v["invite_time"]) : date("m-d H:i", $v["invite_time"])));
         $v["birthday"] && ($v["age"] = date("Y") - date("Y", strtotime($v["birthday"])));
         $v["age"] = 100 < $v["age"] || $v["age"] < 0 ? "保密" : $v["age"] . "岁";
     }
     return array("data" => $res, "total" => $count);
 }
Ejemplo n.º 2
0
 public function mysign()
 {
     $invitation_signs = D("Invitation_sign")->field("invid")->where(array("uid" => $this->user_session["uid"]))->order("invid DESC")->select();
     $invids = $pre = "";
     foreach ($invitation_signs as $is) {
         $invids .= $pre . $is["invid"];
         $pre = ",";
     }
     $today = strtotime(date("Y-m-d")) + 86400;
     $tomorrow = $today + 86400;
     $lastday = $tomorrow + 86400;
     if ($invids) {
         $sql = "SELECT i.*, u.* FROM " . C("DB_PREFIX") . "user as u INNER JOIN " . C("DB_PREFIX") . "invitation as i ON i.uid=u.uid WHERE i.pigcms_id IN ({$invids}) ORDER BY i.pigcms_id DESC, u.sex DESC";
         $mode = new Model();
         $res = $mode->query($sql);
         foreach ($res as &$v) {
             $v["_time"] = date("Y-m-d H:i", $v["invite_time"]);
             $v["juli"] = ROUND(6378.138 * 2 * ASIN(SQRT(POW(SIN(($this->_lat * PI() / 180 - $v["lat"] * PI() / 180) / 2), 2) + COS($this->_lat * PI() / 180) * COS($v["lat"] * PI() / 180) * POW(SIN(($this->_long * PI() / 180 - $v["long"] * PI() / 180) / 2), 2))) * 1000);
             $v["juli"] = 1000 < $v["juli"] ? number_format($v["juli"] / 1000, 1) . "km" : ($v["juli"] < 100 ? "<100m" : $v["juli"] . "m");
             $v["invite_time"] = $v["invite_time"] < $today ? "今天 " . date("H:i", $v["invite_time"]) : ($v["invite_time"] < $tomorrow ? "明天  " . date("H:i", $v["invite_time"]) : ($v["invite_time"] < $lastday ? "后天  " . date("H:i", $v["invite_time"]) : date("m-d H:i", $v["invite_time"])));
             $v["birthday"] && ($v["age"] = date("Y") - date("Y", strtotime($v["birthday"])));
         }
         $this->assign("date_list", $res);
     }
     $this->display();
 }
Ejemplo n.º 3
0
 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;
 }