示例#1
0
 public function index()
 {
     global_run();
     init_app_page();
     $GLOBALS['tmpl']->assign("no_nav", true);
     //无分类下拉
     if (check_save_login() != LOGIN_STATUS_LOGINED) {
         app_redirect(url("index", "user#login"));
     }
     $GLOBALS['tmpl']->assign("page_title", "我的点评");
     assign_uc_nav_list();
     //begin review
     require_once APP_ROOT_PATH . "system/model/review.php";
     require_once APP_ROOT_PATH . "app/Lib/page.php";
     //分页
     $page_size = 10;
     $page = intval($_REQUEST['p']);
     if ($page == 0) {
         $page = 1;
     }
     $limit = ($page - 1) * $page_size . "," . $page_size;
     $dp_res = get_dp_list($limit, "", " user_id = " . $GLOBALS['user_info']['id']);
     $dp_list = $dp_res['list'];
     $total = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "supplier_location_dp  where " . $dp_res['condition']);
     $page = new Page($total, $page_size);
     //初始化分页对象
     $p = $page->show();
     $GLOBALS['tmpl']->assign('pages', $p);
     foreach ($dp_list as $k => $v) {
         if ($v['deal_id'] > 0) {
             $data_info = load_auto_cache("deal", array("id" => $v['deal_id']));
         } elseif ($v['youhui_id'] > 0) {
             $data_info = load_auto_cache("youhui", array("id" => $v['youhui_id']));
         } elseif ($v['event_id'] > 0) {
             $data_info = load_auto_cache("event", array("id" => $v['event_id']));
         }
         if (empty($data_info)) {
             $data_info = load_auto_cache("store", array("id" => $v['supplier_location_id']));
         }
         $dp_list[$k]['data_info'] = $data_info;
     }
     $GLOBALS['tmpl']->assign('dp_list', $dp_list);
     require_once APP_ROOT_PATH . "system/model/topic.php";
     global $no_lazy;
     $no_lazy = true;
     $review_html = decode_topic_without_img($GLOBALS['tmpl']->fetch("inc/uc_review_list.html"));
     $GLOBALS['tmpl']->assign("review_html", $review_html);
     //end review
     $no_lazy = false;
     $GLOBALS['tmpl']->display("uc/uc_review_index.html");
 }
示例#2
0
 public function index()
 {
     //检查用户,用户密码
     $user = $GLOBALS['user_info'];
     $user_id = intval($user['id']);
     $type = "tech";
     $city_name = strim($GLOBALS['request']['city_name']);
     //城市名称
     $tech_id = $user_id;
     require_once APP_ROOT_PATH . "system/model/tech.php";
     $tech_info = get_tech($tech_id);
     $relate_data_name = $tech_info['name'];
     $page = intval($GLOBALS['request']['page']);
     /*分页*/
     $city_name = strim($GLOBALS['request']['city_name']);
     //城市分类ID
     $root = array();
     $root['return'] = 1;
     $page = $page == 0 ? 1 : $page;
     $page_size = PAGE_SIZE;
     $limit = ($page - 1) * $page_size . "," . $page_size;
     require_once APP_ROOT_PATH . "system/model/review.php";
     require_once APP_ROOT_PATH . "system/model/user.php";
     $message_re = get_dp_list($limit, $param = array("deal_id" => $deal_id, "youhui_id" => $youhui_id, "event_id" => $event_id, "location_id" => $location_id, "tech_id" => $tech_id, "tag" => ""), "", "");
     $root['message_list'] = $message_re['list'];
     if (count($message_re['list']) > 0) {
         $sql = "select count(*) from " . DB_PREFIX . "supplier_location_dp where  " . $message_re['condition'];
         $message_re['count'] = $GLOBALS['db']->getOne($sql);
     }
     $root['message_count'] = $message_re['count'];
     $page_total = ceil($message_re['count'] / $page_size);
     $root['page'] = array("page" => $page, "page_total" => $page_total, "page_size" => $page_size);
     $root['type'] = $type;
     $root['id'] = $id;
     $root['page_title'] = "点评列表";
     $root['city_name'] = $city_name;
     output($root);
 }
示例#3
0
 public function index()
 {
     $type = strim($GLOBALS['request']['type']);
     $id = intval($GLOBALS['request']['id']);
     $city_name = strim($GLOBALS['request']['city_name']);
     //城市名称
     $deal_id = 0;
     $youhui_id = 0;
     $location_id = 0;
     $event_id = 0;
     $tech_id = 0;
     if ($type == "deal") {
         $deal_id = $id;
         require_once APP_ROOT_PATH . "system/model/deal.php";
         $deal_info = get_deal($deal_id);
         $relate_data_name = $deal_info['name'];
     } elseif ($type == "supplier") {
         $location_id = $id;
         require_once APP_ROOT_PATH . "system/model/supplier.php";
         $location_info = get_location($location_id);
         $relate_data_name = $location_info['name'];
     } elseif ($type == "youhui") {
         $youhui_id = $id;
         require_once APP_ROOT_PATH . "system/model/youhui.php";
         $youhui_info = get_youhui($youhui_id);
         $relate_data_name = $youhui_info['name'];
     } elseif ($type == "event") {
         $event_id = $id;
         require_once APP_ROOT_PATH . "system/model/event.php";
         $event_info = get_event($event_id);
         $relate_data_name = $event_info['name'];
     } elseif ($type == "tech") {
         $tech_id = $id;
         require_once APP_ROOT_PATH . "system/model/tech.php";
         $tech_info = get_tech($tech_id);
         $relate_data_name = $tech_info['name'];
     }
     $page = intval($GLOBALS['request']['page']);
     /*分页*/
     $city_name = strim($GLOBALS['request']['city_name']);
     //城市分类ID
     //检查用户,用户密码
     $user = $GLOBALS['user_info'];
     $user_id = intval($user['id']);
     $root = array();
     $root['return'] = 1;
     $page = $page == 0 ? 1 : $page;
     $page_size = PAGE_SIZE;
     $limit = ($page - 1) * $page_size . "," . $page_size;
     // 		$message_re=m_get_message_list($limit," m.rel_table = 'deal' and m.rel_id=".$tuan_id." and m.is_buy = 1",0);/*购买评论*/
     require_once APP_ROOT_PATH . "system/model/review.php";
     require_once APP_ROOT_PATH . "system/model/user.php";
     $message_re = get_dp_list($limit, $param = array("deal_id" => $deal_id, "youhui_id" => $youhui_id, "event_id" => $event_id, "location_id" => $location_id, "tech_id" => $tech_id, "tag" => ""), "", "");
     foreach ($message_re['list'] as $k => $v) {
         $message_re['list'][$k]['width'] = $v['point'] / 5 * 100;
         $message_re['list'][$k]['create_time'] = to_date($v['create_time']);
         $uinfo = load_user($v['user_id']);
         $message_re['list'][$k]['user_name'] = $uinfo['user_name'];
         foreach ($message_re['list'][$k]['images'] as $kk => $vv) {
             $message_re['list'][$k]['images'][$kk] = get_abs_img_root(get_spec_image($vv, 60, 60, 1));
             $message_re['list'][$k]['oimages'][$kk] = get_abs_img_root($vv);
         }
     }
     $root['message_list'] = $message_re['list'];
     if (count($message_re['list']) > 0) {
         $sql = "select count(*) from " . DB_PREFIX . "supplier_location_dp where  " . $message_re['condition'];
         $message_re['count'] = $GLOBALS['db']->getOne($sql);
     }
     $root['message_count'] = $message_re['count'];
     //$deal = get_deal($tuan_id);
     $dp_info = load_dp_info(array("deal_id" => $deal_id, "youhui_id" => $youhui_id, "event_id" => $event_id, "location_id" => $location_id, "tech_id" => $tech_id));
     $root['name'] = $relate_data_name;
     //星级点评数
     $root['star_1'] = $dp_info['dp_count_1'];
     $root['star_2'] = $dp_info['dp_count_2'];
     $root['star_3'] = $dp_info['dp_count_3'];
     $root['star_4'] = $dp_info['dp_count_4'];
     $root['star_5'] = $dp_info['dp_count_5'];
     $root['star_dp_width_1'] = $dp_info['avg_point_1_percent'];
     $root['star_dp_width_2'] = $dp_info['avg_point_2_percent'];
     $root['star_dp_width_3'] = $dp_info['avg_point_3_percent'];
     $root['star_dp_width_4'] = $dp_info['avg_point_4_percent'];
     $root['star_dp_width_5'] = $dp_info['avg_point_5_percent'];
     $buy_dp_sum = 0.0;
     // 		$buy_dp_group = $GLOBALS['db']->getAll("select point,count(*) as num from ".DB_PREFIX."message where rel_id = ".$tuan_id." and rel_table = 'deal' and pid = 0 and is_buy = 1 group by point");
     // 		foreach($buy_dp_group as $dp_k=>$dp_v)
     // 		{
     // 			$star = intval($dp_v['point']);
     // 			if ($star >= 1 && $star <= 5){
     // 				$root['star_'.$star] = $dp_v['num'];
     // 				$buy_dp_sum += $star * $dp_v['num'];
     // 				$root['star_dp_width_'.$star] = (round($dp_v['num']/ $message_re['count'],1)) * 100;
     // 			}
     // 		}
     //点评平均分
     $root['buy_dp_sum'] = $dp_info['dp_count'];
     $root['buy_dp_avg'] = $dp_info['avg_point'];
     $root['buy_dp_width'] = $dp_info['avg_point'] / 5 * 100;
     $page_total = ceil($message_re['count'] / $page_size);
     $root['page'] = array("page" => $page, "page_total" => $page_total, "page_size" => $page_size);
     $root['allow_dp'] = 0;
     //0:不允许点评;1:允许点评
     //判断用户是否购买了这个商品
     if ($user_id > 0) {
         // 			$sql = "select count(*) from ".DB_PREFIX."deal_order_item as doi left join ".DB_PREFIX."deal_order as do on doi.order_id = do.id where doi.deal_id = ".intval($tuan_id)." and do.user_id = ".intval($user_id)." and do.pay_status = 2";
         // 			//$root['sql'] = $sql;
         // 			if($GLOBALS['db']->getOne($sql)>0)
         // 			{
         // 				$root['allow_dp'] = 1;
         // 			}
         $dp_status = check_dp_status($user_id, array("deal_id" => $deal_id, "youhui_id" => $youhui_id, "event_id" => $event_id, "location_id" => $location_id));
         if ($dp_status['status']) {
             $root['allow_dp'] = 1;
         }
         if ($type == "tech" && $user_id == $id) {
             //技师本身不能给自己点评
             $root['allow_dp'] = 0;
         }
     }
     $root['type'] = $type;
     $root['id'] = $id;
     $root['page_title'] = "点评列表";
     $root['city_name'] = $city_name;
     output($root);
 }
示例#4
0
 public function index()
 {
     require_once APP_ROOT_PATH . 'system/model/deal.php';
     /**
      * has_attr: 0:无属性; 1:有属性
      * 有商品属性在要购买时,要选择属性后,才能购买
      * change_cart_request_server: 
      * 编辑购买车商品时,需要提交到服务器端,让服务器端通过一些判断返回一些信息回来(如:满多少钱,可以免运费等一些提示)
      * 0:提交,1:不提交;
      * image_attr_a_id_{$attr_a_id} 图片列表,可以根据属性ID值,来切换图片列表;默认为:0
      * limit_num: 库存数量
      */
     $id = intval($GLOBALS['request']['id']);
     //商品ID
     $user = $GLOBALS['user_info'];
     $user_id = intval($user['id']);
     $is_collect = 0;
     if ($user_id > 0) {
         $sql2 = "select count(*) from " . DB_PREFIX . "deal_collect where deal_id = " . $id . " and user_id=" . $user_id;
         if ($GLOBALS['db']->getOne($sql2) > 0) {
             $is_collect = 1;
         }
     }
     $ypoint = $m_latitude = doubleval($GLOBALS['request']['m_latitude']);
     //ypoint
     $xpoint = $m_longitude = doubleval($GLOBALS['request']['m_longitude']);
     //xpoint
     $city_name = strim($GLOBALS['request']['city_name']);
     //城市名称
     $item = get_deal($id);
     //$item['origin_price_format'] = format_price2($item['origin_price']);
     //$item['current_price_format'] = format_price2($item['current_price']);
     //$item['save_price_format'] = format_price2($item['save_price']);
     $root = getGoodsArray($item);
     //$message_re=m_get_message_list(3," m.rel_table = 'deal' and m.rel_id=".$id." and m.is_buy = 1");/*购买评论*/
     require_once APP_ROOT_PATH . "system/model/review.php";
     require_once APP_ROOT_PATH . "system/model/user.php";
     $message_re = get_dp_list(3, $param = array("deal_id" => $id, "youhui_id" => 0, "event_id" => 0, "location_id" => 0, "tag" => ""), "", "");
     foreach ($message_re['list'] as $k => $v) {
         $message_re['list'][$k]['width'] = $v['point'] / 5 * 100;
         if ($v['point'] > 0) {
             $str = "";
             for ($i = 1; $i <= $v['point']; $i++) {
                 $str .= "★";
             }
             $message_re['list'][$k]['xing'] = $str;
         }
         $message_re['list'][$k]['reply_time_format'] = date("Y-m-d H:i:s", $v['reply_time']);
         $uinfo = load_user($v['user_id']);
         $message_re['list'][$k]['user_name'] = $uinfo['user_name'];
         foreach ($message_re['list'][$k]['images'] as $kk => $vv) {
             $message_re['list'][$k]['images'][$kk] = get_abs_img_root(get_spec_image($vv, 60, 60, 1));
             $message_re['list'][$k]['oimages'][$kk] = get_abs_img_root($vv);
         }
     }
     $root['message_list'] = $message_re['list'];
     if (count($message_re['list']) > 0) {
         $sql = "select count(*) from " . DB_PREFIX . "supplier_location_dp where  " . $message_re['condition'];
         $message_re['count'] = $GLOBALS['db']->getOne($sql);
     }
     $root['message_count'] = $message_re['count'];
     $pi = 3.14159265;
     //圆周率
     $r = 6378137;
     //地球平均半径(米)
     $root['distance'] = ACOS(SIN($ypoint * $pi / 180) * SIN($item['supplier_address_info']['ypoint'] * $pi / 180) + COS($ypoint * $pi / 180) * COS($item['supplier_address_info']['ypoint'] * $pi / 180) * COS($xpoint * $pi / 180 - $item['supplier_address_info']['xpoint'] * $pi / 180)) * $r;
     $root['return'] = 1;
     $images = array();
     //image_attr_1_id_{$attr_1_id} 图片列表,可以根据属性ID值,来切换图片列表
     $sql = "select img from " . DB_PREFIX . "deal_gallery where deal_id = " . intval($id) . " order by sort asc";
     $list = $GLOBALS['db']->getAll($sql);
     $gallery = array();
     $big_gallery = array();
     foreach ($list as $k => $image) {
         $gallery[] = get_abs_img_root(get_spec_image($image['img'], 460, 280, 1));
         $big_gallery[] = get_abs_img_root(get_spec_image($image['img'], 0, 0, 0));
     }
     $root['gallery'] = $gallery;
     $root['big_gallery'] = $big_gallery;
     //支持的门店列表;
     $sql = "select id,name,address,tel,xpoint,ypoint,supplier_id from " . DB_PREFIX . "supplier_location where id in (select location_id from " . DB_PREFIX . "deal_location_link where deal_id = " . $id . ")";
     $supplier_location_list = $GLOBALS['db']->getAll($sql);
     foreach ($supplier_location_list as $k => $sl) {
         $supplier_location_list[$k]['distance'] = ACOS(SIN($ypoint * $pi / 180) * SIN($sl['ypoint'] * $pi / 180) + COS($ypoint * $pi / 180) * COS($sl['ypoint'] * $pi / 180) * COS($xpoint * $pi / 180 - $sl['xpoint'] * $pi / 180)) * $r;
     }
     $root['supplier_location_list'] = $supplier_location_list;
     //其它团购
     //if($GLOBALS['request']['from']=="wap"){
     $time = get_gmtime();
     $time_condition = '  and is_shop = 0 ';
     $time_condition .= ' and (' . $time . '>=begin_time or begin_time = 0 ) and (' . $time . '< end_time or end_time = 0) and buy_type<>2 and is_recommend=1';
     $time_condition .= ' and id<>' . $id;
     /*
     if($item['cate_id']>0)
     {
     	$ids = load_auto_cache("deal_sub_parent_cate_ids",array("cate_id"=>$item['cate_id']));
     	$time_condition .= " and cate_id in (".implode(",",$ids).")";
     
     }
     
     if($item['city_id']==0)
     {
     	$city = get_current_deal_city();
     	$city_id = $city['id'];
     	$time_condition .= " and city_id in (".implode(",",$item['city_id']).")";
     }
     if($item['city_id']>0)
     {
     	$ids = load_auto_cache("deal_city_belone_ids",array("city_id"=>$item['city_id']));
     	if($ids)
     	{
     		$time_condition .= " and city_id in (".implode(",",$ids).")";
     
     	}
     }
     */
     $dealsql = "select * from " . DB_PREFIX . "deal where is_effect = 1 and  is_delete = 0 " . $time_condition . " order by sort desc,id desc limit 4";
     $deal_other = $GLOBALS['db']->getAll($dealsql);
     $root['deal_other'] = $deal_other;
     /*门店评论*/
     /*
     $comment_list=$GLOBALS['db']->getAll("select a.id,a.content,a.point,a.avg_price,a.create_time,b.id as user_id,b.user_name from ".DB_PREFIX."supplier_location_dp as a left join ".DB_PREFIX."user as b on b.id=a.user_id where a.supplier_location_id = ".$root['supplier_location_id']." and a.status = 1");
     $comment_count=$GLOBALS['db']->getOne("select count(*) from ".DB_PREFIX."supplier_location_dp as a left join ".DB_PREFIX."user as b on b.id=a.user_id where a.supplier_location_id = ".$root['supplier_location_id']." and a.status = 1");
     $count_point=0;
     foreach($comment_list as $k=>$v)
     {
     	$comment_list[$k]['avg_price']=round($v['avg_price'],2);
     	$comment_list[$k]['time']=pass_date($v['create_time']);
     	$count_point+=$v['point'];
     }
     $root['comment_list']=$comment_list;
     $score=round($count_point/$comment_count,2);
     $width = $score > 0 ? ($score / 5) * 100 : 0;
     $root['point']=$score;
     $root['width']=$width;
     $root['comment_count']=$comment_count;
     */
     /*商品评论*/
     /*
     $comment_list=$GLOBALS['db']->getAll("select a.id,a.content,a.point,a.avg_price,a.create_time,b.id as user_id,b.user_name from ".DB_PREFIX."deal as a left join ".DB_PREFIX."user as b on b.id=a.user_id where a.supplier_location_id = ".$root['supplier_location_id']." and a.status = 1");
     $comment_count=$GLOBALS['db']->getOne("select count(*) from ".DB_PREFIX."supplier_location_dp as a left join ".DB_PREFIX."user as b on b.id=a.user_id where a.supplier_location_id = ".$root['supplier_location_id']." and a.status = 1");
     $count_point=0;
     foreach($comment_list as $k=>$v)
     {
     	$comment_list[$k]['avg_price']=round($v['avg_price'],2);
     	$comment_list[$k]['time']=pass_date($v['create_time']);
     	$count_point+=$v['point'];
     }
     $root['comment_list']=$comment_list;
     $score=round($count_point/$comment_count,2);
     $width = $score > 0 ? ($score / 5) * 100 : 0;
     $root['point']=$score;
     $root['width']=$width;
     $root['comment_count']=$comment_count;
     */
     //购买点评数量
     $comment_count = $root['message_count'];
     // intval($GLOBALS['db']->getOne("select count(*) from ".DB_PREFIX."message where rel_id = ".$id." and rel_table = 'deal' and pid = 0 and is_buy = 1"));
     $buy_dp_sum = 0.0;
     $buy_dp_group = $GLOBALS['db']->getAll("select point,count(*) as num from " . DB_PREFIX . "message where rel_id = " . $id . " and rel_table = 'deal' and pid = 0 and is_buy = 1 group by point");
     foreach ($buy_dp_group as $dp_k => $dp_v) {
         $star = intval($dp_v['point']);
         if ($star >= 1 && $star <= 5) {
             $buy_dp_sum += $star * $dp_v['num'];
         }
     }
     //点评平均分
     $score = round($buy_dp_sum / $comment_count, 1);
     $width = $score > 0 ? $score / 5 * 110 : 0;
     $root['point'] = $score;
     $root['width'] = $width;
     /*
     $root['comment_count']=$comment_count;
     
     $sql = "select m.id,m.content,m.create_time,m.update_time, m.point,m.admin_reply,m.admin_id,u.user_name from ".DB_PREFIX."message m left join fanwe_user u on u.id = m.user_id where m.rel_id = ".$id." and m.rel_table = 'deal' and m.pid = 0 and m.is_buy = 1  order by m.create_time desc limit 0,8";
     $comment_list = $GLOBALS['db']->getAll($sql);			
     $root['comment_list']=$comment_list;
     */
     if ($item['is_shop'] == 0) {
         $root['page_title'] = "团购详情";
     } elseif ($item['is_shop'] == 1) {
         $root['page_title'] = "商品详情";
     } else {
         $root['page_title'] = "代金券详情";
     }
     //}
     $root['is_collect'] = $is_collect;
     $root['city_name'] = $city_name;
     output($root);
 }
示例#5
0
 public function index()
 {
     //print_r($GLOBALS['request']);
     //检查用户,用户密码
     $user = $GLOBALS['user_info'];
     $user_id = intval($user['id']);
     $id = intval($GLOBALS['request']['id']);
     $city_id = intval($GLOBALS['request']['city_id']);
     $act_2 = $GLOBALS['request']['act_2'];
     //子操作 空:没子操作; dz:设置打折提醒
     if ($act_2 != '' && $user_id == 0) {
         $root['act_2'] = $act_2;
         $root['user_login_status'] = 0;
         //用户登陆状态:1:成功登陆;0:未成功登陆
         output($root);
     }
     $ypoint = $m_latitude = doubleval($GLOBALS['request']['m_latitude']);
     //ypoint
     $xpoint = $m_longitude = doubleval($GLOBALS['request']['m_longitude']);
     //xpoint
     $pi = 3.14159265;
     //圆周率
     $r = 6378137;
     //地球平均半径(米)
     $sql = "select a.id,a.name,a.avg_point,a.address,a.api_address,a.supplier_id,a.tel,a.dp_count,a.avg_point,a.supplier_id as brand_id,a.brief,a.preview as logo,a.xpoint,a.ypoint,a.route,a.youhui_count,a.event_count,(select count(*) from " . DB_PREFIX . "supplier_location_dp as dp where dp.supplier_location_id = a.id and dp.status = 1) as comment_count, c.name as city_name, \n\t\t(ACOS(SIN(({$ypoint} * {$pi}) / 180 ) *SIN((a.ypoint * {$pi}) / 180 ) +COS(({$ypoint} * {$pi}) / 180 ) * COS((a.ypoint * {$pi}) / 180 ) *COS(({$xpoint} * {$pi}) / 180 - (a.xpoint * {$pi}) / 180 ) ) * {$r}) as distance \n\t\t  from " . DB_PREFIX . "supplier_location as a " . " left outer join " . DB_PREFIX . "deal_city as c on c.id = a.city_id " . "where a.id = {$id} ";
     //file_put_contents(APP_ROOT_PATH. "sjmapi/log/sql_".strftime("%Y%m%d%H%M%S",time()).".txt",$sql);
     $list = $GLOBALS['db']->getRow($sql);
     $root = m_merchantItem($list);
     //is_auto_order 1:手机自主下单;消费者(在手机端上)可以直接给该门店支付金额
     $sql = "select is_auto_order from  " . DB_PREFIX . "supplier_location where id = " . $id;
     $is_auto_order = $GLOBALS['db']->getOne($sql);
     $root['is_auto_order'] = intval($is_auto_order);
     //$root['is_auto_order'] = 0;
     //其它门店
     $sql = "select a.id,a.name,a.avg_point,a.address,a.api_address,a.supplier_id,a.tel,a.dp_count,a.avg_point,a.supplier_id as brand_id,a.brief,a.preview as logo,a.xpoint,a.ypoint,a.route,a.youhui_count,a.event_count,(select count(*) from " . DB_PREFIX . "supplier_location_dp as dp where dp.supplier_location_id = a.id and dp.status = 1) as comment_count, c.name as city_name,\n\t\t(ACOS(SIN(({$ypoint} * {$pi}) / 180 ) *SIN((a.ypoint * {$pi}) / 180 ) +COS(({$ypoint} * {$pi}) / 180 ) * COS((a.ypoint * {$pi}) / 180 ) *COS(({$xpoint} * {$pi}) / 180 - (a.xpoint * {$pi}) / 180 ) ) * {$r}) as distance\n\t\tfrom " . DB_PREFIX . "supplier_location as a " . " left outer join " . DB_PREFIX . "deal_city as c on c.id = a.city_id " . "where a.id != {$id} and a.supplier_id =" . intval($root['supplier_id']);
     //$root['ss'] = $sql;
     $other_supplier_location = $GLOBALS['db']->getAll($sql);
     if ($other_supplier_location === false) {
         $root['other_supplier_location'] = array();
     } else {
         foreach ($other_supplier_location as $k => $v) {
             $other_supplier_location[$k]['logo'] = get_abs_img_root($v['logo']);
         }
         $root['other_supplier_location'] = $other_supplier_location;
     }
     /*门店团购*/
     $time = get_gmtime();
     $t_where = "where b.location_id=" . $list['id'] . " and a.is_shop=0 and a.is_effect=1 and a.is_delete=0  and ((" . $time . ">= a.begin_time or a.begin_time = 0) and (" . $time . "< a.end_time or a.end_time = 0)) and a.buy_status <> 2";
     $g_where = "where b.location_id=" . $list['id'] . " and a.is_shop=1 and a.is_effect=1 and a.is_delete=0  and ((" . $time . ">= a.begin_time or a.begin_time = 0) and (" . $time . "< a.end_time or a.end_time = 0)) and a.buy_status <> 2";
     $y_where = "where a.is_effect = 1 and b.location_id=" . $list['id'] . " and ((" . $time . ">= a.begin_time or a.begin_time = 0) and (" . $time . "< a.end_time or a.end_time = 0))";
     if ($city_id == 0) {
         require_once APP_ROOT_PATH . "system/model/city.php";
         $city = City::locate_city();
         $city_id = $city['id'];
     }
     if ($city_id > 0) {
         $ids = load_auto_cache("deal_city_belone_ids", array("city_id" => $city_id));
         if ($ids) {
             $t_where .= " and a.city_id in (" . implode(",", $ids) . ")";
             $g_where .= " and a.city_id in (" . implode(",", $ids) . ")";
             $y_where .= " and a.city_id in (" . implode(",", $ids) . ")";
         }
     }
     $tuan_list = $GLOBALS['db']->getAll("select a.brief,a.auto_order,a.id,a.name,a.sub_name,a.origin_price,a.current_price,a.img,a.buy_count,a.discount from " . DB_PREFIX . "deal as a left join " . DB_PREFIX . "deal_location_link as b on b.deal_id=a.id " . $t_where . " order by a.sort desc,a.id desc");
     $tuan_count = $GLOBALS['db']->getOne("select count(a.id) from " . DB_PREFIX . "deal as a left join " . DB_PREFIX . "deal_location_link as b on b.deal_id=a.id " . $t_where . "");
     foreach ($tuan_list as $k => $v) {
         $tuan_list[$k]['origin_price'] = round($v['origin_price'], 2);
         $tuan_list[$k]['current_price'] = round($v['current_price'], 2);
         if ($v['origin_price'] > 0 && floatval($v['discount']) == 0) {
             //手动折扣
             $tuan_list[$k]['save_price'] = round($v['origin_price'] - $v['current_price'], 2);
         } else {
             $tuan_list[$k]['save_price'] = round($v['origin_price'] * ((10 - $v['discount']) / 10), 2);
         }
         if ($v['origin_price'] > 0 && floatval($v['discount']) == 0) {
             $tuan_list[$k]['discount'] = round($v['current_price'] / $v['origin_price'] * 10, 2);
         }
         $tuan_list[$k]['discount'] = round($tuan_list[$k]['discount'], 2);
         $tuan_list[$k]['img'] = get_abs_img_root(get_spec_image($v['img'], 140, 85, 0));
         if (empty($v['brief'])) {
             $tuan_list[$k]['brief'] = $v['name'];
             $tuan_list[$k]['name'] = $v['sub_name'];
         }
     }
     if ($tuan_list === false) {
         $root['tuan_list'] = array();
     } else {
         $root['tuan_list'] = $tuan_list;
     }
     $root['tuan_count'] = $tuan_count;
     /*门店商品*/
     $goods_list = $GLOBALS['db']->getAll("select a.brief,a.id,a.is_hot,a.name,a.sub_name,a.origin_price,a.current_price,a.img,a.buy_count,a.discount from " . DB_PREFIX . "deal as a left join " . DB_PREFIX . "deal_location_link as b on b.deal_id=a.id " . $g_where . " order by a.sort desc,a.id desc");
     foreach ($goods_list as $k => $v) {
         $goods_list[$k]['origin_price'] = round($v['origin_price'], 2);
         $goods_list[$k]['current_price'] = round($v['current_price'], 2);
         if ($v['origin_price'] > 0 && floatval($v['discount']) == 0) {
             //手动折扣
             $goods_list[$k]['save_price'] = round($v['origin_price'] - $v['current_price'], 2);
         } else {
             $goods_list[$k]['save_price'] = round($v['origin_price'] * ((10 - $v['discount']) / 10), 2);
         }
         if ($v['origin_price'] > 0 && floatval($v['discount']) == 0) {
             $goods_list[$k]['discount'] = round($v['current_price'] / $v['origin_price'] * 10, 2);
         }
         $goods_list[$k]['discount'] = round($goods_list[$k]['discount'], 2);
         $goods_list[$k]['img'] = get_abs_img_root(get_spec_image($v['img'], 140, 85, 0));
         if (empty($v['brief'])) {
             $goods_list[$k]['brief'] = $v['name'];
             $goods_list[$k]['name'] = $v['sub_name'];
         }
     }
     if ($goods_list === false) {
         $root['goods_list'] = array();
     } else {
         $root['goods_list'] = $goods_list;
     }
     /*优惠券*/
     $youhui_list = $GLOBALS['db']->getAll("select a.id,a.supplier_id as merchant_id,a.begin_time,a.youhui_type,a.total_num,a.end_time,a.name as title,a.list_brief as content,a.icon as merchant_logo,a.create_time,a.address as api_address,a.view_count,a.print_count,a.sms_count from " . DB_PREFIX . "youhui as a left join " . DB_PREFIX . "youhui_location_link as b on b.youhui_id=a.id " . $y_where . " order by a.sort desc,a.id desc");
     $sql = "select a.id,a.supplier_id as merchant_id,a.begin_time,a.youhui_type,a.total_num,a.end_time,a.name as title,a.list_brief as content,a.icon as merchant_logo,a.create_time,a.address as api_address,a.view_count,a.print_count,a.sms_count from " . DB_PREFIX . "youhui as a left join " . DB_PREFIX . "youhui_location_link as b on b.youhui_id=a.id " . $y_where . " order by a.sort desc,a.id desc";
     $youhui_list = $GLOBALS['db']->getAll($sql);
     foreach ($youhui_list as $k => $v) {
         $youhui_list[$k]['merchant_logo'] = get_abs_img_root(get_spec_image($v['merchant_logo'], 140, 85, 0));
         $youhui_list[$k]['down_count'] = $youhui_list[$k]['sms_count'] + $youhui_list[$k]['print_count'];
         $youhui_list[$k]['begin_time'] = to_date($v['begin_time'], "Y-m-d") . '至' . to_date($v['end_time'], "Y-m-d");
     }
     if ($youhui_list === false) {
         $root['youhui_list'] = array();
     } else {
         $root['youhui_list'] = $youhui_list;
     }
     /*门店评论*/
     // 		$comment_list=$GLOBALS['db']->getAll("select a.id,a.content,a.point,a.avg_price,a.create_time,b.id as user_id,b.user_name from ".DB_PREFIX."supplier_location_dp as a left join ".DB_PREFIX."user as b on b.id=a.user_id where a.supplier_location_id = ".$list['id']." and a.status = 1 limit 10");
     // 		$comment_count=$GLOBALS['db']->getOne("select count(*) from ".DB_PREFIX."supplier_location_dp as a left join ".DB_PREFIX."user as b on b.id=a.user_id where a.supplier_location_id = ".$list['id']." and a.status = 1");
     // 		foreach($comment_list as $k=>$v)
     // 		{
     // 			$comment_list[$k]['avg_price']=round($v['avg_price'],1);
     // 			$comment_list[$k]['time']=pass_date($v['create_time']);
     // 			$comment_list[$k]['width']=$v['avg_point'] > 0 ? ($v['avg_point'] / 5) * 90 : 0;
     // 		}
     // 		if ($comment_list === false){
     // 			$root['comment_list']= array();
     // 		}else{
     // 			$root['comment_list']=$comment_list;
     // 		}
     // 		$root['comment_count']=$comment_count;
     require_once APP_ROOT_PATH . "system/model/review.php";
     require_once APP_ROOT_PATH . "system/model/user.php";
     $message_re = get_dp_list(3, $param = array("deal_id" => 0, "youhui_id" => 0, "event_id" => 0, "location_id" => $list['id'], "tag" => ""), "", "");
     foreach ($message_re['list'] as $k => $v) {
         $message_re['list'][$k]['width'] = $v['point'] / 5 * 100;
         $uinfo = load_user($v['user_id']);
         $message_re['list'][$k]['user_name'] = $uinfo['user_name'];
         foreach ($message_re['list'][$k]['images'] as $kk => $vv) {
             $message_re['list'][$k]['images'][$kk] = get_abs_img_root(get_spec_image($vv, 60, 60, 1));
             $message_re['list'][$k]['oimages'][$kk] = get_abs_img_root($vv);
         }
     }
     $root['message_list'] = $message_re['list'];
     if (count($message_re['list']) > 0) {
         $sql = "select count(*) from " . DB_PREFIX . "supplier_location_dp where  " . $message_re['condition'];
         $message_re['count'] = $GLOBALS['db']->getOne($sql);
     }
     $root['message_count'] = $message_re['count'];
     if ($act_2 == "dz") {
         $sql = "select uid from  " . DB_PREFIX . "supplier_dy where uid = {$user_id} and supplier_id = " . $list['brand_id'];
         if (intval($GLOBALS['db']->getOne($sql) > 0)) {
             //已经设置打折提醒,则取消
             $sql = "delete from " . DB_PREFIX . "supplier_dy where uid = {$user_id} and supplier_id = " . $list['brand_id'];
             $GLOBALS['db']->query($sql);
         } else {
             //没设置,则设置
             $merchant_dy = array('uid' => $user_id, 'supplier_id' => $list['brand_id']);
             $GLOBALS['db']->autoExecute(DB_PREFIX . "supplier_dy", $merchant_dy, 'INSERT');
         }
     }
     $root['is_dy'] = $GLOBALS['db']->getOne("select uid from " . DB_PREFIX . "supplier_dy where uid = {$user_id} and supplier_id = " . $list['brand_id'] . " ");
     $root['return'] = 1;
     $root['user_login_status'] = 1;
     $root['page_title'] = "商家详情";
     output($root);
 }
示例#6
0
 public function index()
 {
     $act_2 = $GLOBALS['request']['act_2'];
     //子操作 空:没子操作; dz:设置打折提醒;sc:(取消)收藏
     $city_name = strim($GLOBALS['request']['city_name']);
     //城市名称
     //print_r($email);
     //print_r($pwd);
     //检查用户,用户密码
     $user = $GLOBALS['user_info'];
     //print_r($user);exit;
     $user_id = intval($user['id']);
     if ($act_2 != '' && $user_id == 0) {
         $root['act_2'] = $act_2;
         $root['user_login_status'] = 0;
         //用户登陆状态:1:成功登陆;0:未成功登陆
         output($root);
     }
     $id = intval($GLOBALS['request']['id']);
     $sql = "update " . DB_PREFIX . "youhui set view_count = view_count + 1 where id = " . $id;
     $GLOBALS['db']->query($sql);
     //sc:(取消)收藏
     if ($act_2 == "sc") {
         $sql = "select uid from  " . DB_PREFIX . "youhui_sc where uid = {$user_id} and youhui_id = {$id}";
         if (intval($GLOBALS['db']->getOne($sql) > 0)) {
             //已经设置打折提醒,则取消
             $sql = "delete from " . DB_PREFIX . "youhui_sc where uid = {$user_id} and youhui_id = {$id}";
             $GLOBALS['db']->query($sql);
         } else {
             //没设置,则设置
             $merchant_youhui_sc = array('uid' => $user_id, 'youhui_id' => $id);
             $GLOBALS['db']->autoExecute(DB_PREFIX . "youhui_sc", $merchant_youhui_sc, 'INSERT');
         }
     }
     $sql = "select a.id, a.supplier_id as merchant_id,a.is_sms, a.name as title, a.icon as merchant_logo,a.create_time,a.xpoint,a.ypoint,a.address as api_address,a.icon as image_1, a.image_3,a.image_3_w,a.image_3_h, a.begin_time,a.end_time, a.description as content,a.use_notice,a.view_count,a.print_count,a.sms_count," . "(select count(*) from " . DB_PREFIX . "youhui_sc as b where b.uid = {$user_id} and b.youhui_id = a.id) as is_sc, " . "(select count(*) from " . DB_PREFIX . "message as c where c.rel_table = 'youhui' and c.rel_id = a.id) as comment_count, " . "(select name from " . DB_PREFIX . "deal_city as d where d.id = a.city_id) as city_name " . " from " . DB_PREFIX . "youhui as a where a.id = {$id} ";
     //file_put_contents(APP_ROOT_PATH. "sjmapi/log/sql_".strftime("%Y%m%d%H%M%S",time()).".txt",$sql);
     //echo $sql; exit;
     $youhui = $GLOBALS['db']->getRow($sql);
     $root = m_youhuiItem($youhui);
     $root['logo'] = get_abs_img_root(get_spec_image($root['logo'], 320, 194, 0));
     $root['down_count'] = $root['sms_count'] + $root['print_count'];
     //$root['merchant_id'] = 0;
     $root['act_2'] = $act_2;
     $root['user_login_status'] = 1;
     //print_r($root);exit;
     //分享信息
     //$site_url = ';网址:'.str_replace($_FANWE['site_root'],'',$_FANWE['site_url']).FU('yh/detail',array('id'=>$youhui['id']));
     //$site_url = get_domain().url("youhui","ydetail",array("id"=>$deal['id']));
     $site_url = get_domain() . url("youhui", "fdetail", array("id" => $youhui['id']));
     $site_url = str_replace('/sjmapi/', '/', $site_url);
     $root['share_content'] = msubstr($youhui['title'], 0, 140 - strlen($site_url) - 3) . $site_url;
     $root['return'] = 1;
     $merchant_id = intval($youhui[merchant_id]);
     if ($merchant_id > 0) {
         if ($act_2 == "dz") {
             $sql = "select uid from  " . DB_PREFIX . "supplier_dy where uid = {$user_id} and supplier_id = {$merchant_id}";
             if (intval($GLOBALS['db']->getOne($sql) > 0)) {
                 //已经设置打折提醒,则取消
                 $sql = "delete from " . DB_PREFIX . "supplier_dy where uid = {$user_id} and supplier_id = {$merchant_id}";
                 $GLOBALS['db']->query($sql);
             } else {
                 //没设置,则设置
                 $merchant_dy = array('uid' => $user_id, 'supplier_id' => $merchant_id);
                 $GLOBALS['db']->autoExecute(DB_PREFIX . "supplier_dy", $merchant_dy, 'INSERT');
             }
         }
         $sql = "select a.id,a.name,a.content as brief,a.preview as logo, b.uid as is_dy from " . DB_PREFIX . "supplier as a " . " left outer join " . DB_PREFIX . "supplier_dy as b on b.uid = {$user_id} and b.supplier_id = a.id " . "where a.id = {$merchant_id} ";
         //echo $sql; exit;
         $merchant = $GLOBALS['db']->getRow($sql);
         $merchant = m_merchantItem($merchant);
         $root['merchant'] = $merchant;
         $ypoint = $m_latitude = doubleval($GLOBALS['request']['m_latitude']);
         //ypoint
         $xpoint = $m_longitude = doubleval($GLOBALS['request']['m_longitude']);
         //xpoint
         $pi = 3.14159265;
         //圆周率
         $r = 6378137;
         //地球平均半径(米)
         /*
         if($GLOBALS['request']['from']=="wap"){
         		//购买评论			
         	$message_re=m_get_message_list(3," m.rel_table = 'deal' and m.rel_id=".$id." and m.is_buy = 1");//购买评论
         	$root['message_list']=$message_re['list']; 
         	$root['message_count']=$message_re['count'];
         	$supplier_location_id=$GLOBALS['db']->getOne("select id from ".DB_PREFIX."supplier_location where supplier_id=".$merchant_id);
         	
         	//门店评论
         	$comment_list=$GLOBALS['db']->getAll("select a.id,a.content,a.point,a.avg_price,a.create_time,b.id as user_id,b.user_name from ".DB_PREFIX."supplier_location_dp as a left join ".DB_PREFIX."user as b on b.id=a.user_id where a.supplier_location_id = ".$supplier_location_id." and a.status = 1");
         	$youhui_count=$GLOBALS['db']->getOne("select count(*) from ".DB_PREFIX."message where rel_table = 'youhui' and rel_id=".$id." and user_id=".$user_id);
         	$comment_count=$GLOBALS['db']->getOne("select count(*) from ".DB_PREFIX."supplier_location_dp as a left join ".DB_PREFIX."user as b on b.id=a.user_id where a.supplier_location_id = ".$supplier_location_id." and a.status = 1");
         	$count_point=0;
         	foreach($comment_list as $k=>$v)
         	{
         		$comment_list[$k]['avg_price']=round($v['avg_price'],2);
         		$comment_list[$k]['time']=pass_date($v['create_time']);
         		$count_point+=$v['point'];
         	}
         	$root['comment_list']=$comment_list;
         	$root['youhui_count']=$youhui_count;
         	$score=round($count_point/$comment_count,2);
         
         	$width = $score > 0 ? ($score / 5) * 100 : 0;
         	$root['point']=$score;
         	$root['width']=$width;
         	$root['comment_count']=$comment_count;
         		//fwb 2014-08-27
         }//fwb add 2014-08-27
         */
         $sql = "select a.id,a.name,a.address,a.api_address, a.tel,a.supplier_id as brand_id,a.brief,a.preview as logo,a.xpoint,a.ypoint,a.route, (select count(*) from " . DB_PREFIX . "message as m where m.rel_table = 'supplier_location' and m.rel_id = a.id) as comment_count,c.name as city_name,\n\t\t\t\t(ACOS(SIN(({$ypoint} * {$pi}) / 180 ) *SIN((a.ypoint * {$pi}) / 180 ) +COS(({$ypoint} * {$pi}) / 180 ) * COS((a.ypoint * {$pi}) / 180 ) *COS(({$xpoint} * {$pi}) / 180 - (a.xpoint * {$pi}) / 180 ) ) * {$r}) as distance \n\t\t\t\t from " . DB_PREFIX . "supplier_location as a " . " left outer join " . DB_PREFIX . "deal_city as c on c.id = a.city_id " . "where a.supplier_id = {$merchant_id} ";
         $list = $GLOBALS['db']->getAll($sql);
         $list_merchant = array();
         foreach ($list as $item) {
             $list_merchant[] = m_merchantItem($item);
         }
         $root['list_merchant'] = $list_merchant;
     }
     require_once APP_ROOT_PATH . "system/model/review.php";
     require_once APP_ROOT_PATH . "system/model/user.php";
     $message_re = get_dp_list(3, $param = array("deal_id" => 0, "youhui_id" => $youhui['id'], "event_id" => 0, "location_id" => 0, "tag" => ""), "", "");
     foreach ($message_re['list'] as $k => $v) {
         $message_re['list'][$k]['width'] = $v['point'] / 5 * 100;
         $uinfo = load_user($v['user_id']);
         $message_re['list'][$k]['user_name'] = $uinfo['user_name'];
         foreach ($message_re['list'][$k]['images'] as $kk => $vv) {
             $message_re['list'][$k]['images'][$kk] = get_abs_img_root(get_spec_image($vv, 60, 60, 1));
             $message_re['list'][$k]['oimages'][$kk] = get_abs_img_root($vv);
         }
     }
     $root['message_list'] = $message_re['list'];
     if (count($message_re['list']) > 0) {
         $sql = "select count(*) from " . DB_PREFIX . "supplier_location_dp where  " . $message_re['condition'];
         $message_re['count'] = $GLOBALS['db']->getOne($sql);
     }
     $root['message_count'] = $message_re['count'];
     $root['city_name'] = $city_name;
     $root['page_title'] = "优惠券详情";
     output($root);
 }
示例#7
0
文件: functions.php 项目: macall/jsd
function m_get_event_reply($event_id, $page)
{
    if ($page == 0) {
        $page = 1;
    }
    $limit = ($page - 1) * PAGE_SIZE . "," . PAGE_SIZE;
    require_once APP_ROOT_PATH . "system/model/review.php";
    //get_dp_list($limit,$param=array("deal_id"=>0,"youhui_id"=>0,"event_id"=>0,"location_id"=>0,"tag"=>""),$where="",$orderby="")
    //$res = get_message_list_shop($limit," rel_table='event' and rel_id = ".$event_id." and is_effect = 1");
    //get_dp_list($limit,$param=array("deal_id"=>0,"youhui_id"=>0,"event_id"=>0,"location_id"=>0,"tag"=>""),$where="",$orderby="")
    $res = get_dp_list($limit, array("deal_id" => 0, "youhui_id" => 0, "event_id" => $event_id, "location_id" => 0, "tag" => ""), "is_effect = 1");
    $list = $res['list'];
    $condition = $res['condition'];
    $sql = "select count(*) from " . DB_PREFIX . "supplier_location_dp where  " . $condition;
    $count = $GLOBALS['db']->getOne($sql);
    $reply_list = array();
    foreach ($list as $k => $v) {
        $reply_list[$k]['content'] = $v['content'];
        $reply_list[$k]['create_time'] = $v['create_time_format'];
        $reply_list[$k]['user_name'] = $GLOBALS['db']->getOne("select user_name from " . DB_PREFIX . "user where id = " . $v['user_id']);
        $reply_list[$k]['user_avatar'] = get_abs_img_root(get_muser_avatar($v['user_id'], "big"));
        $reply_list[$k]['time'] = pass_date($v['create_time_format']);
        $reply_list[$k]['parse_expres'] = get_parse_expres($v['content']);
        $reply_list[$k]['parse_user'] = get_parse_user($v['content']);
        $reply_list[$k]['user_id'] = $v['user_id'];
    }
    $page_info = array("page" => $page, "page_total" => ceil($count / PAGE_SIZE), "page_size" => PAGE_SIZE);
    return array("list" => $reply_list, "page" => $page_info);
}
示例#8
0
 /**
  * 加载点评详细列表
  */
 public function load_review_list()
 {
     $deal_id = intval($_REQUEST['deal_id']);
     $youhui_id = intval($_REQUEST['youhui_id']);
     $event_id = intval($_REQUEST['event_id']);
     $supplier_id = intval($_REQUEST['supplier_id']);
     $location_id = intval($_REQUEST['location_id']);
     $item_array = array("deal_id" => $deal_id, "youhui_id" => $youhui_id, "event_id" => $event_id, "supplier_id" => $supplier_id, "location_id" => $location_id);
     require_once APP_ROOT_PATH . "system/model/review.php";
     require_once APP_ROOT_PATH . "app/Lib/page.php";
     $dp_data = load_dp_info($item_array);
     $GLOBALS['tmpl']->assign("dp_data", $dp_data);
     //排序行
     $sort_field = intval($_REQUEST['sort_field']);
     $sort_type = strim($_REQUEST['sort_type']);
     $filter = intval($_REQUEST['filter']);
     $is_img = intval($_REQUEST['is_img']);
     $is_content = intval($_REQUEST['is_content']);
     $sort_data['sort_field'] = $sort_field;
     $sort_data['sort_type'] = $sort_type;
     $sort_data['filter'] = $filter;
     $sort_data['is_img'] = $is_img;
     $sort_data['is_content'] = $is_content;
     $GLOBALS['tmpl']->assign("sort_data", $sort_data);
     $ext_condition = "";
     if ($filter == 1) {
         $ext_condition = " point >= 4 ";
     } elseif ($filter == 2) {
         $ext_condition = " point >= 2 and point < 4 ";
     } elseif ($filter == 3) {
         $ext_condition = " point < 2 ";
     }
     if ($is_img == 1) {
         if ($ext_condition != "") {
             $ext_condition .= " and ";
         }
         $ext_condition .= "  is_img = 1 ";
     }
     if ($is_content == 1) {
         if ($ext_condition != "") {
             $ext_condition .= " and ";
         }
         $ext_condition .= "  is_content = 1 ";
     }
     //排序
     $orderby = "";
     if ($sort_field > 0) {
         if ($sort_field == 1) {
             if ($sort_type == "asc") {
                 $orderby = " point asc ";
             } else {
                 $orderby = " point desc ";
             }
         } elseif ($sort_field == 2) {
             if ($sort_type == "asc") {
                 $orderby = " point desc ";
             } else {
                 $orderby = " point asc ";
             }
         }
     }
     //tag行
     $tag = strim($_REQUEST['tag']);
     $GLOBALS['tmpl']->assign("filter_tag", $tag);
     $gid = intval($_REQUEST['gid']);
     $GLOBALS['tmpl']->assign("gid", $gid);
     //分页
     $page_size = 5;
     $page = intval($_REQUEST['p']);
     if ($page == 0) {
         $page = 1;
     }
     $limit = ($page - 1) * $page_size . "," . $page_size;
     $list_item_array = $item_array;
     $list_item_array['tag'] = $tag;
     $dp_res = get_dp_list($limit, $list_item_array, $ext_condition, $orderby);
     $dp_list = $dp_res['list'];
     $total = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "supplier_location_dp  where " . $dp_res['condition']);
     $page = new Page($total, $page_size);
     //初始化分页对象
     $p = $page->show();
     $GLOBALS['tmpl']->assign('pages', $p);
     $GLOBALS['tmpl']->assign('dp_list', $dp_list);
     require_once APP_ROOT_PATH . "system/model/topic.php";
     $data['html'] = decode_topic_without_img($GLOBALS['tmpl']->fetch("inc/review_list.html"));
     ajax_return($data);
 }
示例#9
0
 public function index()
 {
     require_once APP_ROOT_PATH . "system/model/user.php";
     if (strim($GLOBALS['request']['act_2']) == 'bm') {
         $root['status'] = 1;
         $city_name = strim($GLOBALS['request']['city_name']);
         //城市名称
         //检查用户,用户密码
         $user_data = $GLOBALS['user_info'];
         //报名
         if ($user_data) {
             $root['user_login_status'] = 1;
             $event_id = intval($GLOBALS['request']['event_id']);
             $user_id = intval($GLOBALS['user_info']['id']);
             require_once APP_ROOT_PATH . "system/model/event.php";
             // 				$event = $GLOBALS['db']->getRow("select * from ".DB_PREFIX."event where id = ".$event_id." and is_effect = 1");
             $event = get_event($event_id);
             if ($event) {
                 if ($event['xpoint'] == '') {
                     $event['xpoint'] = 0;
                 }
                 if ($event['ypoint'] == '') {
                     $event['ypoint'] = 0;
                 }
                 if ($event['submit_begin_time'] > NOW_TIME) {
                     $root['return'] = 0;
                     $root['info'] = "活动未开始";
                 } elseif ($event['submit_end_time'] > 0 && $event['submit_end_time'] < NOW_TIME) {
                     $root['return'] = 0;
                     $root['info'] = "活动报名已结束";
                 } elseif ($event['submit_count'] >= $event['total_count'] && $event['total_count'] > 0) {
                     $root['return'] = 0;
                     $root['info'] = "活动名额已满";
                 } else {
                     //开始提交报名
                     $user_id = intval($GLOBALS['user_info']['id']);
                     $user_submit = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "event_submit where user_id = " . $user_id . " and event_id = " . $event_id);
                     if ($user_submit) {
                         if ($user_submit['is_verify'] == 1) {
                             $root['return'] = 0;
                             $root['info'] = "您已经报过名了";
                         } elseif ($user_submit['is_verify'] == 2) {
                             $root['return'] = 0;
                             $root['info'] = "您的报名审核不通过";
                         } else {
                             //已经报名,仅作修改
                             $bm = $GLOBALS['request']['bm'];
                             $GLOBALS['db']->query("delete from " . DB_PREFIX . "event_submit_field where submit_id = " . $user_submit['id']);
                             foreach ($bm as $field_id => $bm_result) {
                                 $field_data = array();
                                 $field_data['submit_id'] = $user_submit['id'];
                                 $field_data['field_id'] = $field_id;
                                 $field_data['event_id'] = $event_id;
                                 $field_data['result'] = strim($bm_result);
                                 $GLOBALS['db']->autoExecute(DB_PREFIX . "event_submit_field", $field_data, "INSERT");
                             }
                             $root['return'] = 1;
                             $root['info'] = "报名修改成功";
                         }
                     } else {
                         $submit_data = array();
                         $submit_data['user_id'] = $user_id;
                         $submit_data['event_id'] = $event_id;
                         $submit_data['create_time'] = get_gmtime();
                         $GLOBALS['db']->autoExecute(DB_PREFIX . "event_submit", $submit_data, "INSERT");
                         $submit_id = $GLOBALS['db']->insert_id();
                         if ($submit_id) {
                             $bm = $GLOBALS['request']['bm'];
                             //file_put_contents(APP_ROOT_PATH. "sjmapi/log/bm_".strftime("%Y%m%d%H%M%S",time()).".txt",print_r($GLOBALS['request'],true));
                             //$bm = (unserialize($GLOBALS['request']['bm']));
                             foreach ($bm as $field_id => $bm_result) {
                                 $field_data = array();
                                 $field_data['submit_id'] = $submit_id;
                                 $field_data['field_id'] = $field_id;
                                 $field_data['event_id'] = $event_id;
                                 $field_data['result'] = strim($bm_result);
                                 $GLOBALS['db']->autoExecute(DB_PREFIX . "event_submit_field", $field_data, "INSERT");
                             }
                             $GLOBALS['db']->query("update " . DB_PREFIX . "event set submit_count = submit_count+1 where id=" . $event_id);
                             if ($event['is_auto_verify'] == 1) {
                                 //自动审核,发券
                                 $sn = verify_event_submit($submit_id);
                             }
                             //同步分享
                             // 								$title = "报名参加了".$event['name'];
                             // 								$content = "报名参加了".$event['name']." - ".$event['brief'];
                             // 								$url_route = array(
                             // 										'rel_app_index'	=>	'youhui',
                             // 										'rel_route'	=>	'edetail',
                             // 										'rel_param' => 'id='.$event['id']
                             // 								);
                             // 								$tid = insert_topic($content,$title,$type="eventsubmit",$group="", $relay_id = 0, $fav_id = 0,$group_data ="",$attach_list=array(),$url_route);
                             // 								if($tid)
                             // 								{
                             // 									$GLOBALS['db']->query("update ".DB_PREFIX."topic set source_name = '".$GLOBALS['request']['source']."' where id = ".intval($tid));
                             // 								}
                             //同步分享
                             $title = "报名参加了" . $event['name'];
                             $content = "报名参加了" . $event['name'] . " - " . $event['brief'];
                             $url_route = array('rel_app_index' => 'index', 'rel_route' => 'event#' . $event['id'], 'rel_param' => '');
                             require_once APP_ROOT_PATH . "system/model/topic.php";
                             $tid = insert_topic($content, $title, $type = "eventsubmit", $group = "", $relay_id = 0, $fav_id = 0, $group_data = "", $attach_list = array(), $url_route);
                             if ($tid) {
                                 $GLOBALS['db']->query("update " . DB_PREFIX . "topic set source_name = '" . $GLOBALS['request']['source'] . "' where id = " . intval($tid));
                             }
                             require_once APP_ROOT_PATH . "system/model/user.php";
                             modify_account(array("score" => "-" . $event['score_limit']), $user_id, "活动报名:" . $event['name']);
                             $root['return'] = 1;
                             $root['info'] = "报名成功";
                             if ($sn) {
                                 $root['info'] .= " 验证码:" . $sn;
                             } else {
                                 $root['info'] .= " 请等待审核";
                             }
                             rm_auto_cache("event", array("id" => $event['id']));
                         } else {
                             $root['return'] = 0;
                             $root['info'] = "报名失败";
                         }
                     }
                 }
             } else {
                 $root['return'] = 0;
                 $root['info'] = "没有该活动数据";
             }
         } else {
             $root['return'] = 0;
             $root['user_login_status'] = 0;
             $root['info'] = "请先登录";
         }
         output($root);
         //报名
     }
     //报名结束
     $page = intval($GLOBALS['request']['page']);
     //分页,无用
     if ($page == 0) {
         $page = 1;
     }
     $event_id = intval($GLOBALS['request']['event_id']);
     if ($event_id) {
         $user_data = $GLOBALS['user_info'];
         require_once APP_ROOT_PATH . "system/model/event.php";
         $event = get_event($event_id);
         if ($event['xpoint'] == '') {
             $event['xpoint'] = 0;
         }
         if ($event['ypoint'] == '') {
             $event['ypoint'] = 0;
         }
         $pattern = "/<img([^>]*)\\/>/i";
         $replacement = "<img width=300 \$1 />";
         $event['icon'] = get_abs_img_root($event['icon']);
         $pattern = "/<[img|IMG].*?src=[\\'|\"](.*?(?:[\\.gif|\\.jpg|\\.png]))[\\'|\"].*?[\\/]?>/i";
         //$replacement = "<img width=300 $1 />";
         $replacement = "<img src='\$1' width='278' />";
         $event['content'] = get_abs_img_root(preg_replace($pattern, $replacement, $event['content']));
         //$event['content'] = get_abs_img_root(get_spec_image($event['content'], 278,168,1));
         $event['content'] = preg_replace($pattern, $replacement, $event['content']);
         $event['event_begin_time'] = to_date($event['event_begin_time'], 'Y-m-d');
         $event['event_end_time'] = to_date($event['event_end_time'], 'Y-m-d');
         //验证是否报名
         //$is_submit = $GLOBALS['db']->getOne("select count(*) from ".DB_PREFIX."event_submit where user_id = ".intval($GLOBALS['user_info']['id'])." and event_id = ".$event['id']);
         // 			$event_fields = $GLOBALS['db']->getAll("select * from ".DB_PREFIX."event_field where event_id = ".$event_id." order by sort asc");
         // 			foreach($event_fields as $k=>$v)
         // 			{
         // 				$event_fields[$k]['value_scope'] = explode(" ",$v['value_scope']);
         // 			}
         // 			$event['field_list'] = $event_fields;
         // 			$event['is_submit'] = $is_submit;
         // 			$event['field_list_json']=json_encode($event_fields);
         $user_submit = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "event_submit where user_id = " . $user_data['id'] . " and event_id = " . $event_id);
         if ($user_submit) {
             if ($user_submit['is_verify'] == 1) {
                 $event['is_submit'] = 1;
                 //已报名
                 $event['is_verify'] = 1;
                 //已审核
             } elseif ($user_submit['is_verify'] == 2) {
                 $event['is_submit'] = 1;
                 //已报名
                 $event['is_verify'] = 2;
                 //审核失败
             } else {
                 //未审核
                 $event_fields = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "event_field where event_id = " . $event_id . " order by sort asc");
                 foreach ($event_fields as $k => $v) {
                     $event_fields[$k]['result'] = $GLOBALS['db']->getOne("select result from " . DB_PREFIX . "event_submit_field where submit_id = " . $user_submit['id'] . " and field_id = " . $v['id'] . " and event_id = " . $event_id);
                     $event_fields[$k]['value_scope'] = explode(" ", $v['value_scope']);
                 }
                 $event['event_fields'] = $event_fields;
                 $event['is_submit'] = 1;
                 //已报名
                 $event['is_verify'] = 0;
                 //未审核
                 // 					$GLOBALS['tmpl']->assign("event_fields",$event_fields);
                 // 					$GLOBALS['tmpl']->assign("user_submit",$user_submit);  //表示修改已报名记录
                 // 					$GLOBALS['tmpl']->assign("btn_name","修改报名");
             }
         } else {
             $event_fields = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "event_field where event_id = " . $event_id . " order by sort asc");
             foreach ($event_fields as $k => $v) {
                 $event_fields[$k]['value_scope'] = explode(" ", $v['value_scope']);
             }
             $event['event_fields'] = $event_fields;
             $event['is_submit'] = 0;
             //已报名
         }
     }
     //$res = m_get_event_reply($event_id,$page);
     //$event['comments'] =  $res['list'];
     //$root['page'] = $res['page'];
     require_once APP_ROOT_PATH . "system/model/review.php";
     require_once APP_ROOT_PATH . "system/model/user.php";
     $message_re = get_dp_list(3, $param = array("deal_id" => 0, "youhui_id" => 0, "event_id" => $event_id, "location_id" => 0, "tag" => ""), "", "");
     foreach ($message_re['list'] as $k => $v) {
         $message_re['list'][$k]['width'] = $v['point'] / 5 * 100;
         $uinfo = load_user($v['user_id']);
         $message_re['list'][$k]['user_name'] = $uinfo['user_name'];
         foreach ($message_re['list'][$k]['images'] as $kk => $vv) {
             $message_re['list'][$k]['images'][$kk] = get_abs_img_root(get_spec_image($vv, 60, 60, 1));
             $message_re['list'][$k]['oimages'][$kk] = get_abs_img_root($vv);
         }
     }
     $root['message_list'] = $message_re['list'];
     if (count($message_re['list']) > 0) {
         $sql = "select count(*) from " . DB_PREFIX . "supplier_location_dp where  " . $message_re['condition'];
         $message_re['count'] = $GLOBALS['db']->getOne($sql);
     }
     $root['message_count'] = $message_re['count'];
     $root['return'] = 1;
     $root['item'] = $event;
     $root['page_title'] = "活动详情";
     $root['city_name'] = $city_name;
     output($root);
 }