public function index()
 {
     $root = array();
     $root['response_code'] = 1;
     $id = intval($_REQUEST['id']);
     $email = strim($GLOBALS['request']['email']);
     // 用户名或邮箱
     $pwd = strim($GLOBALS['request']['pwd']);
     // 密码		                                               // 检查用户,用户密码
     $user = user_check($email, $pwd);
     $user_id = intval($user['id']);
     $deal_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where id = " . $id . " and is_delete = 0 and (is_effect = 1 or (is_effect = 0 and user_id = " . $user_id . "))");
     $deal_info = cache_deal_extra($deal_info);
     $page_size = $GLOBALS['m_config']['page_size'];
     $page = intval($_REQUEST['p']);
     if ($page == 0) {
         $page = 1;
     }
     $limit = ($page - 1) * $page_size . "," . $page_size;
     $support_list = $GLOBALS['db']->getAll("select user_id,price from " . DB_PREFIX . "deal_support_log where deal_id = " . $id . " order by create_time desc limit " . $limit);
     $support_count = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_support_log where deal_id = " . $id);
     $user_list = array();
     $user_ids = array();
     foreach ($support_list as $k => $v) {
         if ($v['user_id']) {
             $user_ids[] = $v['user_id'];
         }
     }
     $user_ids = array_filter($user_ids);
     if ($user_ids) {
         $user_id_str = implode(',', array_filter($user_ids));
         $user_list_array = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "user where id in (" . $user_id_str . ") ");
         foreach ($user_list_array as $k => $v) {
             foreach ($support_list as $k_support => $v_support) {
                 if ($v['id'] == $v_support['user_id']) {
                     $support_list[$k_support]['user_info'] = $v;
                     $support_list[$k_support]['user_info']["image"] = get_user_avatar_root($v["id"], "middle");
                     $support_list[$k_support]['user_info']["url"] = url_root("home", array("id" => $v["user_id"]));
                 }
             }
         }
     }
     $root['support_list'] = $support_list;
     // -----------------------------------
     $virtual_person = $GLOBALS['db']->getOne("select sum(virtual_person) from " . DB_PREFIX . "deal_item where deal_id=" . $id);
     // 获得该项目下的子项目的所有信息
     // $deal_item_list=$GLOBALS['db']->getAll("select * from
     // ".DB_PREFIX."deal_item where deal_id=".$id);
     $deal_item_list = $deal_info['deal_item_list'];
     foreach ($deal_item_list as $k => $v) {
         // 统计每个子项目真实+虚拟(人)
         $deal_item_list[$k]['virtual_person'] = $v['virtual_person'] + $v['support_count'];
         // 统计所有真实+虚拟(钱)
         $deal_item_list[$k]['virtual_price'] = $v['price'] * $deal_item_list[$k]['virtual_person'];
         // 支付该项花费的金额
         $deal_item_list[$k]['total_price'] = $v['price'] + $v['delivery_fee'];
         $deal_item_list[$k]['delivery_fee_format'] = number_price_format($v['delivery_fee']);
         $deal_item_list[$k]['content'] = $v['description'];
         foreach ($deal_item_list[$k]['images'] as $kk => $vv) {
             $deal_item_list[$k]['images'][$kk]['image'] = get_abs_img_root(get_spec_image($vv['image'], 640, 240, 1));
         }
     }
     $root['deal_item_list'] = $deal_item_list;
     $root['person'] = $virtual_person + $deal_info['support_count'];
     // -----------------------------------
     if ($deal_info['user_id'] > 0) {
         $deal_user_info = $GLOBALS['db']->getRow("select id,user_name,province,city,intro,login_time from " . DB_PREFIX . "user where id = " . $deal_info['user_id'] . " and is_effect = 1");
         if ($deal_user_info == false) {
             $deal_user_info = NULL;
         }
         $root['deal_user_info'] = $deal_user_info;
     }
     // $root['support_list'] = $support_list;
     $root['page'] = array("page" => $page, "page_total" => ceil($support_count / $page_size), "page_size" => intval($page_size), 'total' => intval($support_count));
     output($root);
 }
 public function index()
 {
     require_once APP_ROOT_PATH . "system/libs/user.php";
     $root = array();
     $page = intval($GLOBALS['request']['page']);
     if ($page == 0) {
         $page = 1;
     }
     $uid = intval($GLOBALS['request']['uid']);
     $user_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where id = " . $uid . " and is_effect = 1 and is_delete = 0");
     if (!$user_info) {
         $root['info'] = "非法的会员";
         output($root);
     }
     $limit = ($page - 1) * PAGE_SIZE . "," . PAGE_SIZE;
     $image_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "topic_image where user_id = " . $user_info['id'] . " and topic_id > 0 order by create_time desc limit " . $limit);
     $image_total = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "topic_image where user_id = " . $user_info['id'] . " and topic_id > 0  ");
     $images = array();
     foreach ($image_list as $k => $v) {
         $images[$k]['photo_id'] = $v['id'];
         $images[$k]['share_id'] = $v['topic_id'];
         $images[$k]['img'] = get_abs_img_root(get_spec_image($v['o_path'], 200, 0, 0));
         $images[$k]['height'] = floor($v['height'] * (200 / $v['width']));
     }
     $root['page'] = array("page" => $page, "page_total" => ceil($image_total / PAGE_SIZE));
     $root['item'] = $images;
     $root['return'] = 1;
     output($root);
 }
 public function index()
 {
     require_once APP_ROOT_PATH . 'app/Lib/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
     $item = get_deal($id);
     $root = getGoodsArray($item);
     $root['return'] = 1;
     $root['attr'] = getAttrArray($id);
     $images = array();
     //image_attr_1_id_{$attr_1_id} 图片列表,可以根据属性ID值,来切换图片列表
     $sql = "select img from " . DB_PREFIX . "deal_gallery where deal_id = " . intval($id);
     $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'], 320, 320, 0));
         $big_gallery[] = get_abs_img_root(get_spec_image($image['img'], 0, 0, 0));
     }
     $root['gallery'] = $gallery;
     $root['big_gallery'] = $big_gallery;
     output($root);
 }
Example #4
0
 public function index()
 {
     $root = array();
     $root['response_code'] = 1;
     $root['kf_phone'] = $GLOBALS['m_config']['kf_phone'];
     //客服电话
     $root['kf_email'] = $GLOBALS['m_config']['kf_email'];
     //客服邮箱
     //关于我们(填文章ID)
     $root['about_info'] = intval($GLOBALS['m_config']['about_info']);
     $root['version'] = VERSION;
     //接口版本号int
     $root['page_size'] = PAGE_SIZE;
     //默认分页大小
     $root['program_title'] = $GLOBALS['m_config']['program_title'];
     $root['site_domain'] = str_replace("/mapi", "", SITE_DOMAIN . APP_ROOT);
     //站点域名;
     $root['site_domain'] = str_replace("http://", "", $root['site_domain']);
     //站点域名;
     $root['site_domain'] = str_replace("https://", "", $root['site_domain']);
     //站点域名;
     /*虚拟的累计项目总个数,支持总人数,项目支持总金额*/
     $virtual_effect = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal where is_effect = 1 and is_delete=0");
     $virtual_person = $GLOBALS['db']->getOne("select sum((support_count+virtual_person)) from " . DB_PREFIX . "deal_item");
     $virtual_money = $GLOBALS['db']->getOne("select sum((support_count+virtual_person)*price) from " . DB_PREFIX . "deal_item");
     $root['virtual_effect'] = $virtual_effect;
     //项目总个数
     $root['virtual_person'] = $virtual_person;
     //累计支持人
     $root['virtual_money'] = number_format($virtual_money, 2);
     //筹资总金额
     /*虚拟的累计项目总个数,支持总人数,项目支持总金额 结束*/
     /*取6个推荐项目*/
     $index_list = $GLOBALS['db']->getAll(" select * from " . DB_PREFIX . "deal where is_effect=1 and is_recommend=1 order by sort desc limit 0,6");
     $deal_list = array();
     $time = time();
     foreach ($index_list as $k => $v) {
         if ($v['image'] != '') {
             $v['image'] = get_abs_img_root_wap(get_spec_image($v['image'], 900, 480, 1));
         }
         if ($v['start_time'] > $time) {
             $tmp_start_day = ceil(($v['start_time'] - $time) / 86400);
             $v['show'] = "还有" . $tmp_start_day . "天开始";
         } elseif ($time > $v['end_time']) {
             $v['show'] = "已过期";
         } else {
             $tmp_end_day = ceil(($v['end_time'] - $time) / 86400);
             $v['show'] = "剩余" . $tmp_end_day . "天";
         }
         $deal_list[] = $v;
     }
     $GLOBALS['tmpl']->assign('deal_list', $deal_list);
     /*取3个专题*/
     $topic_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "zhuanti where state=1 order by sort desc limit 0,3");
     //获取所有分类
     $cates = getCateList();
     $GLOBALS['tmpl']->assign('topic_list', $topic_list);
     $GLOBALS['tmpl']->assign('cates', $cates);
     $GLOBALS['tmpl']->display("index.html");
 }
Example #5
0
 public function index()
 {
     $page = intval($GLOBALS['request']['page']);
     //分页
     $page = $page == 0 ? 1 : $page;
     $cate_id = intval($GLOBALS['request']['cate_id']);
     $city_id = intval($GLOBALS['request']['city_id']);
     $page_size = PAGE_SIZE;
     $limit = ($page - 1) * $page_size . "," . $page_size;
     /*输出分类*/
     $bigcate_list = $GLOBALS['db']->getAll("select id,name from " . DB_PREFIX . "topic_group_cate where is_effect=1 order by sort asc");
     if ($cate_id > 0) {
         $cate_condition = " and cate_id = " . $cate_id;
     }
     $sql = " select * from " . DB_PREFIX . "topic_group where is_effect = 1 {$cate_condition} order by sort desc limit " . $limit;
     $sql_count = "select count(*) from " . DB_PREFIX . "topic_group where is_effect = 1 {$cate_condition} ";
     $list = $GLOBALS['db']->getAll($sql);
     $count = $GLOBALS['db']->getOne($sql_count);
     foreach ($list as $k => $v) {
         $list[$k]['icon'] = get_abs_img_root(get_spec_image($v['icon'], 300, 181, 0));
     }
     $page_total = ceil($count / $page_size);
     $root = array();
     $root['bigcate_list'] = $bigcate_list;
     $root['return'] = 1;
     $root['email'] = $email;
     $root['f_link_data'] = get_link_list();
     $root['item'] = $list;
     $root['page'] = array("page" => $page, "page_total" => ceil($res['count'] / $page_size), "page_size" => $page_size);
     $root['page_title'] = "小组";
     output($root);
 }
Example #6
0
 public function biz_register()
 {
     global_run();
     $msg = $this->upload("biz_register", true);
     $msg['origin_img'] = $msg['url'];
     $msg['url'] = get_spec_image($msg['url'], 88, 75, 1);
     $msg['url_path'] = $msg['url'];
     ajax_return($msg);
 }
Example #7
0
/**
 * 按宽度格式化html内容中的图片
 * @param unknown_type $content
 * @param unknown_type $width
 * @param unknown_type $height
 */
function format_html_content_image($content, $width, $height = 0)
{
    $res = preg_match_all("/<img.*?src=[\"|\\']([^\"|\\']*)[\"|\\'][^>]*>/i", $content, $matches);
    if ($res) {
        foreach ($matches[0] as $k => $match) {
            $old_path = $matches[1][$k];
            if (preg_match("/\\.\\/public\\//i", $old_path)) {
                $new_path = get_spec_image($matches[1][$k], $width, $height, 0);
                $content = str_replace($match, "<img src='" . $new_path . "' lazy='true' />", $content);
            }
        }
    }
    return $content;
}
 public function index()
 {
     $city_name = strim($GLOBALS['request']['city_name']);
     //城市名称
     $root = array();
     $root['page_title'] = '投诉列表';
     $root['mana_page_title'] = '投诉列表';
     //检查用户,用户密码
     $user = $GLOBALS['user_info'];
     $user_id = intval($user['id']);
     //经理id
     $root['return'] = 1;
     if ($user_id > 0) {
         $root['user_login_status'] = 1;
         //配置分页参数
         require_once APP_ROOT_PATH . "wap/lib/page.php";
         $page_size = 10;
         $page = intval($GLOBALS['request']['page']);
         if ($page == 0) {
             $page = 1;
         }
         $limit = ($page - 1) * $page_size . "," . $page_size;
         $sql = "SELECT\n                        doc.`id` AS complain_id,\n                        doi.`number`,\n                        doc.`create_time`,\n                        d.`id` AS deal_id,\n                        d.`current_price` AS price,\n                        d.`sub_name` AS service_name,\n                        d.`img` AS service_icon,\n                        do.`create_time` AS order_create_time \n                      FROM\n                        " . DB_PREFIX . "deal_order_complain doc \n                        LEFT JOIN " . DB_PREFIX . "deal_order DO \n                          ON doc.`order_id` = do.`id` \n                        LEFT JOIN " . DB_PREFIX . "deal_order_item doi \n                          ON do.`id` = doi.`order_id` \n                        LEFT JOIN " . DB_PREFIX . "deal d \n                          ON doi.`deal_id`=d.`id` \n                      WHERE do.`type` = 0 \n                        AND doc.`tech_id` IN \n                        (SELECT \n                          id \n                        FROM\n                          " . DB_PREFIX . "user fu \n                        WHERE fu.`p_id` = " . $user_id . " \n                          AND fu.`service_type_id` = 2 \n                          AND fu.`is_delete` = 0) GROUP BY doc.`id` ORDER BY doc.`create_time` DESC limit " . $limit;
         $sql_count = "SELECT \n                        count(*) \n                      FROM\n                        " . DB_PREFIX . "deal_order_complain doc \n                        LEFT JOIN " . DB_PREFIX . "deal_order DO \n                          ON doc.`order_id` = do.`id` \n                        LEFT JOIN " . DB_PREFIX . "deal_order_item doi \n                          ON do.`id` = doi.`order_id` \n                        LEFT JOIN " . DB_PREFIX . "deal d \n                          ON doi.`deal_id`=d.`id` \n                      WHERE do.`type` = 0 \n                        AND doc.`tech_id` IN \n                        (SELECT \n                          id \n                        FROM\n                          " . DB_PREFIX . "user fu \n                        WHERE fu.`p_id` = " . $user_id . " \n                          AND fu.`service_type_id` = 2 \n                          AND fu.`is_delete` = 0) GROUP BY doc.`id` ";
         $complain_list = $GLOBALS['db']->getAll($sql);
         foreach ($complain_list as $key => $value) {
             $value['total_price'] = format_price($value['price'] * $value['number']);
             $value['price'] = format_price($value['price']);
             $value['service_icon'] = get_abs_img_root(get_spec_image($value['service_icon'], 360, 288, 0));
             $value['order_create_time'] = date('Y-m-d H:i', $value['order_create_time']);
             $value['complain_time'] = date('Y-m-d H:i', $value['complain_time']);
             $complain_list[$key] = $value;
         }
         //配置分页
         $count = $GLOBALS['db']->getOne($sql_count);
         $page_total = ceil($count / $page_size);
         $root['page'] = array("page" => $page, "page_total" => $page_total, "page_size" => $page_size);
         $root['complain_list'] = $complain_list;
     } else {
         $root['user_login_status'] = 0;
     }
     $root['user'] = $user;
     $root['city_name'] = $city_name;
     output($root);
 }
 public function index()
 {
     $city_name = strim($GLOBALS['request']['city_name']);
     //城市名称
     $root = array();
     $root['page_title'] = '订单列表';
     $root['mana_page_title'] = '订单列表';
     //检查用户
     $user = $GLOBALS['user_info'];
     $user_id = intval($user['id']);
     $root['return'] = 1;
     if ($user_id > 0) {
         $root['user_login_status'] = 1;
         //配置分页参数
         require_once APP_ROOT_PATH . "wap/lib/page.php";
         $page_size = 10;
         $page = intval($GLOBALS['request']['page']);
         if ($page == 0) {
             $page = 1;
         }
         $limit = ($page - 1) * $page_size . "," . $page_size;
         $sql = "SELECT \n                    d.`sub_name` AS deal_name,\n                    d.`current_price` AS deal_price,\n                    d.`id` AS deal_id,\n                    d.`icon`,\n                    o.`id` AS order_id,\n                    o.`total_price`,\n                    o.`create_time`,\n                    o.`is_get_bonus`,\n                    doi.`number` \n                  FROM\n                    " . DB_PREFIX . "deal_order o \n                    LEFT JOIN " . DB_PREFIX . "deal d \n                      ON o.`deal_ids` = d.`id` \n                    LEFT JOIN " . DB_PREFIX . "deal_order_item doi \n                      ON o.`id` = doi.`order_id` \n                  WHERE TYPE = 0 \n                    AND technician_id IN \n                    (SELECT \n                      id \n                    FROM\n                      " . DB_PREFIX . "user \n                    WHERE p_id = " . $user_id . " \n                      AND service_type_id = 2 \n                      AND is_delete = 0 \n                      AND is_effect = 1) ORDER BY o.`create_time` DESC limit " . $limit;
         $sql_count = "SELECT count(o.`id`) \n                  FROM\n                    " . DB_PREFIX . "deal_order o \n                    LEFT JOIN " . DB_PREFIX . "deal d \n                      ON o.`deal_ids` = d.`id` \n                    LEFT JOIN " . DB_PREFIX . "deal_order_item doi \n                      ON o.`id` = doi.`order_id` \n                  WHERE TYPE = 0 \n                    AND technician_id IN \n                    (SELECT \n                      id \n                    FROM\n                      " . DB_PREFIX . "user \n                    WHERE p_id = " . $user_id . " \n                      AND service_type_id = 2 \n                      AND is_delete = 0 \n                      AND is_effect = 1)";
         $order_list = $GLOBALS['db']->getAll($sql);
         foreach ($order_list as $key => $value) {
             $value['mana_fee'] = format_price($value['total_price'] * $user['manager_commission_fee_percent'] * 0.01);
             $value['deal_price'] = format_price($value['deal_price']);
             $value['total_price'] = format_price($value['total_price']);
             $value['create_time'] = date('Y-m-d H:i', $value['create_time']);
             $value['icon'] = get_abs_img_root(get_spec_image($value['icon'], 360, 288, 0));
             $order_list[$key] = $value;
         }
         //配置分页
         $count = $GLOBALS['db']->getOne($sql_count);
         $page_total = ceil($count / $page_size);
         $root['page'] = array("page" => $page, "page_total" => $page_total, "page_size" => $page_size);
         $root['order_list'] = $order_list;
     } else {
         $root['user_login_status'] = 0;
     }
     $root['user'] = $user;
     $root['city_name'] = $city_name;
     output($root);
 }
Example #10
0
 public function index()
 {
     $root = array();
     $root['return'] = 1;
     $cate_list = $GLOBALS['cache']->get("MOBILE_SHARECATE_CATELIST");
     if ($cate_list === false) {
         //取出标签分类
         $cate_list_data = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "topic_tag_cate where showin_mobile = 1 order by sort desc");
         $cate_list = array();
         foreach ($cate_list_data as $k => $v) {
             $cate_list[$k]['cate_id'] = $v['id'];
             $cate_list[$k]['cate_name'] = $v['name'];
             $cate_list[$k]['desc'] = $v['sub_name'] == '' ? $v['name'] : $v['sub_name'];
             $cate_list[$k]['share_count'] = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "topic as t left join " . DB_PREFIX . "topic_cate_link as l on l.topic_id = t.id where l.cate_id =" . $v['id']);
             //查询分类下的分享
             $img_tags_data = $GLOBALS['db']->getAll("select t.* from " . DB_PREFIX . "topic as t left join " . DB_PREFIX . "topic_cate_link as l on l.topic_id = t.id where l.cate_id =" . $v['id'] . " and is_recommend = 1 and has_image = 1 order by t.create_time desc limit 5");
             $img_tags = array();
             foreach ($img_tags_data as $kk => $vv) {
                 $img_tags[$kk]['share_id'] = $vv['id'];
                 $topic_tags = explode(" ", $vv['tags']);
                 $img_tags[$kk]['tag_name'] = trim($topic_tags[0]);
                 $image = $GLOBALS['db']->getOne("select o_path from " . DB_PREFIX . "topic_image where topic_id = " . $vv['id'] . " limit 1");
                 if ($kk == 0) {
                     $img_tags[$kk]['img'] = get_abs_img_root(get_spec_image($image, 320, 320, 1));
                 } else {
                     $img_tags[$kk]['img'] = get_abs_img_root(get_spec_image($image, 160, 160, 1));
                 }
             }
             $cate_list[$k]['img_tags'] = $img_tags;
             //查询分类下的标签
             $txt_tags_data = $GLOBALS['db']->getAll("select t.* from " . DB_PREFIX . "topic_tag as t left join " . DB_PREFIX . "topic_tag_cate_link as l on l.tag_id = t.id where l.cate_id =" . $v['id'] . " order by t.sort desc limit 11");
             $txt_tags = array();
             foreach ($txt_tags_data as $kk => $vv) {
                 $txt_tags[$kk]['tag_name'] = $vv['name'];
                 $txt_tags[$kk]['color'] = $vv['color'];
             }
             $cate_list[$k]['txt_tags'] = $txt_tags;
         }
         $GLOBALS['cache']->set("MOBILE_SHARECATE_CATELIST", $cate_list, CACHE_TIME);
     }
     $root['item'] = $cate_list;
     output($root);
 }
Example #11
0
 public function index()
 {
     require_once APP_ROOT_PATH . "system/libs/user.php";
     $uid = intval($GLOBALS['request']['uid']);
     if ($uid == 0) {
         $email = strim($GLOBALS['request']['email']);
         $pwd = strim($GLOBALS['request']['pwd']);
         $result = do_login_user($email, $pwd);
         $user_data = es_session::get('user_info');
         $user_data['id'] = intval($user_data['id']);
         $uid = $user_data['id'];
     }
     $page = intval($GLOBALS['request']['page']);
     if ($page == 0) {
         $page = 1;
     }
     $page_size = 20;
     $limit = ($page - 1) * $page_size . "," . $page_size;
     $root = array();
     $root['return'] = 1;
     $condition = " 1 = 1 ";
     $sort = "";
     $condition .= " and user_id = " . $uid . " and fav_id <> 0 ";
     $sort .= " order by  t.create_time desc  ";
     $sql = "select t.id,t.fav_id,t.origin_id from " . DB_PREFIX . "topic as t  where " . $condition . $sort . " limit " . $limit;
     $sql_total = "select count(*) from " . DB_PREFIX . "topic as t where " . $condition;
     $total = $GLOBALS['db']->getOne($sql_total);
     $result = $GLOBALS['db']->getAll($sql);
     $share_list = array();
     foreach ($result as $k => $v) {
         $share_list[$k]['share_id'] = $v['fav_id'];
         $image = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "topic_image where topic_id = " . $v['origin_id'] . " limit 1");
         $share_list[$k]['img'] = get_abs_img_root(get_spec_image($image['o_path'], 200, 0, 0));
         $share_list[$k]['height'] = floor($image['height'] * (200 / $image['width']));
     }
     $root['item'] = $share_list;
     //分页
     $page_info['page'] = $page;
     $page_info['page_total'] = ceil($total / $page_size);
     $root['page'] = $page_info;
     output($root);
 }
 public function index()
 {
     $city_name = strim($GLOBALS['request']['city_name']);
     //城市名称
     $root = array();
     $root['page_title'] = '退款列表';
     //检查用户,用户密码
     $user = $GLOBALS['user_info'];
     $user_id = intval($user['id']);
     //经理id
     $root['return'] = 1;
     if ($user_id > 0) {
         $root['user_login_status'] = 1;
         //配置分页参数
         require_once APP_ROOT_PATH . "wap/lib/page.php";
         $page_size = 10;
         $page = intval($GLOBALS['request']['page']);
         if ($page == 0) {
             $page = 1;
         }
         $limit = ($page - 1) * $page_size . "," . $page_size;
         $sql = "SELECT \n                        d.`sub_name` AS service_name,\n                        d.`icon` AS service_icon,\n                        d.`id` AS deal_id,\n                        do.`order_sn`,\n                        do.`create_time`,\n                        do.`refund_status`,\n                        do.`id` AS order_id \n                      FROM\n                        " . DB_PREFIX . "deal_order DO \n                        LEFT JOIN " . DB_PREFIX . "deal_order_item doi \n                          ON do.`id` = doi.`order_id` \n                        LEFT JOIN " . DB_PREFIX . "deal d \n                          ON doi.`deal_id` = d.`id` \n                      WHERE do.`pay_status` = 2 \n                        AND do.`user_id` = " . $user_id . " \n                      GROUP BY do.`id` \n                      ORDER BY do.`create_time` limit " . $limit;
         $sql_count = "SELECT \n                        count(*) \n                      FROM\n                        " . DB_PREFIX . "deal_order DO \n                        LEFT JOIN " . DB_PREFIX . "deal_order_item doi \n                          ON do.`id` = doi.`order_id` \n                        LEFT JOIN " . DB_PREFIX . "deal d \n                          ON doi.`deal_id` = d.`id` \n                      WHERE do.`pay_status` = 2 \n                        AND do.`user_id` = " . $user_id . " \n                      GROUP BY do.`id` ";
         $refund_list = $GLOBALS['db']->getAll($sql);
         foreach ($refund_list as $key => $value) {
             $value['service_icon'] = get_abs_img_root(get_spec_image($value['service_icon'], 360, 288, 0));
             $value['create_time'] = date('Y-m-d H:i:s', $value['create_time']);
             $refund_list[$key] = $value;
         }
         //配置分页
         $count = $GLOBALS['db']->getOne($sql_count);
         $page_total = ceil($count / $page_size);
         $root['page'] = array("page" => $page, "page_total" => $page_total, "page_size" => $page_size);
         $root['refund_list'] = $refund_list;
     } else {
         $root['user_login_status'] = 0;
     }
     $root['user'] = $user;
     $root['city_name'] = $city_name;
     output($root);
 }
Example #13
0
/**
 * $user_level_id 会员等级id
 * $is_cut 是否要裁切 默认不裁切
 * $width 图片宽度
 * $height 图片高度
 * $width,$height 都不传输入或都为零,默认是16px*17px
 * */
function get_user_lever_icon($user_level_id, $is_cut = false, $width = 0, $height = 0)
{
    $width = intval($width);
    $height = intval($height);
    $user_level = load_auto_cache("user_level");
    $user_level_icon = $user_level[$user_level_id]['icon'];
    if ($is_cut) {
        if ($width <= 0 && $height <= 0) {
            return get_spec_image($user_level_icon, 16, 17);
        } else {
            return get_spec_image($user_level_icon, $width, $height);
        }
    } else {
        return $user_level_icon;
    }
}
Example #14
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);
 }
Example #15
0
 public function index()
 {
     $page = intval($GLOBALS['request']['page']);
     if ($page == 0) {
         $page = 1;
     }
     $cate_id = intval($GLOBALS['request']['cate_id']);
     $city_id = intval($GLOBALS['request']['city_id']);
     $city_name = strim($GLOBALS['request']['city_name']);
     //城市名称
     $ytop = $latitude_top = floatval($GLOBALS['request']['latitude_top']);
     //最上边纬线值 ypoint
     $ybottom = $latitude_bottom = floatval($GLOBALS['request']['latitude_bottom']);
     //最下边纬线值 ypoint
     $xleft = $longitude_left = floatval($GLOBALS['request']['longitude_left']);
     //最左边经度值  xpoint
     $xright = $longitude_right = floatval($GLOBALS['request']['longitude_right']);
     //最右边经度值 xpoint
     $ypoint = $m_latitude = doubleval($GLOBALS['request']['m_latitude']);
     //ypoint
     $xpoint = $m_longitude = doubleval($GLOBALS['request']['m_longitude']);
     //xpoint
     if ($GLOBALS['request']['from'] == "wap") {
         /*输出分类*/
         $bigcate_list = $GLOBALS['db']->getAll("select id,name from " . DB_PREFIX . "event_cate where is_effect=1 order by sort");
         /*输出商圈*/
         $all_quan_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "area where city_id=" . $city_id . "");
         $quan_list = array();
         $quan_sub_list = array();
         $quan_list[0]['id'] = 0;
         $quan_list[0]['name'] = '全城';
         $quan_list[0]['quan_sub'][0]['id'] = 0;
         $quan_list[0]['quan_sub'][0]['pid'] = 0;
         $quan_list[0]['quan_sub'][0]['name'] = '全城';
         foreach ($all_quan_list as $k => $v) {
             if ($v['pid'] == 0) {
                 $quan_list[] = $v;
             }
             if ($v['pid'] > 0) {
                 $quan_sub_list[$v['pid']][] = $v;
             }
         }
         foreach ($quan_list as $k => $v) {
             if ($v['name'] != "全城") {
                 if ($quan_sub_list[$v['id']] == null || $quan_sub_list[$v['id']] == '') {
                     $quan_list[$k]['quan_sub'] = array();
                 } else {
                     $quan_list[$k]['quan_sub'] = $quan_sub_list[$v['id']];
                 }
             }
         }
         $root[quan_list] = $quan_list;
     }
     $keyword = strim($GLOBALS['request']['keyword']);
     if ($xpoint > 0) {
         $pi = 3.14159265;
         //圆周率
         $r = 6378137;
         //地球平均半径(米)
         $field_append = ", (ACOS(SIN(({$ypoint} * {$pi}) / 180 ) *SIN((ypoint * {$pi}) / 180 ) +COS(({$ypoint} * {$pi}) / 180 ) * COS((ypoint * {$pi}) / 180 ) *COS(({$xpoint} * {$pi}) / 180 - (xpoint * {$pi}) / 180 ) ) * {$r}) as distance ";
         if ($ybottom != 0 && $ytop != 0 && $xleft != 0 && $xright != 0) {
             $where = " ypoint > {$ybottom} and ypoint < {$ytop} and xpoint > {$xleft} and xpoint < {$xright} ";
         }
         $order = " distance asc,is_recommend desc,sort desc,id desc";
     } else {
         $field_append = $where = $order = "";
     }
     $limit = ($page - 1) * PAGE_SIZE . "," . PAGE_SIZE;
     if ($keyword) {
         $kws_div = div_str($keyword);
         foreach ($kws_div as $k => $item) {
             $kw[$k] = str_to_unicode_string($item);
         }
         $ukeyword = implode(" ", $kw);
         $where .= " (match(name_match) against('" . $ukeyword . "'  IN BOOLEAN MODE)  or name like '%" . $keyword . "%') ";
     }
     $res = m_search_event_list($limit, $cate_id, $city_id, $where, $order, $field_append);
     $pattern = "/<img([^>]*)\\/>/i";
     $replacement = "<img width=300 \$1 />";
     foreach ($res['list'] as $k => $v) {
         if ($v['ypoint'] == '') {
             $res['list'][$k]['ypoint'] = 0;
         }
         if ($v['xpoint'] == '') {
             $res['list'][$k]['xpoint'] = 0;
         }
         $res['list'][$k]['icon'] = get_abs_img_root(get_spec_image($v['icon'], 140, 85, 0));
         $res['list'][$k]['distance'] = round($v['distance']);
         $res['list'][$k]['date_time'] = pass_date($v['submit_begin_time']);
         $res['list'][$k]['event_begin_time'] = to_date($v['event_begin_time'], 'Y-m-d');
         $res['list'][$k]['event_end_time'] = to_date($v['event_end_time'], 'Y-m-d');
         $res['list'][$k]['submit_end_time'] = to_date($v['submit_end_time'], 'Y-m-d');
         $res['list'][$k]['submit_begin_time'] = to_date($v['submit_begin_time'], 'Y-m-d');
         $res['list'][$k]['content'] = preg_replace($pattern, $replacement, get_abs_img_root($v['content']));
     }
     $root = array();
     $root['bigcate_list'] = $bigcate_list;
     $root['return'] = 1;
     $root['item'] = $res['list'];
     $root['page'] = array("page" => $page, "page_total" => ceil($res['count'] / PAGE_SIZE), "page_size" => PAGE_SIZE);
     $root['page_title'] = "活动列表";
     $root['city_name'] = $city_name;
     output($root);
 }
Example #16
0
 public function index()
 {
     require_once APP_ROOT_PATH . "system/libs/user.php";
     $root = array();
     $email = strim($GLOBALS['request']['biz_email']);
     //用户名或邮箱
     $pwd = strim($GLOBALS['request']['biz_pwd']);
     //密码
     $user_qrcode = strim($GLOBALS['request']['user_qrcode']);
     //会员二维码
     $page = intval($GLOBALS['request']['page']);
     //分页
     if ($page == 0) {
         $page = 1;
     }
     $limit = ($page - 1) * PAGE_SIZE . "," . PAGE_SIZE;
     $keyword = strim($GLOBALS['request']['keyword']);
     //查询关键字
     //检查用户,用户密码
     $biz_user = biz_check($email, $pwd);
     $supplier_id = intval($biz_user['supplier_id']);
     if ($supplier_id > 0) {
         $root['user_login_status'] = 1;
         //用户登陆状态:1:成功登陆;0:未成功登陆
         $time = get_gmtime();
         $sql = "select id, user_name, user_qrcode, qrcode_end from " . DB_PREFIX . "user where user_qrcode = '" . $user_qrcode . "' limit 1";
         $user = $GLOBALS['db']->getRow($sql);
         if (!$user) {
             $root['return'] = 0;
             $root['info'] = "会员卡不存在";
             output($root);
         } else {
             if ($user['qrcode_end'] < $time) {
                 $root['return'] = 0;
                 $root['info'] = "会员卡已过期";
                 output($root);
             }
         }
         $root['user_id'] = $user['id'];
         $root['user_qrcode'] = $user['user_qrcode'];
         $root['user_name'] = $user['user_name'];
         $sql = "select d.id,d.name,d.sub_name,d.icon, d.current_price,d.return_qrcode_money from " . DB_PREFIX . "deal as d left join " . DB_PREFIX . "deal_location_link as l on l.deal_id = d.id where ";
         $count_sql = "select count(d.id) from " . DB_PREFIX . "deal as d left join " . DB_PREFIX . "deal_location_link as l on l.deal_id = d.id where ";
         $condition = " d.is_shop in (0,1) and l.location_id in (" . implode(",", $biz_user['location_ids']) . ") and d.is_delete = 0 and d.supplier_id = " . $supplier_id . " and d.buy_type = 0 and d.publish_wait = 0  ";
         $condition .= " and ((" . $time . ">= d.begin_time or d.begin_time = 0) and (" . $time . "< d.end_time or d.end_time = 0) and d.buy_status <> 2) ";
         //$condition .= " and d.return_qrcode_money > 0";
         if ($keyword) {
             $kws_div = div_str($keyword);
             foreach ($kws_div as $k => $item) {
                 $kws[$k] = str_to_unicode_string($item);
             }
             $ukeyword = implode(" ", $kws);
             $condition .= " and (match(d.tag_match,d.name_match,d.locate_match,d.deal_cate_match) against('" . $ukeyword . "' IN BOOLEAN MODE) or d.name like '%" . $keyword . "%') ";
         }
         $sql .= $condition . " order by d.id desc limit " . $limit;
         //$root['sql'] = $sql;
         $count_sql .= $condition;
         //print_r($biz_user);
         //echo $sql; exit;
         $deal_list = $GLOBALS['db']->getAll($sql);
         foreach ($deal_list as $k => $v) {
             $deal_list[$k]['icon'] = get_abs_img_root(get_spec_image($v['icon'], 360, 288, 0));
             $deal_list[$k]['current_price_format'] = format_price($v['current_price']);
             $deal_list[$k]['return_qrcode_money_format'] = format_price($v['return_qrcode_money']);
             $deal_list[$k]['allow_edit_total_money'] = 1;
             //允许下单时,直接编辑商品总价
         }
         $deal_count = $GLOBALS['db']->getOne($count_sql);
         $root['page'] = array("page" => $page, "page_total" => ceil($deal_count / PAGE_SIZE), "page_size" => PAGE_SIZE);
         if ($deal_list == false || $deal_list == null) {
             $deal_list = array();
         }
         $root['item'] = $deal_list;
         $root['return'] = 1;
         $root['info'] = "商品列表";
     } else {
         $root['return'] = 0;
         $root['user_login_status'] = 0;
         //用户登陆状态:1:成功登陆;0:未成功登陆
         $root['info'] = "商户不存在或密码错误";
     }
     output($root);
 }
Example #17
0
 public function index()
 {
     require_once APP_ROOT_PATH . "system/model/user.php";
     $root = array();
     $email = strim($GLOBALS['request']['biz_email']);
     //用户名或邮箱
     $pwd = strim($GLOBALS['request']['biz_pwd']);
     //密码
     //检查用户,用户密码
     $biz_user = biz_check($email, $pwd);
     $supplier_id = intval($biz_user['supplier_id']);
     $type = strim($GLOBALS['request']['type']);
     //0:消费者评价;1:消费统计
     if ($supplier_id > 0) {
         $root['user_login_status'] = 1;
         //用户登陆状态:1:成功登陆;0:未成功登陆
         $page = intval($GLOBALS['request']['page']);
         if ($page == 0) {
             $page = 1;
         }
         $limit = ($page - 1) * PAGE_SIZE . "," . PAGE_SIZE;
         if ($type == 1) {
             $sql = "select DISTINCT d.id,d.begin_time,d.current_price,d.sub_name,d.name,d.img from " . DB_PREFIX . "deal as d left join " . DB_PREFIX . "deal_location_link as l on l.deal_id = d.id where d.is_shop in (0,2) and l.location_id in (" . implode(",", $biz_user['location_ids']) . ") and d.is_delete = 0 and d.supplier_id = " . $supplier_id . " order by d.id desc limit " . $limit;
         } else {
             $sql = "select DISTINCT d.id,d.begin_time,d.current_price,d.sub_name,d.name,d.img from " . DB_PREFIX . "deal as d left join " . DB_PREFIX . "deal_location_link as l on l.deal_id = d.id where d.is_shop = 0 and l.location_id in (" . implode(",", $biz_user['location_ids']) . ") and d.is_delete = 0 and d.supplier_id = " . $supplier_id . " order by d.id desc limit " . $limit;
         }
         //print_r($biz_user);
         //echo $sql; exit;
         $deal_list = $GLOBALS['db']->getAll($sql);
         foreach ($deal_list as $k => $v) {
             $deal_list[$k]['begin_time_format'] = to_date($v['begin_time'], 'Y-m-d');
             $deal_list[$k]['current_price_format'] = format_price($v['current_price']);
             //$deal_list[$k]['begin_time_format'] = to_date($v['begin_time'], 'Y-m-d');
             if ($type == 1) {
                 //已售团购券数量
                 $deal_list[$k]['coupon_count'] = intval($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_coupon as dc where dc.deal_id = " . $v['id'] . " and dc.is_valid = 1 and dc.is_delete = 0 "));
                 //已消费团购券数量
                 $deal_list[$k]['confirm_count'] = intval($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_coupon as dc where dc.deal_id = " . $v['id'] . " and dc.is_valid = 1 and dc.is_delete = 0 and dc.confirm_account <> 0"));
                 $deal_list[$k]['img'] = get_abs_img_root(get_spec_image($v['img'], 160, 160, 0));
                 //$deal_list[$k]['img2'] = get_domain().APP_ROOT;
             } else {
                 //购买点评数量
                 $deal_list[$k]['buy_dp_count'] = intval($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "message where rel_id = " . $v['id'] . " and rel_table = 'deal' and pid = 0 and is_buy = 1"));
                 //购买点评未读数
                 $deal_list[$k]['buy_dp_no_read_count'] = intval($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "message where rel_id = " . $v['id'] . " and rel_table = 'deal' and pid = 0 and is_buy = 1 and is_read = 0"));
                 //购买差评数
                 $deal_list[$k]['buy_dp_low_point_count'] = intval($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "message where rel_id = " . $v['id'] . " and rel_table = 'deal' and pid = 0 and is_buy = 1 and point <= 2"));
                 //星级点评数
                 $deal_list[$k]['star_1'] = 0;
                 $deal_list[$k]['star_2'] = 0;
                 $deal_list[$k]['star_3'] = 0;
                 $deal_list[$k]['star_4'] = 0;
                 $deal_list[$k]['star_5'] = 0;
                 $buy_dp_sum = 0.0;
                 $buy_dp_group = $GLOBALS['db']->getAll("select point,count(*) as num from " . DB_PREFIX . "message where rel_id = " . $v['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) {
                         $deal_list[$k]['star_' . $star] = $dp_v['num'];
                         $buy_dp_sum += $star * $dp_v['num'];
                     }
                 }
                 //点评平均分
                 $deal_list[$k]['buy_dp_avg'] = round($buy_dp_sum / $deal_list[$k]['buy_dp_count'], 1);
             }
         }
         $deal_count = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal as d left join " . DB_PREFIX . "deal_location_link as l on l.deal_id = d.id where l.location_id in (" . implode(",", $biz_user['location_ids']) . ") and d.is_delete = 0 and d.supplier_id = " . $supplier_id);
         $root['page'] = array("page" => $page, "page_total" => ceil($deal_count / PAGE_SIZE), "page_size" => PAGE_SIZE);
         if ($deal_list == false || $deal_list == null) {
             $deal_list = array();
         }
         $root['item'] = $deal_list;
         $root['return'] = 1;
     } else {
         $root['return'] = 0;
         $root['user_login_status'] = 0;
         //用户登陆状态:1:成功登陆;0:未成功登陆
         $root['info'] = "商户不存在或密码错误";
     }
     output($root);
 }
Example #18
0
 public function index()
 {
     $root = array();
     $root['return'] = 1;
     $catalog_id = intval($GLOBALS['request']['catalog_id']);
     //商品分类ID
     $cata_type_id = intval($GLOBALS['request']['cata_type_id']);
     //商品二级分类
     $city_id = intval($GLOBALS['request']['city_id']);
     //城市分类ID
     $page = intval($GLOBALS['request']['page']);
     //分页
     $keyword = strim($GLOBALS['request']['keyword']);
     $page = $page == 0 ? 1 : $page;
     $quan_id = intval($GLOBALS['request']['quan_id']);
     //商圈id
     $order_type = strim($GLOBALS['request']['order_type']);
     //if(!$city_id)
     //{
     //	$city = get_current_deal_city();
     //	$city_id = $city['id'];
     //}
     $ytop = $latitude_top = floatval($GLOBALS['request']['latitude_top']);
     //最上边纬线值 ypoint
     $ybottom = $latitude_bottom = floatval($GLOBALS['request']['latitude_bottom']);
     //最下边纬线值 ypoint
     $xleft = $longitude_left = floatval($GLOBALS['request']['longitude_left']);
     //最左边经度值  xpoint
     $xright = $longitude_right = floatval($GLOBALS['request']['longitude_right']);
     //最右边经度值 xpoint
     $ypoint = $m_latitude = doubleval($GLOBALS['request']['m_latitude']);
     //ypoint
     $xpoint = $m_longitude = doubleval($GLOBALS['request']['m_longitude']);
     //xpoint
     /*输出分类*/
     $bcate_list = getCateList();
     $url_param['quan_id'] = $quan_id;
     $url_param['catalog_id'] = $catalog_id;
     $url_param['cata_type_id'] = $cata_type_id;
     foreach ($bcate_list as $k => $v) {
         $tmp_url_param = $url_param;
         unset($tmp_url_param['catalog_id']);
         $tmp_url_param['catalog_id'] = $v['id'];
         $tmp_url_param['catename'] = $v['name'];
         if ($quan_id > 0) {
             $quanname = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "area where id=" . $quan_id);
             $tmp_url_param['quanname'] = $quanname;
         } else {
             $tmp_url_param['quanname'] = "全城";
         }
         $turl = wap_url("index", "tuanlist", $tmp_url_param);
         $url = str_replace('sjmapi', 'wap', $turl);
         $bcate_list[$k]["url"] = $url;
         foreach ($v['bcate_type'] as $kk => $vv) {
             $tmp_url_param = $url_param;
             unset($tmp_url_param['cata_type_id']);
             $tmp_url_param['cata_type_id'] = $vv["id"];
             $tmp_url_param['catename'] = $vv['name'];
             $tmp_url_param['catalog_id'] = $vv['cate_id'];
             if ($quan_id > 0) {
                 $quanname = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "area  where id=" . $quan_id);
                 $tmp_url_param['quanname'] = $quanname;
             } else {
                 $tmp_url_param['quanname'] = "全城";
             }
             $turl = wap_url("index", "tuanlist", $tmp_url_param);
             $url = str_replace('sjmapi', 'wap', $turl);
             $bcate_list[$k]["bcate_type"][$kk]["url"] = $url;
         }
     }
     /*输出商圈*/
     $quan_list = getQuanList($city_id);
     foreach ($quan_list as $k => $v) {
         $tmp_url_param = $url_param;
         unset($tmp_url_param['quan_id']);
         $tmp_url_param['quan_id'] = $v['id'];
         $tmp_url_param['quanname'] = $v['name'];
         if ($catalog_id > 0) {
             $catename = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "deal_cate  where id=" . $catalog_id);
             $tmp_url_param['catename'] = $catename;
         } else {
             $tmp_url_param['catename'] = "全部分类";
         }
         $turl = wap_url("index", "tuanlist", $tmp_url_param);
         $url = str_replace('sjmapi', 'wap', $turl);
         $quan_list[$k]["url"] = $url;
         foreach ($v['quan_sub'] as $kk => $vv) {
             $tmp_url_param = $url_param;
             unset($tmp_url_param['quan_id']);
             $tmp_url_param['quan_id'] = $vv['id'];
             $tmp_url_param['quanname'] = $vv['name'];
             if ($catalog_id > 0) {
                 $catename = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "deal_cate  where id=" . $catalog_id);
                 $tmp_url_param['catename'] = $catename;
             } else {
                 $tmp_url_param['catename'] = "全部分类";
             }
             $turl = wap_url("index", "tuanlist", $tmp_url_param);
             $url = str_replace('sjmapi', 'wap', $turl);
             $quan_list[$k]["quan_sub"][$kk]["url"] = $url;
         }
     }
     $page_size = PAGE_SIZE;
     $limit = ($page - 1) * $page_size . "," . $page_size;
     if ($keyword) {
         $kws_div = div_str($keyword);
         foreach ($kws_div as $k => $item) {
             $kws[$k] = str_to_unicode_string($item);
         }
         $ukeyword = implode(" ", $kws);
         $condition = "  (match(tag_match,name_match,locate_match,deal_cate_match) against('" . $ukeyword . "' IN BOOLEAN MODE) or name like '%" . $keyword . "%') and ";
     }
     //buy_type 0普通团购;2在线订购;3秒杀抢团
     //is_shop 0团购;1:商品;
     $condition .= " buy_type = 0 and is_shop = 0 and is_lottery = 0 ";
     if ($xpoint > 0) {
         $pi = 3.14159265;
         //圆周率
         $r = 6378137;
         //地球平均半径(米)
         $field_append = ", (ACOS(SIN(({$ypoint} * {$pi}) / 180 ) *SIN((ypoint * {$pi}) / 180 ) +COS(({$ypoint} * {$pi}) / 180 ) * COS((ypoint * {$pi}) / 180 ) *COS(({$xpoint} * {$pi}) / 180 - (xpoint * {$pi}) / 180 ) ) * {$r}) as distance ";
         if ($ybottom != 0 && $ytop != 0 && $xleft != 0 && $xright != 0) {
             if ($condition != "") {
                 $condition .= " and ";
             }
             $condition .= " ypoint > {$ybottom} and ypoint < {$ytop} and xpoint > {$xleft} and xpoint < {$xright} ";
         }
         $order = " distance asc,id desc ";
     } else {
         $order = "sort desc,id desc ";
     }
     /*排序  
     		 智能排序和 离我最的 是一样的 都以距离来升序来排序,只有这两种情况有传经纬度过来,就没有把 这两种情况写在 下面的判断里,写在上面了。
     		default 智能(默认),nearby  离我,avg_point 评价,newest 最新,buy_count 人气,price_asc 价低,price_desc 价高 */
     $ordertype[] = array("name" => "默认排序", "sc" => "avg_point");
     $ordertype[] = array("name" => "最新发布", "sc" => "newest");
     $ordertype[] = array("name" => "销量最高", "sc" => "buy_count");
     $ordertype[] = array("name" => "价格最高", "sc" => "price_desc");
     $ordertype[] = array("name" => "价格最低", "sc" => "price_asc");
     foreach ($ordertype as $k => $v) {
         $tmp_url_param = $url_param;
         if ($quanname) {
             $tmp_url_param['quanname'] = $quanname;
         }
         if ($catename) {
             $tmp_url_param['catename'] = $catename;
         }
         if ($keyword) {
             $tmp_url_param['keyword'] = $keyword;
         }
         $tmp_url_param['order_type'] = $v['sc'];
         $turl = wap_url("index", "goodslist", $tmp_url_param);
         $url = str_replace('sjmapi', 'wap', $turl);
         $ordertype[$k]["url"] = $url;
     }
     $root['ordertype'] = $ordertype;
     if ($order_type == 'avg_point') {
         /*评价*/
         $order = " avg_point desc,id desc ";
     } elseif ($order_type == 'newest') {
         /*最新*/
         $order = " create_time desc,id desc ";
     } elseif ($order_type == 'buy_count') {
         /*销量*/
         $order = " buy_count desc,id desc ";
     } elseif ($order_type == 'price_asc') {
         /*价格升*/
         $order = " current_price asc,id desc ";
     } elseif ($order_type == 'price_desc') {
         /*价格降*/
         $order = " current_price desc,id desc ";
     }
     //根据传入的商圈ID来搜索该商圈下的商品
     if ($quan_id > 0) {
         $sql_q = "select name from " . DB_PREFIX . "area where id = " . intval($quan_id);
         $q_name = $GLOBALS['db']->getOne($sql_q);
         $q_name_unicode = str_to_unicode_string($q_name);
         $condition .= " and (match(locate_match) against('" . $q_name_unicode . "' IN BOOLEAN MODE))";
     }
     $deals = m_get_deal_list($limit, $catalog_id, $city_id, array(DEAL_ONLINE), $condition, $order, 0, $field_append, $cata_type_id);
     $list = $deals['list'];
     $count = $deals['count'];
     $page_total = ceil($count / $page_size);
     //$root['sql'] = $deals['sql'];
     $taday_begin = to_timespan(to_date(get_gmtime(), 'Y-m-d'));
     $taday_end = $taday_begin * 24 * 60 * 60;
     $goodses = array();
     foreach ($list as $k => $v) {
         $goodses[$k]['id'] = $v['id'];
         $goodses[$k]['distance'] = $v['distance'];
         $goodses[$k]['ypoint'] = $v['ypoint'];
         $goodses[$k]['xpoint'] = $v['xpoint'];
         $goodses[$k]['name'] = $v['name'];
         $goodses[$k]['sub_name'] = $v['sub_name'];
         $goodses[$k]['goods_brief'] = $v['brief'];
         $goodses[$k]['buy_count'] = $v['buy_count'];
         $goodses[$k]['auto_order'] = $v['auto_order'];
         $goodses[$k]['current_price'] = round($v['current_price'], 2);
         $goodses[$k]['origin_price'] = round($v['origin_price'], 2);
         $goodses[$k]['icon'] = get_abs_img_root(get_spec_image($v['icon'], 140, 85, 0));
         if ($v['begin_time'] > 0 && ($taday_begin < $v['begin_time'] && $v['begin_time'] < $taday_end)) {
             $goodses[$k]['is_taday'] = 1;
         } else {
             if ($v['begin_time'] == 0 && ($taday_begin < $v['create_time'] && $v['create_time'] < $taday_end)) {
                 $goodses[$k]['is_taday'] = 1;
             } else {
                 $goodses[$k]['is_taday'] = 0;
             }
         }
     }
     $root['city_id'] = $city_id;
     $root['quan_id'] = $quan_id;
     $root['catalog_id'] = $catalog_id;
     $root['page_title'] = "团购列表";
     $root['page'] = array("page" => $page, "page_total" => $page_total, "page_size" => $page_size);
     if ($goodses === false) {
         $root['item'] = array();
     } else {
         $root['item'] = $goodses;
     }
     if ($bcate_list === false) {
         $root[''] = array();
     } else {
         $root['bcate_list'] = $bcate_list;
     }
     if ($quan_list === false) {
         $root['quan_list'] = array();
     } else {
         $root['quan_list'] = $quan_list;
     }
     output($root);
 }
Example #19
0
 public function index()
 {
     require_once APP_ROOT_PATH . 'system/model/deal.php';
     $root = array();
     $root['return'] = 1;
     $catalog_id = intval($GLOBALS['request']['catalog_id']);
     //商品分类ID
     $cata_type_id = intval($GLOBALS['request']['cata_type_id']);
     //商品二级分类
     $city_id = intval($GLOBALS['request']['city_id']);
     //城市分类ID
     $page = intval($GLOBALS['request']['page']);
     //分页
     $keyword = strim($GLOBALS['request']['keyword']);
     $city_name = strim($GLOBALS['request']['city_name']);
     //城市名称
     //print_r($GLOBALS['request']);
     $order_type = strim($GLOBALS['request']['order_type']);
     $quan_id = intval($GLOBALS['request']['quan_id']);
     //商圈id
     if ($cata_type_id > 0) {
         $catalog_id = $cata_type_id;
     }
     if ($order_type == 'buy_count') {
         $marked_tag = 1;
     } elseif ($order_type == 'price_desc') {
         $marked_tag = 2;
     } elseif ($order_type == 'newest') {
         $marked_tag = 3;
     } else {
         $marked_tag = 1;
     }
     $root['marked_tag'] = $marked_tag;
     /*输出分类*/
     $bcate_list = getShopcateList();
     $url_param['quan_id'] = $quan_id;
     $url_param['catalog_id'] = $catalog_id;
     foreach ($bcate_list as $k => $v) {
         if ($catalog_id == $v['id']) {
             $bcate_list[$k]['marked_tag'] = 1;
         }
         /*
         if($catalog_id==$v['id'])
         {
         	$bcate_list['bcate_type'][$k]['act'] = 1;
         }
         */
         $tmp_url_param = $url_param;
         unset($tmp_url_param['catalog_id']);
         $tmp_url_param['catalog_id'] = $v['id'];
         $tmp_url_param['catename'] = $v['name'];
         if ($quan_id > 0) {
             $quanname = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "area  where id=" . $quan_id);
             $tmp_url_param['quanname'] = $quanname;
         } else {
             $tmp_url_param['quanname'] = "全城";
         }
         $turl = wap_url("index", "goodslist", $tmp_url_param);
         $url = str_replace('sjmapi', 'wap', $turl);
         $bcate_list[$k]["url"] = $url;
         foreach ($v['bcate_type'] as $kk => $vv) {
             /*
             if($catalog_id==$vv['id'])
             {
             	$bcate_list['bcate_type'][$kk]['act'] = 1;
             }
             */
             $tmp_url_param = $url_param;
             unset($tmp_url_param['catalog_id']);
             $tmp_url_param['catalog_id'] = $vv['id'];
             if ($bcate_list['bcate_type'][$kk]['id'] == $vv['id']) {
                 $tmp_url_param['catename'] = $v['name'];
             } else {
                 $tmp_url_param['catename'] = $vv['name'];
             }
             if ($quan_id > 0) {
                 $quanname = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "area a where id=" . $quan_id);
                 $tmp_url_param['quanname'] = $quanname;
             } else {
                 $tmp_url_param['quanname'] = "全城";
             }
             $turl = wap_url("index", "goodslist", $tmp_url_param);
             $url = str_replace('sjmapi', 'wap', $turl);
             $bcate_list[$k]["bcate_type"][$kk]["url"] = $url;
         }
     }
     //品牌列表
     if ($catalog_id > 0) {
         $cate_key = load_auto_cache("shop_cate_key", array("cid" => $catalog_id));
         $brand_list = $GLOBALS['db']->getAll("select id,name,sort,0 as city_id, from " . DB_PREFIX . "brand where match(tag_match) against('" . $cate_key . "' IN BOOLEAN MODE)  order by sort limit 100");
     } else {
         $brand_list = $GLOBALS['db']->getAll("select id,name,sort,0 as city_id from " . DB_PREFIX . "brand  order by sort limit 100");
     }
     $quan_list = array();
     $quan_list[0]['id'] = 0;
     $quan_list[0]['name'] = '全部品牌';
     /*
     $quan_list[0]['quan_sub'][0]['id']=0;
     $quan_list[0]['quan_sub'][0]['pid']=0;
     $quan_list[0]['quan_sub'][0]['name']='全部';
     */
     foreach ($brand_list as $k => $v) {
         $quan_list[] = $v;
     }
     foreach ($quan_list as $k => $v) {
         $tmp_url_param = $url_param;
         unset($tmp_url_param['quan_id']);
         $tmp_url_param['quan_id'] = $v['id'];
         $tmp_url_param['quanname'] = $v['name'];
         if ($catalog_id > 0) {
             $catename = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "shop_cate  where id=" . $catalog_id);
             $tmp_url_param['catename'] = $catename;
         } else {
             $tmp_url_param['catename'] = "全部分类";
         }
         $turl = wap_url("index", "goodslist", $tmp_url_param);
         $url = str_replace('sjmapi', 'wap', $turl);
         $quan_list[$k]["url"] = $url;
         $quan_list[$k]['quan_sub'][] = array('id' => $v['id'], 'pid' => $v['id'], 'name' => '全部');
     }
     $ordertype[] = array("name" => "默认排序", "sc" => "avg_point");
     $ordertype[] = array("name" => "最新发布", "sc" => "newest");
     $ordertype[] = array("name" => "销量最高", "sc" => "buy_count");
     $ordertype[] = array("name" => "价格最高", "sc" => "price_desc");
     $ordertype[] = array("name" => "价格最低", "sc" => "price_asc");
     foreach ($ordertype as $k => $v) {
         $tmp_url_param = $url_param;
         if ($quanname) {
             $tmp_url_param['quanname'] = $quanname;
         }
         if ($catename) {
             $tmp_url_param['catename'] = $catename;
         }
         if ($keyword) {
             $tmp_url_param['keyword'] = $keyword;
         }
         $tmp_url_param['order_type'] = $v['sc'];
         $turl = wap_url("index", "goodslist", $tmp_url_param);
         $url = str_replace('sjmapi', 'wap', $turl);
         $ordertype[$k]["url"] = $url;
     }
     $root['ordertype'] = $ordertype;
     /*排序*/
     if ($order_type == 'avg_point') {
         $order = " avg_point desc,id desc ";
     } elseif ($order_type == 'newest') {
         $order = " create_time desc,id desc ";
     } elseif ($order_type == 'buy_count') {
         $order = " buy_count desc,id desc ";
     } elseif ($order_type == 'price_asc') {
         $order = " current_price asc,id desc ";
     } elseif ($order_type == 'price_desc') {
         $order = " current_price desc,id desc ";
     } else {
         $order = "sort desc,id desc ";
     }
     $page = $page == 0 ? 1 : $page;
     $page_size = PAGE_SIZE;
     $limit = ($page - 1) * $page_size . "," . $page_size;
     //buy_type = 0 普通商品;1积分商品
     $condition = " buy_type = 0  and is_shop=1";
     if ($keyword) {
         $kws_div = div_str($keyword);
         foreach ($kws_div as $k => $item) {
             $kws[$k] = str_to_unicode_string($item);
         }
         $ukeyword = implode(" ", $kws);
         $condition .= " and  (match(tag_match,name_match,locate_match,shop_cate_match) against('" . $ukeyword . "' IN BOOLEAN MODE) or name like '%" . $keyword . "%')";
     }
     $merchant_id = intval($GLOBALS['request']['merchant_id']);
     if ($merchant_id > 0) {
         $deal_ids = $GLOBALS['db']->getOne("select group_concat(deal_id) from " . DB_PREFIX . "deal_location_link where location_id = " . $merchant_id);
         if ($deal_ids) {
             $condition .= " and id in (" . $deal_ids . ") ";
         } else {
             $condition .= " and id ='' ";
         }
     }
     //根据传入的商圈ID来搜索该商圈下的商品
     if ($quan_id > 0) {
         $condition .= " and brand_id = " . $quan_id;
     }
     //get_goods_list($limit,$type=array(DEAL_ONLINE,DEAL_HISTORY,DEAL_NOTICE),$param=array("cid"=>0,"city_id"=>0), $join='', $where='',$orderby = '')
     $deals = get_goods_list($limit, array(DEAL_ONLINE, DEAL_HISTORY), array("cid" => $catalog_id, "city_id" => $city_id), '', $condition, $order);
     $condition = $deals['condition'];
     $sql = "select count(*) from " . DB_PREFIX . "deal as d where  " . $condition;
     $count = $GLOBALS['db']->getOne($sql);
     $list = $deals['list'];
     $page_total = ceil($count / $page_size);
     $goodses = array();
     foreach ($list as $item) {
         //$goods = array();
         $goods = getGoodsArray($item);
         $goods['image'] = get_abs_img_root(get_spec_image($item['img'], 140, 85, 0));
         $goodses[] = $goods;
     }
     $root['item'] = $goodses;
     $root['page'] = array("page" => $page, "page_total" => $page_total, "page_size" => $page_size);
     //$root['quan_list'] = getCityList();
     /*
     //输出城市
     $root['city_list']=getCityList();
     //输出商圈
     $quan_list=getQuanList($city_id);
     $root['quan_list2'] = $quan_list;
     */
     //$root['bcate_list'] = $bcate_list;
     //$root['quan_list'] = $quan_list;
     if ($bcate_list === false) {
         $root['bcate_list'] = array();
     } else {
         $root['bcate_list'] = $bcate_list;
     }
     if ($quan_list === false) {
         $root['quan_list'] = array();
     } else {
         $root['quan_list'] = $quan_list;
     }
     $root['page_title'] = "商品列表";
     $root['city_name'] = $city_name;
     output($root);
 }
 public function index()
 {
     $root = array();
     $page = intval($GLOBALS['request']['page']);
     // 分页
     $page = $page == 0 ? 1 : $page;
     $root['response_code'] = 1;
     $param = array();
     // 参数集合
     // 数据来源参数
     $r = strim($_REQUEST['r']);
     // 推荐类型
     $param['r'] = $r ? $r : '';
     $id = intval($_REQUEST['id']);
     // 分类id3
     $param['id'] = $id;
     // ios标志
     if ($id == 0) {
         $isAll = 1;
     } else {
         $isAll = 0;
     }
     $loc = strim($_REQUEST['loc']);
     // 地区
     $param['loc'] = $loc;
     $GLOBALS['tmpl']->assign("p_loc", $loc);
     $state = intval($_REQUEST['state']);
     // 状态1
     $param['state'] = $state;
     $tag = strim($_REQUEST['tag']);
     // 标签
     $param['tag'] = $tag;
     $GLOBALS['tmpl']->assign("p_tag", $tag);
     $kw = strim($_REQUEST['key']);
     // 关键词
     $param['kw'] = $kw;
     $cate_list = load_dynamic_cache("INDEX_CATE_LIST");
     if (!$cate_list) {
         $cate_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_cate order by sort asc");
         set_dynamic_cache("INDEX_CATE_LIST", $cate_list);
     }
     $cate_result = array();
     $cate_result[0]['id'] = '0';
     $cate_result[0]['name'] = "全部";
     foreach ($cate_list as $k => $v) {
         $temp_param = $param;
         $cate_result[$k + 1]['id'] = $v['id'];
         $cate_result[$k + 1]['name'] = $v['name'];
         $temp_param['id'] = $v['id'];
     }
     $root['cate_list'] = $cate_result;
     $pid = 0;
     // 获取父类id
     if ($cate_list) {
         foreach ($cate_list as $k => $v) {
             if ($v['id'] == $id) {
                 if ($v['pid'] > 0) {
                     $pid = $v['pid'];
                 } else {
                     $pid = $id;
                 }
             }
         }
     }
     /* 子分类 start */
     $cate_ids = array();
     $is_has_child = false;
     $temp_cate_ids = array();
     if ($cate_list) {
         $child_cate_result = array();
         foreach ($cate_list as $k => $v) {
             if ($v['pid'] == $pid) {
                 if ($v['pid'] > 0) {
                     $temp_param = $param;
                     $child_cate_result[$v['id']]['id'] = $v['id'];
                     $child_cate_result[$v['id']]['name'] = $v['name'];
                     $temp_param['id'] = $v['id'];
                     $child_cate_result[$v['id']]['url'] = url_mapi("deals", $temp_param);
                     if ($v['id'] == $id) {
                         $is_has_child = true;
                     }
                 }
             }
             if ($v['pid'] == $pid || $pid == 0) {
                 $temp_cate_ids[] = $v['id'];
             }
         }
     }
     // 假如选择了子类 那么使用子类ID 否则使用 父类和其子类
     if ($is_has_child) {
         $cate_ids[] = $id;
     } else {
         $cate_ids[] = $pid;
         $cate_ids = array_merge($cate_ids, $temp_cate_ids);
     }
     $root['child_cate_list'] = $child_cate_result;
     $root['pid'] = $pid;
     /* 子分类 end */
     $city_list = load_dynamic_cache("INDEX_CITY_LIST");
     if (!$city_list) {
         $city_list = $GLOBALS['db']->getAll("select province from " . DB_PREFIX . "deal group by province order by sort asc");
         set_dynamic_cache("INDEX_CITY_LIST", $city_list);
     }
     foreach ($city_list as $k => $v) {
         $temp_param = $param;
         $temp_param['loc'] = $v['province'];
         $city_list[$k]['url'] = url_mapi("deals", $temp_param);
     }
     $root['city_list'] = $city_list;
     $state_list = array(0 => array("name" => "全部"), 1 => array("name" => "筹资成功"), 2 => array("name" => "筹资失败"), 3 => array("name" => "筹资中"));
     foreach ($state_list as $k => $v) {
         $temp_param = $param;
         $temp_param['state'] = $k;
         $state_list[$k]['url'] = url_mapi("deals", $temp_param);
     }
     $root['state_list'] = $state_list;
     $page_size = $GLOBALS['m_config']['page_size'];
     $page = intval($_REQUEST['p']);
     if ($page == 0) {
         $page = 1;
     }
     $limit = ($page - 1) * $page_size . "," . $page_size;
     $condition = " is_delete = 0 and is_effect = 1 ";
     if ($r != "") {
         if ($r == "new") {
             $condition .= " and " . NOW_TIME . " - begin_time < " . 24 * 3600 . " and " . NOW_TIME . " - begin_time > 0 ";
             // 上线不超过一天
             $GLOBALS['tmpl']->assign("page_title", "最新上线");
         }
         if ($r == "rec") {
             $condition .= " and " . NOW_TIME . " <= end_time AND " . NOW_TIME . " >= begin_time and is_recommend = 1 ";
             $GLOBALS['tmpl']->assign("page_title", "推荐项目");
         }
         if ($r == "yure") {
             $condition .= " and " . NOW_TIME . " - begin_time < " . 24 * 3600 . " and " . NOW_TIME . " - begin_time <  0 ";
             // 上线不超过一天
             $GLOBALS['tmpl']->assign("page_title", "正在预热");
         }
         if ($r == "nend") {
             $condition .= " and end_time - " . NOW_TIME . " < " . 24 * 3600 . " and end_time - " . NOW_TIME . " > 0 ";
             // 当天就要结束
             $GLOBALS['tmpl']->assign("page_title", "即将结束");
         }
         if ($r == "classic") {
             $condition .= " and is_classic = 1 ";
             $GLOBALS['tmpl']->assign("page_title", "经典项目");
         }
         if ($r == "limit_price") {
             $condition .= " and max(limit_price) ";
             $GLOBALS['tmpl']->assign("page_title", "最高目标金额");
         }
     }
     switch ($state) {
         // 筹资中
         case 0:
             $GLOBALS['tmpl']->assign("page_title", "全部");
             break;
             // 筹资成功
         // 筹资成功
         case 1:
             $condition .= " and end_time < " . NOW_TIME . "  and support_amount >= limit_price";
             $GLOBALS['tmpl']->assign("page_title", "筹资成功");
             break;
             // 筹资失败
         // 筹资失败
         case 2:
             $condition .= " and end_time < " . NOW_TIME . "  and  support_amount < limit_price ";
             $GLOBALS['tmpl']->assign("page_title", "筹资失败");
             break;
             // 筹资中
         // 筹资中
         case 3:
             $condition .= " and end_time > " . NOW_TIME . "  and begin_time < " . NOW_TIME . " ";
             $GLOBALS['tmpl']->assign("page_title", "筹资中");
             break;
     }
     if (count($cate_ids) > 0) {
         $condition .= " and cate_id in (" . implode(",", $cate_ids) . ")";
         $GLOBALS['tmpl']->assign("page_title", $cate_result[$id]['name']);
     }
     if ($loc != "") {
         $condition .= " and (province = '" . $loc . "' or city = '" . $loc . "') ";
         $GLOBALS['tmpl']->assign("page_title", $loc);
     }
     if ($tag != "") {
         $unicode_tag = str_to_unicode_string($tag);
         $condition .= " and match(tags_match) against('" . $unicode_tag . "'  IN BOOLEAN MODE) ";
         $GLOBALS['tmpl']->assign("page_title", $tag);
     }
     if ($kw != "") {
         $kws_div = div_str($kw);
         foreach ($kws_div as $k => $item) {
             $kws[$k] = str_to_unicode_string($item);
         }
         $ukeyword = implode(" ", $kws);
         $condition .= " and (match(name_match) against('" . $ukeyword . "'  IN BOOLEAN MODE) or match(tags_match) against('" . $ukeyword . "'  IN BOOLEAN MODE)  or name like '%" . $kw . "%') ";
         $GLOBALS['tmpl']->assign("page_title", $kw);
     }
     // 权限浏览控制
     if ($GLOBALS['user_info']['user_level'] != 0) {
         $condition .= " AND (user_level ='' or user_level=0 or user_level <=" . $GLOBALS['user_info']['user_level'] . ") ";
     } else {
         $condition .= " AND (user_level =0 or user_level =1 or user_level ='') ";
     }
     $deal_count = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal where " . $condition);
     /* (所需项目)准备虚拟数据 start */
     $deal_list = array();
     if ($deal_count > 0) {
         $now_time = get_gmtime();
         // $deal_list = $GLOBALS['db']->getAll("select * from
         // ".DB_PREFIX."deal where ".$condition." order by sort asc ");
         $deal_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal where " . $condition . " order by sort asc limit " . $limit);
         $deal_ids = array();
         foreach ($deal_list as $k => $v) {
             // $deal_list['percent'] =
             // round($deal_list['support_amount']/$deal_list['limit_price']*100);
         }
         // 获取当前项目列表下的所有子项目
         $temp_virtual_person_list = $GLOBALS['db']->getAll("select deal_id,virtual_person,price from " . DB_PREFIX . "deal_item where deal_id in(" . implode(",", $deal_ids) . ") ");
         $virtual_person_list = array();
         // 重新组装一个以项目ID为KEY的 统计所有的虚拟人数和虚拟价格
         foreach ($temp_virtual_person_list as $k => $v) {
             $virtual_person_list[$v['deal_id']]['total_virtual_person'] += $v['virtual_person'];
             $virtual_person_list[$v['deal_id']]['total_virtual_price'] += $v['price'] * $v['virtual_person'];
         }
         unset($temp_virtual_person_list);
         // 将获取到的虚拟人数和虚拟价格拿到项目列表里面进行统计
         foreach ($deal_list as $k => $v) {
             $deal_list[$k]['virtual_person'] = $virtual_person_list[$v['id']]['total_virtual_person'];
             $deal_list[$k]['percent'] = round(($v['support_amount'] + $virtual_person_list[$v['id']]['total_virtual_price']) / $v['limit_price'] * 100);
             $deal_list[$k]['support_count'] += $deal_list[$k]['virtual_person'];
             $deal_list[$k]['support_amount'] += $virtual_person_list[$v['id']]['total_virtual_price'];
             /*
              *
              * $deal_list[$k]['description']=get_abs_img_root(get_spec_image($v['description'],640,240,1));
              * $deal_list[$k]['content']=get_abs_img_root(get_spec_image($v['description'],640,240,1));
              * $deal_list[$k]['content_1']=get_abs_img_root(get_spec_image($v['description_1'],640,240,1));
              * $deal_list[$k]['deal_extra_cache']=null;
              */
             $deal_list[$k]['image'] = get_abs_img_root(get_spec_image($v['image'], 640, 240, 1));
             if ($v['end_time'] > 0 && $v['end_time'] > $now_time) {
                 $deal_list[$k]['remain_days'] = floor(($v['end_time'] - $now_time) / (24 * 3600));
             } elseif ($v['end_time'] > 0 && $v['end_time'] <= $now_time) {
                 $deal_list[$k]['remain_days'] = 0;
             }
             if ($v['begin_time'] > $now_time) {
                 $deal_list[$k]['left_days'] = intval(($now_time - $v['create_time']) / 24 / 3600);
             } else {
                 $deal_list[$k]['left_days'] = 0;
             }
             $deal_list[$k]['num_days'] = floor(($v['end_time'] - $v['begin_time']) / (24 * 3600));
             // $deal_list[$k]['status']值0表示即将开始;1表示已成功;2表示筹资失败;3表示筹资中;4表示长期项目
             if ($v['begin_time'] > $now_time) {
                 $deal_list[$k]['status'] = '0';
             } elseif ($v['end_time'] < $now_time && $v['end_time'] > 0) {
                 if ($deal_list[$k]['percent'] >= 100) {
                     $deal_list[$k]['status'] = '1';
                 } else {
                     if ($deal_list[$k]['percent'] >= 0) {
                         $deal_list[$k]['status'] = '2';
                     }
                 }
             } else {
                 if ($v['end_time'] > 0) {
                     if ($deal_list[$k]['percent'] >= 100) {
                         $deal_list[$k]['status'] = '1';
                     } else {
                         $deal_list[$k]['status'] = '3';
                     }
                 } else {
                     $deal_list[$k]['status'] = '4';
                 }
             }
             $deal_list[$k]['end_time'] = to_date($v['end_time'], 'Y-m-d');
             $deal_list[$k]['begin_time'] = to_date($v['begin_time'], 'Y-m-d');
             $deal_list[$k]['create_time'] = to_date($v['create_time'], 'Y-m-d');
             $deal_ids[] = $v['id'];
             // 查询出对应项目id的user_level
             $deal_list[$k]['deal_level'] = $GLOBALS['db']->getOne("select level from " . DB_PREFIX . "deal_level where id=" . intval($deal_list[$k]['user_level']));
         }
     }
     /* (所需项目)准备虚拟数据 end */
     $root['isAll'] = $isAll;
     $root['deal_list'] = $deal_list;
     $root['deal_count'] = $deal_count;
     $root['page'] = array("page" => $page, "page_total" => ceil($deal_count / $page_size), "page_size" => intval($page_size), 'total' => intval($deal_count));
     output($root);
 }
Example #21
0
 public function index()
 {
     $root = array();
     $root['response_code'] = 1;
     //print_r($GLOBALS['db_conf']); exit;
     $root['kf_phone'] = $GLOBALS['m_config']['kf_phone'];
     //客服电话
     $root['kf_email'] = $GLOBALS['m_config']['kf_email'];
     //客服邮箱
     //$pattern = "/<img([^>]*)\/>/i";
     //$replacement = "<img width=300 $1 />";
     //$goods['goods_desc'] = preg_replace($pattern, $replacement, get_abs_img_root($goods['goods_desc']));
     //关于我们(填文章ID)
     $root['about_info'] = intval($GLOBALS['m_config']['about_info']);
     $root['version'] = VERSION;
     //接口版本号int
     $root['page_size'] = PAGE_SIZE;
     //默认分页大小
     $root['program_title'] = $GLOBALS['m_config']['program_title'];
     $root['site_domain'] = str_replace("/mapi", "", SITE_DOMAIN . APP_ROOT);
     //站点域名;
     $root['site_domain'] = str_replace("http://", "", $root['site_domain']);
     //站点域名;
     $root['site_domain'] = str_replace("https://", "", $root['site_domain']);
     //站点域名;
     //$root['newslist'] = $GLOBALS['m_config']['newslist'];
     //累计投资金额
     $stats['total_load'] = $GLOBALS['db']->getOne("SELECT sum(money) FROM " . DB_PREFIX . "deal_load where is_repay= 0 ");
     $stats['total_load_format'] = format_conf_count(number_format($stats['total_load'], 2));
     //成交笔数
     $stats['deal_total_count'] = $GLOBALS['db']->getOne("SELECT count(*) FROM " . DB_PREFIX . "deal where  deal_status >=4 ");
     //累计创造收益
     $stats['total_rate'] = $GLOBALS['db']->getOne("SELECT sum(true_interest_money + impose_money + true_reward_money - true_manage_money - true_manage_interest_money) FROM " . DB_PREFIX . "deal_load_repay where  has_repay = 1 ");
     $stats['total_rate'] += $GLOBALS['db']->getOne("SELECT sum(rebate_money) FROM " . DB_PREFIX . "deal_load where  is_has_loans = 1 ");
     //加上返利
     $stats['total_rate'] -= $GLOBALS['db']->getOne("SELECT sum(fee_amount) FROM " . DB_PREFIX . "payment_notice WHERE  is_paid =1  ");
     //减去充值手续费
     $stats['total_rate'] -= $GLOBALS['db']->getOne("SELECT sum(fee) FROM " . DB_PREFIX . "user_carry WHERE status =1  ");
     //减去提现手续费
     $stats['total_rate'] += $GLOBALS['db']->getOne("SELECT sum(money) FROM " . DB_PREFIX . "referrals WHERE pay_time >0  ");
     //加上邀请返利
     $stats['total_rate_format'] = format_conf_count(number_format($stats['total_rate'], 2));
     //本息保证金(元)
     $stats['total_bzh'] = $GLOBALS['db']->getOne("SELECT sum(guarantor_real_freezen_amt+real_freezen_amt) FROM " . DB_PREFIX . "deal where deal_status= 4 ");
     $stats['total_bzh_format'] = format_conf_count(number_format($stats['total_bzh'], 2));
     //待收资金(元)
     $stats['total_repay'] = $GLOBALS['db']->getOne("SELECT sum(repay_money) FROM " . DB_PREFIX . "deal_load_repay where has_repay = 1 ");
     $stats['total_repay_format'] = format_conf_count(number_format($stats['total_repay'], 2));
     //待投资金(元)
     $statsU = $GLOBALS['db']->getRow("SELECT sum(money) as total_usermoney ,count(*) total_user FROM " . DB_PREFIX . "user where is_effect = 1 and is_delete=0 ");
     $stats['total_usermoney'] = $statsU['total_usermoney'];
     $stats['total_usermoney_format'] = format_conf_count(number_format($stats['total_usermoney'], 2));
     $stats['total_user'] = $statsU['total_user'];
     $GLOBALS['tmpl']->assign("stats", $stats);
     $root['virtual_money_1'] = strip_tags($GLOBALS['db_conf']['VIRTUAL_MONEY_1'] + $stats['total_load']);
     //虚拟的累计成交额;
     $root['virtual_money_2'] = strip_tags($GLOBALS['db_conf']['VIRTUAL_MONEY_2'] + $stats['total_rate']);
     //虚拟的累计创造收益;
     $root['virtual_money_3'] = strip_tags($GLOBALS['db_conf']['VIRTUAL_MONEY_3'] + $stats['total_bzh']);
     //虚拟的本息保障金;
     $index_list = $GLOBALS['cache']->get("MOBILE_INDEX_ADVS");
     if (true || $index_list === false) {
         $advs = $GLOBALS['db']->getAll(" select * from " . DB_PREFIX . "m_adv where status = 1 order by sort desc ");
         $adv_list = array();
         $deal_list = array();
         $condition = "-1";
         foreach ($advs as $k => $v) {
             if ($v['page'] == 'top') {
                 /*
                 $adv_list[]['id'] = $v['id'];
                 $adv_list[]['name'] = $v['name'];
                 if ($v['page'] == 'top' && $v['img'] != ''){
                 	$adv_list[]['img'] = get_abs_img_root(get_spec_image($v['img'],640,240,1));
                 }else{
                 	$adv_list[]['img'] = '';
                 }
                 $adv_list[]['type'] = $v['type'];
                 $adv_list[]['open_url_type'] = $v['open_url_type'];
                 $adv_list[]['data'] = $v['data'];
                 */
                 if ($v['img'] != '') {
                     $v['img'] = get_abs_img_root(get_spec_image($v['img'], 640, 240, 1));
                 }
                 $adv_list[] = $v;
             } else {
                 /*
                 $deal_list[]['id'] = $v['id'];
                 $deal_list[]['name'] = $v['name'];					
                 $deal_list[]['img'] = '';					
                 $deal_list[]['type'] = $v['type'];
                 $deal_list[]['open_url_type'] = $v['open_url_type'];
                 $deal_list[]['data'] = $v['data'];
                 */
                 //$v['img'] = '';
                 //$deal_list[] = $v;
                 $condition .= "," . intval($v['data']);
             }
         }
         //$condition = " id in (".$condition.")";
         //publish_wait 0:已审核 1:等待审核;deal_status 0待等材料,1进行中,2满标,3流标,4还款中,5已还清
         $condition = " publish_wait = 0 AND deal_status in (1,2,4,5)";
         require APP_ROOT_PATH . 'app/Lib/deal.php';
         $limit = "0,5";
         $orderby = "deal_status ASC,sort DESC,id DESC";
         //print_r($limit);
         //print_r($condition);
         $result = get_deal_list($limit, 0, $condition, $orderby);
         $index_list['adv_list'] = $adv_list;
         $index_list['deal_list'] = $result['list'];
         $GLOBALS['cache']->set("MOBILE_INDEX_ADVS", $index_list);
     }
     $root['index_list'] = $index_list;
     $root['deal_cate_list'] = getDealCateArray();
     //分类
     if (strim($GLOBALS['m_config']['sina_app_key']) != "" && strim($GLOBALS['m_config']['sina_app_secret']) != "") {
         $root['api_sina'] = 1;
         $root['sina_app_key'] = $GLOBALS['m_config']['sina_app_key'];
         $root['sina_app_secret'] = $GLOBALS['m_config']['sina_app_secret'];
         $root['sina_bind_url'] = $GLOBALS['m_config']['sina_bind_url'];
     }
     if (strim($GLOBALS['m_config']['tencent_app_key']) != "" && strim($GLOBALS['m_config']['tencent_app_secret']) != "") {
         $root['api_tencent'] = 1;
         $root['tencent_app_key'] = $GLOBALS['m_config']['tencent_app_key'];
         $root['tencent_app_secret'] = $GLOBALS['m_config']['tencent_app_secret'];
         $root['tencent_bind_url'] = $GLOBALS['m_config']['tencent_bind_url'];
     }
     output($root);
 }
Example #22
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);
 }
Example #23
0
 public function store()
 {
     global_run();
     init_app_page();
     $id = intval($_REQUEST['id']);
     $type = intval($_REQUEST['type']);
     //0主表 1提交表
     require_once APP_ROOT_PATH . "system/model/supplier.php";
     if ($type == 0) {
         $store_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "supplier_location where id = " . $id);
         if ($store_info) {
             //开始输出商户图库数据json
             $store_images = $GLOBALS['db']->getAll("select brief,image from " . DB_PREFIX . "supplier_location_images where supplier_location_id = " . $store_info['id'] . " and status = 1 order by sort limit " . MAX_SP_IMAGE);
             foreach ($store_images as $k => $v) {
                 $store_images[$k]['image'] = format_image_path(get_spec_image($v['image'], 600, 450, 1));
             }
             $GLOBALS['tmpl']->assign("store_images_json", json_encode($store_images));
             $GLOBALS['tmpl']->assign("store_images_count", count($store_images));
         }
     } else {
         $store_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "supplier_location_biz_submit where id = " . $id);
         if ($store_info) {
             //开始输出商户图库数据json
             $store_images_rs = unserialize($store_info['cache_supplier_location_images']);
             foreach ($store_images_rs as $k => $v) {
                 $store_images[$k]['image'] = format_image_path(get_spec_image($v, 600, 450, 1));
             }
             $GLOBALS['tmpl']->assign("store_images_json", json_encode($store_images));
             $GLOBALS['tmpl']->assign("store_images_count", count($store_images));
         }
     }
     if ($store_info) {
         if (!$this->is_manage()) {
             $account_info = es_session::get('account_info');
             if ($store_info['supplier_id'] != $account_info['supplier_id']) {
                 app_redirect(url("index"));
             }
         }
         $store_info['good_rate_precent'] = round($store_info['good_rate'] * 100, 1);
         $store_info['ref_avg_price'] = round($store_info['ref_avg_price'], 2);
         $store_info['brief'] = format_html_content_image($store_info['brief'], 720);
         $GLOBALS['tmpl']->assign("store_info", $store_info);
         //关于分类信息与seo
         $page_title = "";
         $page_keyword = "";
         $page_description = "";
         $page_title .= $store_info['name'];
         $page_keyword .= $store_info['name'] . ",";
         $page_description .= $store_info['name'] . ",";
         $site_nav[] = array('name' => $GLOBALS['lang']['HOME_PAGE'], 'url' => url("index"));
         if ($store_info['deal_cate_id']) {
             $store_info['cate_name'] = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "deal_cate where id = " . $store_info['deal_cate_id']);
             $store_info['cate_url'] = url("index", "stores", array("cid" => $store_info['deal_cate_id']));
         }
         if ($store_info['cate_name']) {
             $page_title .= " - " . $store_info['cate_name'];
             $page_keyword .= $store_info['cate_name'] . ",";
             $page_description .= $store_info['cate_name'] . ",";
             $site_nav[] = array('name' => $store_info['cate_name'], 'url' => $store_info['cate_url']);
         }
         $site_nav[] = array('name' => $store_info['name'], 'url' => $store_info['url']);
         $GLOBALS['tmpl']->assign("site_nav", $site_nav);
         if ($store_info['seo_title']) {
             $page_title = $store_info['seo_title'];
         }
         if ($store_info['seo_keyword']) {
             $page_keyword = $store_info['seo_keyword'];
         }
         if ($store_info['seo_description']) {
             $page_description = $store_info['seo_description'];
         }
         $GLOBALS['tmpl']->assign("page_title", $page_title);
         $GLOBALS['tmpl']->assign("page_keyword", $page_keyword);
         $GLOBALS['tmpl']->assign("page_description", $page_description);
     } else {
         app_redirect_preview();
     }
     $GLOBALS['tmpl']->assign("preview", true);
     $GLOBALS['tmpl']->display("store.html");
 }
Example #24
0
 public function index2()
 {
     $quan_id = intval($GLOBALS['request']['quan_id']);
     //商圈ID
     $city_id = intval($GLOBALS['request']['city_id']);
     $city_name = strim($GLOBALS['request']['city_name']);
     //城市分类ID
     //print_r($GLOBALS['request']);
     $root = array();
     $root['return'] = 1;
     $city_list = $GLOBALS['db']->getAll("select *from " . DB_PREFIX . "deal_city where is_effect=1 and is_delete=0 order by id asc");
     $root['city_list'] = $city_list;
     if ($city_id > 0) {
         /*当前城市商圈*/
         $indexs_quan = $GLOBALS['cache']->get("MOBILE_INDEX2_QUAN_" . intval($GLOBALS['city_id']));
         if ($indexs_quan === false) {
             $indexs_quan = $GLOBALS['db']->getAll("select id,name from " . DB_PREFIX . "area where pid=0 and city_id=" . $city_id . " order by sort desc");
         }
         if ($indexs_quan) {
             $root['quans'] = $indexs_quan;
         } else {
             $root['quans'] = array();
         }
         $root['quan_id'] = $quan_id;
         /*城市列表*/
         /*当前城市热门团购(正在团购 的推荐商品)*/
         $time = get_gmtime();
         $condition = " is_effect = 1 and is_delete = 0 and is_shop = 0 and (" . $time . ">= begin_time or begin_time = 0) and (" . $time . "< end_time or end_time = 0) and buy_status <> 2";
         if ($city_id == 0) {
             $city = get_current_deal_city();
             $city_id = $city['id'];
         }
         if ($city_id > 0) {
             $ids = load_auto_cache("deal_city_belone_ids", array("city_id" => $city_id));
             if ($ids) {
                 $condition .= " and city_id in (" . implode(",", $ids) . ")";
             }
         }
         if ($quan_id > 0) {
             $ids = load_auto_cache("deal_quan_ids", array("quan_id" => $quan_id));
             $quan_list = $GLOBALS['db']->getAll("select `name` from " . DB_PREFIX . "area where id in (" . implode(",", $ids) . ")");
             $unicode_quans = array();
             foreach ($quan_list as $k => $v) {
                 $unicode_quans[] = str_to_unicode_string($v['name']);
             }
             $kw_unicode = implode(" ", $unicode_quans);
             $condition .= " and (match(locate_match) against('" . $kw_unicode . "' IN BOOLEAN MODE))";
         }
         $sql = "select id,name,sub_name,icon,origin_price,current_price,buy_count from " . DB_PREFIX . "deal where " . $condition . " order by is_recommend desc,sort desc limit 20";
         $deal_list = $GLOBALS['db']->getAll($sql);
         $taday_begin = to_timespan(to_date(get_gmtime(), 'Y-m-d'));
         $taday_end = $taday_begin * 24 * 60 * 60;
         foreach ($deal_list as $k => $v) {
             $deal_list[$k]['current_price'] = round($v['current_price'], 2);
             $deal_list[$k]['origin_price'] = round($v['origin_price'], 2);
             $deal_list[$k]['icon'] = get_abs_img_root(get_spec_image($v['icon'], 300, 181, 0));
             if ($v['begin_time'] > 0 && ($taday_begin < $v['begin_time'] && $v['begin_time'] < $taday_end)) {
                 $deal_list[$k]['is_taday'] = 1;
             } else {
                 if ($v['begin_time'] == 0 && ($taday_begin < $v['create_time'] && $v['create_time'] < $taday_end)) {
                     $deal_list[$k]['is_taday'] = 1;
                 } else {
                     $deal_list[$k]['is_taday'] = 0;
                 }
             }
             unset($deal_list[$k]['begin_time'], $deal_list[$k]['create_time']);
         }
         if ($deal_list) {
             $root['deal_list'] = $deal_list;
         } else {
             $root['deal_list'] = array();
         }
     } else {
         $root['quans'] = array();
         $root['quan_id'] = 0;
         $root['deal_list'] = array();
     }
     $root['city_name'] = $city_name;
     $root['page_title'] = "选择城市";
     output($root);
 }
Example #25
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);
 }
Example #26
0
 public function index()
 {
     $root = array();
     $root['return'] = 1;
     $adv_list = $GLOBALS['cache']->get("MOBILE_INDEX_ADVS_" . intval($GLOBALS['city_id']));
     if ($adv_list === false) {
         $advs = $GLOBALS['db']->getAll(" select * from " . DB_PREFIX . "m_adv where page = 'index' and city_id in (0," . intval($GLOBALS['city_id']) . ") and status = 1 order by sort desc ");
         $adv_list = array();
         foreach ($advs as $k => $v) {
             $adv_list[$k]['id'] = $v['id'];
             $adv_list[$k]['name'] = $v['name'];
             $adv_list[$k]['img'] = get_abs_img_root(get_spec_image($v['img'], 640, 240, 1));
             $adv_list[$k]['type'] = $v['type'];
             $adv_list[$k]['data'] = $v['data'] = unserialize($v['data']);
             if ($v['type'] == 1) {
                 $tag_count = count($v['data']['tags']);
                 $adv_list[$k]['data']['count'] = $tag_count;
             }
             if (in_array($v['type'], array(9, 10, 11, 12, 13))) {
                 if ($v['type'] == 9 || $v['type'] == 12 || $v['type'] == 13) {
                     $adv_list[$k]['data']['cate_name'] = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "deal_cate where id = " . intval($v['data']['cate_id']));
                 } elseif ($v['type'] == 10) {
                     $adv_list[$k]['data']['cate_name'] = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "shop_cate where id = " . intval($v['data']['cate_id']));
                 } elseif ($v['type'] == 11) {
                     $adv_list[$k]['data']['cate_name'] = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "event_cate where id = " . intval($v['data']['cate_id']));
                 }
                 $adv_list[$k]['data']['cate_name'] = $adv_list[$k]['data']['cate_name'] ? $adv_list[$k]['data']['cate_name'] : "全部";
             }
         }
         $GLOBALS['cache']->set("MOBILE_INDEX_ADVS_" . intval($GLOBALS['city_id']), $adv_list);
     }
     $root['advs'] = $adv_list;
     $indexs_list = $GLOBALS['cache']->get("MOBILE_INDEX_INDEX_" . intval($GLOBALS['city_id']));
     if ($indexs_list === false) {
         $indexs = $GLOBALS['db']->getAll(" select * from " . DB_PREFIX . "m_index where status = 1 and city_id in (0," . intval($GLOBALS['city_id']) . ") order by sort desc ");
         $indexs_list = array();
         foreach ($indexs as $k => $v) {
             $indexs_list[$k]['id'] = $v['id'];
             $indexs_list[$k]['name'] = $v['name'];
             $indexs_list[$k]['vice_name'] = $v['vice_name'];
             $indexs_list[$k]['desc'] = $v['desc'];
             $indexs_list[$k]['is_hot'] = $v['is_hot'];
             $indexs_list[$k]['is_new'] = $v['is_new'];
             $indexs_list[$k]['img'] = get_abs_img_root(get_spec_image($v['img'], 640, 120, 1));
             $indexs_list[$k]['type'] = $v['type'];
             $indexs_list[$k]['data'] = $v['data'] = unserialize($v['data']);
             if ($v['type'] == 1) {
                 $tag_count = count($v['data']['tags']);
                 $indexs_list[$k]['data']['count'] = $tag_count;
             }
             if (in_array($v['type'], array(9, 10, 11, 12, 13))) {
                 if ($v['type'] == 9 || $v['type'] == 12 || $v['type'] == 13) {
                     $indexs_list[$k]['data']['cate_name'] = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "deal_cate where id = " . intval($v['data']['cate_id']));
                 } elseif ($v['type'] == 10) {
                     $indexs_list[$k]['data']['cate_name'] = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "shop_cate where id = " . intval($v['data']['cate_id']));
                 } elseif ($v['type'] == 11) {
                     $indexs_list[$k]['data']['cate_name'] = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "event_cate where id = " . intval($v['data']['cate_id']));
                 }
                 $indexs_list[$k]['data']['cate_name'] = $indexs_list[$k]['data']['cate_name'] ? $indexs_list[$k]['data']['cate_name'] : "全部";
             }
         }
         $GLOBALS['cache']->set("MOBILE_INDEX_INDEX_" . intval($GLOBALS['city_id']), $indexs_list);
     }
     $root['indexs'] = $indexs_list;
     output($root);
 }
Example #27
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);
 }
Example #28
0
 public function index()
 {
     $root = array();
     $root['response_code'] = 1;
     $root['kf_phone'] = $GLOBALS['m_config']['kf_phone'];
     //客服电话
     $root['kf_email'] = $GLOBALS['m_config']['kf_email'];
     //客服邮箱
     //$pattern = "/<img([^>]*)\/>/i";
     //$replacement = "<img width=300 $1 />";
     //$goods['goods_desc'] = preg_replace($pattern, $replacement, get_abs_img_root($goods['goods_desc']));
     //关于我们(填文章ID)
     $root['about_info'] = intval($GLOBALS['m_config']['about_info']);
     $root['version'] = VERSION;
     //接口版本号int
     $root['page_size'] = PAGE_SIZE;
     //默认分页大小
     $root['program_title'] = $GLOBALS['m_config']['program_title'];
     $root['site_domain'] = str_replace("/mapi", "", SITE_DOMAIN . APP_ROOT);
     //站点域名;
     $root['site_domain'] = str_replace("http://", "", $root['site_domain']);
     //站点域名;
     $root['site_domain'] = str_replace("https://", "", $root['site_domain']);
     //站点域名;
     //$root['newslist'] = $GLOBALS['m_config']['newslist'];
     /*虚拟的累计项目总个数,支持总人数,项目支持总金额*/
     $virtual_effect = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal where is_effect = 1 and is_delete=0");
     $virtual_person = $GLOBALS['db']->getOne("select sum((support_count+virtual_person)) from " . DB_PREFIX . "deal_item");
     $virtual_money = $GLOBALS['db']->getOne("select sum((support_count+virtual_person)*price) from " . DB_PREFIX . "deal_item");
     $root['virtual_effect'] = $virtual_effect;
     //项目总个数
     $root['virtual_person'] = $virtual_person;
     //累计支持人
     $root['virtual_money'] = number_format($virtual_money, 2);
     //筹资总金额
     /*虚拟的累计项目总个数,支持总人数,项目支持总金额 结束*/
     /*首页广告*/
     $adv_num = intval($GLOBALS['m_config']['adv_num']) ? $GLOBALS['m_config']['adv_num'] : 5;
     $index_list = $GLOBALS['db']->getAll(" select * from " . DB_PREFIX . "m_adv where status = 1 order by sort asc limit 0,{$adv_num}");
     $adv_list = array();
     foreach ($index_list as $k => $v) {
         if ($v['page'] == 'top') {
             if ($v['img'] != '') {
                 $v['img'] = get_abs_img_root(get_spec_image($v['img'], 640, 240, 1));
             }
             $adv_list[] = $v;
         }
     }
     $root['adv_list'] = $adv_list;
     /*项目显示以及权限控制*/
     //===============首页项目列表START===================
     $page_size = $GLOBALS['m_config']['page_size'];
     $page = intval($_REQUEST['p']);
     //		if($page==0)$page = 1;
     //		$limit = (($page-1)*$page_size).",".$page_size	;
     $limit = "";
     $index_pro_num = $GLOBALS['m_config']['index_pro_num'];
     if ($index_pro_num > 0) {
         $limit = " limit 0,{$index_pro_num}";
     }
     $GLOBALS['tmpl']->assign("current_page", $page);
     //权限控制
     $condition = " is_delete = 0 and is_effect = 1 ";
     if ($GLOBALS['user_info']['user_level'] != 0) {
         $condition .= " AND (user_level <=" . $GLOBALS['user_info']['user_level'] . ") AND is_recommend='1'";
     } else {
         $condition .= " AND (user_level =0 or user_level =1 or user_level ='') AND is_recommend='1'";
     }
     $now_time = get_gmtime();
     $deal_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal where " . $condition . " order by sort asc  " . $limit);
     $deal_count = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal where " . $condition);
     foreach ($deal_list as $k => $v) {
         $deal_list[$k]['image'] = get_abs_img_root(get_spec_image($v['image'], 640, 240, 1));
         $deal_list[$k]['end_time'] = to_date($v['end_time'], 'Y-m-d');
         $deal_list[$k]['begin_time'] = to_date($v['begin_time'], 'Y-m-d');
         $deal_list[$k]['create_time'] = to_date($v['create_time'], 'Y-m-d');
         $deal_list[$k]['content'] = $v['description'];
         $deal_list[$k]['deal_extra_cache'] = null;
         if ($v['end_time'] > 0 && $v['end_time'] > $now_time) {
             $deal_list[$k]['remain_days'] = floor(($v['end_time'] - $now_time) / (24 * 3600));
         } elseif ($v['end_time'] > 0 && $v['end_time'] <= $now_time) {
             $deal_list[$k]['remain_days'] = 0;
         }
         $deal_list[$k]['percent'] = round($v['support_amount'] / $v['limit_price'] * 100);
         $deal_list[$k]['num_days'] = floor(($v['end_time'] - $v['begin_time']) / (24 * 3600));
         if ($v['begin_time'] > $now_time) {
             $deal_list[$k]['left_days'] = intval(($v['begin_time'] - $now_time) / 24 / 3600);
         } else {
             $deal_list[$k]['left_days'] = 0;
         }
         //$deal_list[$k]['status']值0表示即将开始;1表示已成功;2表示筹资失败;3表示筹资中;4表示长期项目
         if ($v['begin_time'] > $now_time) {
             $deal_list[$k]['status'] = '0';
         } elseif ($v['end_time'] < $now_time && $v['end_time'] > 0) {
             if ($deal_list[$k]['percent'] >= 100) {
                 $deal_list[$k]['status'] = '1';
             } else {
                 if ($deal_list[$k]['percent'] >= 0) {
                     $deal_list[$k]['status'] = '2';
                 }
             }
         } else {
             if ($v['end_time'] > 0) {
                 if ($deal_list[$k]['percent'] >= 100) {
                     $deal_list[$k]['status'] = '1';
                 } else {
                     $deal_list[$k]['status'] = '3';
                 }
             } else {
                 $deal_list[$k]['status'] = '4';
             }
         }
     }
     $root['deal_count'] = $deal_count;
     $root['deal_list'] = $deal_list;
     //$root['deal_cate_list'] = getDealCateArray();//分类
     $root['page'] = array("page" => $page, "page_total" => ceil($deal_count / $page_size), "page_size" => intval($page_size), 'total' => intval($deal_count));
     output($root);
 }
Example #29
0
 public function index()
 {
     $root = array();
     $root['response_code'] = 1;
     //print_r($GLOBALS['db_conf']); exit;
     $root['kf_phone'] = $GLOBALS['m_config']['kf_phone'];
     //客服电话
     $root['kf_email'] = $GLOBALS['m_config']['kf_email'];
     //客服邮箱
     //$pattern = "/<img([^>]*)\/>/i";
     //$replacement = "<img width=300 $1 />";
     //$goods['goods_desc'] = preg_replace($pattern, $replacement, get_abs_img_root($goods['goods_desc']));
     //关于我们(填文章ID)
     $root['about_info'] = intval($GLOBALS['m_config']['about_info']);
     $root['version'] = VERSION;
     //接口版本号int
     $root['page_size'] = PAGE_SIZE;
     //默认分页大小
     $root['program_title'] = $GLOBALS['m_config']['program_title'];
     $root['site_domain'] = str_replace("/mapi", "", SITE_DOMAIN . APP_ROOT);
     //站点域名;
     $root['site_domain'] = str_replace("http://", "", $root['site_domain']);
     //站点域名;
     $root['site_domain'] = str_replace("https://", "", $root['site_domain']);
     //站点域名;
     //$root['newslist'] = $GLOBALS['m_config']['newslist'];
     $root['virtual_money_1'] = strip_tags($GLOBALS['db_conf']['VIRTUAL_MONEY_1']);
     //虚拟的累计成交额;
     $root['virtual_money_2'] = strip_tags($GLOBALS['db_conf']['VIRTUAL_MONEY_2']);
     //虚拟的累计创造收益;
     $root['virtual_money_3'] = strip_tags($GLOBALS['db_conf']['VIRTUAL_MONEY_3']);
     //虚拟的本息保障金;
     $index_list = $GLOBALS['cache']->get("MOBILE_INDEX_ADVS");
     if (true || $index_list === false) {
         $advs = $GLOBALS['db']->getAll(" select * from " . DB_PREFIX . "m_adv where status = 1 order by sort desc ");
         $adv_list = array();
         $deal_list = array();
         $condition = "-1";
         foreach ($advs as $k => $v) {
             if ($v['page'] == 'top') {
                 /*
                 $adv_list[]['id'] = $v['id'];
                 $adv_list[]['name'] = $v['name'];
                 if ($v['page'] == 'top' && $v['img'] != ''){
                 	$adv_list[]['img'] = get_abs_img_root(get_spec_image($v['img'],640,240,1));
                 }else{
                 	$adv_list[]['img'] = '';
                 }
                 $adv_list[]['type'] = $v['type'];
                 $adv_list[]['open_url_type'] = $v['open_url_type'];
                 $adv_list[]['data'] = $v['data'];
                 */
                 if ($v['img'] != '') {
                     $v['img'] = get_abs_img_root(get_spec_image($v['img'], 640, 240, 1));
                 }
                 $adv_list[] = $v;
             } else {
                 /*
                 $deal_list[]['id'] = $v['id'];
                 $deal_list[]['name'] = $v['name'];					
                 $deal_list[]['img'] = '';					
                 $deal_list[]['type'] = $v['type'];
                 $deal_list[]['open_url_type'] = $v['open_url_type'];
                 $deal_list[]['data'] = $v['data'];
                 */
                 //$v['img'] = '';
                 //$deal_list[] = $v;
                 $condition .= "," . intval($v['data']);
             }
         }
         $condition = " id in (" . $condition . ")";
         require APP_ROOT_PATH . 'app/Lib/deal.php';
         $limit = "0,20";
         $orderby = "deal_status ASC,success_time DESC,sort DESC,id DESC";
         //print_r($limit);
         //print_r($condition);
         $result = get_deal_list($limit, 0, $condition, $orderby);
         $index_list['adv_list'] = $adv_list;
         $index_list['deal_list'] = $result['list'];
         $GLOBALS['cache']->set("MOBILE_INDEX_ADVS", $index_list);
     }
     $root['index_list'] = $index_list;
     $root['deal_cate_list'] = getDealCateArray();
     //分类
     if (strim($GLOBALS['m_config']['sina_app_key']) != "" && strim($GLOBALS['m_config']['sina_app_secret']) != "") {
         $root['api_sina'] = 1;
         $root['sina_app_key'] = $GLOBALS['m_config']['sina_app_key'];
         $root['sina_app_secret'] = $GLOBALS['m_config']['sina_app_secret'];
         $root['sina_bind_url'] = $GLOBALS['m_config']['sina_bind_url'];
     }
     if (strim($GLOBALS['m_config']['tencent_app_key']) != "" && strim($GLOBALS['m_config']['tencent_app_secret']) != "") {
         $root['api_tencent'] = 1;
         $root['tencent_app_key'] = $GLOBALS['m_config']['tencent_app_key'];
         $root['tencent_app_secret'] = $GLOBALS['m_config']['tencent_app_secret'];
         $root['tencent_bind_url'] = $GLOBALS['m_config']['tencent_bind_url'];
     }
     output($root);
 }
Example #30
0
 public function index()
 {
     $root = array();
     $root['return'] = 1;
     $catalog_id = intval($GLOBALS['request']['cate_id']);
     //商品分类ID
     $cata_type_id = intval($GLOBALS['request']['cata_type_id']);
     //商品二级分类
     $city_id = intval($GLOBALS['request']['city_id']);
     $quan_id = intval($GLOBALS['request']['quan_id']);
     $cate_id = intval($GLOBALS['request']['cate_id']);
     $keyword = strim($GLOBALS['request']['keyword']);
     $city_name = strim($GLOBALS['request']['city_name']);
     //城市名称
     $order_type = $GLOBALS['request']['order_type'];
     $ytop = $latitude_top = floatval($GLOBALS['request']['latitude_top']);
     //最上边纬线值 ypoint
     $ybottom = $latitude_bottom = floatval($GLOBALS['request']['latitude_bottom']);
     //最下边纬线值 ypoint
     $xleft = $longitude_left = floatval($GLOBALS['request']['longitude_left']);
     //最左边经度值  xpoint
     $xright = $longitude_right = floatval($GLOBALS['request']['longitude_right']);
     //最右边经度值 xpoint
     $m_distance = doubleval($GLOBALS['request']['m_distance']);
     //范围(米)
     $ypoint = $m_latitude = doubleval($GLOBALS['request']['m_latitude']);
     //ypoint
     $xpoint = $m_longitude = doubleval($GLOBALS['request']['m_longitude']);
     //xpoint
     /*输出分类*/
     $bcate_list = getCateList();
     $url_param['quan_id'] = $quan_id;
     $url_param['catalog_id'] = $catalog_id;
     $url_param['cata_type_id'] = $cata_type_id;
     foreach ($bcate_list as $k => $v) {
         $tmp_url_param = $url_param;
         unset($tmp_url_param['catalog_id']);
         $tmp_url_param['catalog_id'] = $v['id'];
         $tmp_url_param['catename'] = $v['name'];
         if ($quan_id > 0) {
             $quanname = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "area where id=" . $quan_id);
             $tmp_url_param['quanname'] = $quanname;
         } else {
             $tmp_url_param['quanname'] = "全城";
         }
         $turl = url("index", "tuanlist", $tmp_url_param);
         $url = str_replace('sjmapi', 'wap', $turl);
         $bcate_list[$k]["url"] = $url;
         foreach ($v['bcate_type'] as $kk => $vv) {
             $tmp_url_param = $url_param;
             unset($tmp_url_param['cata_type_id']);
             $tmp_url_param['cata_type_id'] = $vv["id"];
             $tmp_url_param['catename'] = $vv['name'];
             $tmp_url_param['catalog_id'] = $vv['cate_id'];
             if ($quan_id > 0) {
                 $quanname = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "area  where id=" . $quan_id);
                 $tmp_url_param['quanname'] = $quanname;
             } else {
                 $tmp_url_param['quanname'] = "全城";
             }
             $turl = url("index", "tuanlist", $tmp_url_param);
             $url = str_replace('sjmapi', 'wap', $turl);
             $bcate_list[$k]["bcate_type"][$kk]["url"] = $url;
         }
     }
     /*输出分类
     		$bcate_list = getCateList();
     		$url_param['quan_id'] = $quan_id;
     		$url_param['cate_id'] = $cate_id;
     		
     		$catalog_id = $cate_id;
     		
     		foreach($bcate_list as $k=>$v)
     		{
     			if($catalog_id==$v['id'])
     			{
     				$bcate_list['bcate_type'][$k]['act'] = 1;
     			}
     			$tmp_url_param = $url_param;
     			unset($tmp_url_param['cate_id']);
     			$tmp_url_param['cate_id']=$v['id'];
     			$tmp_url_param['catename']=$v['name'];
     			if($quan_id>0){
     				$quanname=$GLOBALS['db']->getOne("select name from ".DB_PREFIX."area where id=".$quan_id);
     				$tmp_url_param['quanname']=$quanname;
     			}else{
     				$tmp_url_param['quanname']="全城";
     			}
     			$turl = url("index","youhuilist",$tmp_url_param);
     			$url=str_replace('sjmapi','wap', $turl);
     			$bcate_list[$k]["url"]=$url;
     				
     			foreach($v['bcate_type'] as $kk=>$vv){
     				if($catalog_id==$vv['id'])
     				{
     					$bcate_list['bcate_type'][$kk]['act'] = 1;
     				}
     				$tmp_url_param = $url_param;
     				unset($tmp_url_param['cate_id']);
     				$tmp_url_param['cate_id']=$vv['id'];
     				$tmp_url_param['catename']=$vv['name'];
     				if($quan_id>0){
     					$quanname=$GLOBALS['db']->getOne("select name from ".DB_PREFIX."area  where id=".$quan_id);
     					$tmp_url_param['quanname']=$quanname;
     				}else{
     					$tmp_url_param['quanname']="全城";
     				}
     				$turl = url("index","youhuilist",$tmp_url_param);
     				$url=str_replace('sjmapi','wap', $turl);
     				$bcate_list[$k]["bcate_type"][$kk]["url"]=$url;
     			}
     				
     		
     		}
     		*/
     /*输出商圈*/
     $quan_list = getQuanList($city_id);
     foreach ($quan_list as $k => $v) {
         /*
         if($catalog_id==$v['id'])
         {
         	$quan_list['bcate_type'][$k]['act'] = 1;
         }
         */
         $tmp_url_param = $url_param;
         unset($tmp_url_param['quan_id']);
         $tmp_url_param['quan_id'] = $v['id'];
         $tmp_url_param['quanname'] = $v['name'];
         if ($catalog_id > 0) {
             $catename = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "deal_cate  where id=" . $catalog_id);
             $tmp_url_param['catename'] = $catename;
         } else {
             $tmp_url_param['catename'] = "全部分类";
         }
         $turl = url("index", "youhuilist", $tmp_url_param);
         $url = str_replace('sjmapi', 'wap', $turl);
         $quan_list[$k]["url"] = $url;
         foreach ($v['quan_sub'] as $kk => $vv) {
             /*
             if($catalog_id==$vv['id'])
             {
             	$quan_list['quan_sub'][$kk]['act'] = 1;
             }
             */
             $tmp_url_param = $url_param;
             unset($tmp_url_param['quan_id']);
             $tmp_url_param['quan_id'] = $vv['id'];
             $tmp_url_param['quanname'] = $vv['name'];
             if ($catalog_id > 0) {
                 $catename = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "deal_cate  where id=" . $catalog_id);
                 $tmp_url_param['catename'] = $catename;
             } else {
                 $tmp_url_param['catename'] = "全部分类";
             }
             $turl = url("index", "youhuilist", $tmp_url_param);
             $url = str_replace('sjmapi', 'wap', $turl);
             $quan_list[$k]["quan_sub"][$kk]["url"] = $url;
         }
     }
     $page = intval($GLOBALS['request']['page']);
     //分页
     $page = $page == 0 ? 1 : $page;
     $page_size = PAGE_SIZE;
     $limit = ($page - 1) * $page_size . "," . $page_size;
     $pi = 3.14159265;
     //圆周率
     $r = 6378137;
     //地球平均半径(米)
     $sql_count = "select count(*) from " . DB_PREFIX . "youhui ";
     $sql = "select id,supplier_id as merchant_id,begin_time,youhui_type,total_num,end_time,name as title,list_brief as content,icon as merchant_logo,create_time,xpoint,ypoint,address as api_address,icon as image_1,\n\t\t\t\t (ACOS(SIN(({$ypoint} * {$pi}) / 180 ) *SIN((ypoint * {$pi}) / 180 ) +COS(({$ypoint} * {$pi}) / 180 ) * COS((ypoint * {$pi}) / 180 ) *COS(({$xpoint} * {$pi}) / 180 - (xpoint * {$pi}) / 180 ) ) * {$r}) as distance  \n\t\t\t\tfrom " . DB_PREFIX . "youhui ";
     $now = get_gmtime();
     $where = "1 = 1 and is_effect = 1 and begin_time<" . $now . " and (end_time = 0 or end_time > " . $now . ")";
     if ($city_id > 0) {
         $ids = load_auto_cache("deal_city_belone_ids", array("city_id" => $city_id));
         if ($ids) {
             $where .= " and city_id in (" . implode(",", $ids) . ")";
         }
     }
     if ($quan_id > 0) {
         $ids = load_auto_cache("deal_quan_ids", array("quan_id" => $quan_id));
         $quan_list2 = $GLOBALS['db']->getAll("select `name` from " . DB_PREFIX . "area where id in (" . implode(",", $ids) . ")");
         $unicode_quans = array();
         foreach ($quan_list2 as $k => $v) {
             $unicode_quans[] = str_to_unicode_string($v['name']);
         }
         $kw_unicode = implode(" ", $unicode_quans);
         $where .= " and (match(locate_match) against('" . $kw_unicode . "' IN BOOLEAN MODE)) ";
     }
     if ($cate_id > 0) {
         $where .= " and deal_cate_id = {$cate_id}";
     }
     if ($keyword) {
         $kws_div = div_str($keyword);
         foreach ($kws_div as $k => $item) {
             $kw[$k] = str_to_unicode_string($item);
         }
         $ukeyword = implode(" ", $kw);
         $where .= " and match(name_match) against('" . $ukeyword . "'  IN BOOLEAN MODE) or name like '%" . $keyword . "%' ";
     }
     $merchant_id = intval($GLOBALS['request']['merchant_id']);
     if ($merchant_id > 0) {
         $youhui_ids = $GLOBALS['db']->getOne("select group_concat(youhui_id) from " . DB_PREFIX . "youhui_location_link where location_id = " . $merchant_id);
         if ($youhui_ids) {
             $where .= " and id in (" . $youhui_ids . ") ";
         } else {
             $where .= " and id = 0 ";
         }
     }
     $sql_count .= " where " . $where;
     $sql .= " where " . $where;
     if ($xpoint > 0) {
         $orderby = " order by distance asc ";
     } else {
         $orderby = " order by sort desc,id desc";
     }
     /*排序*/
     if ($order_type == 'avg_point') {
         $orderby = " order by avg_point desc,id desc ";
     } elseif ($order_type == 'newest') {
         $orderby = " order by create_time desc,id desc ";
     } elseif ($order_type == 'buy_count') {
         $orderby = " order by view_count desc,id desc ";
     }
     $sql .= $orderby . " limit " . $limit;
     //echo $sql; exit;
     $total = $GLOBALS['db']->getOne($sql_count);
     $page_total = ceil($total / $page_size);
     $list = $GLOBALS['db']->getAll($sql);
     $youhui_list = array();
     foreach ($list as $item) {
         $youhui_list[] = m_youhuiItem($item);
     }
     foreach ($youhui_list as $k => $v) {
         $youhui_list[$k]['logo'] = get_abs_img_root(get_spec_image($v['logo'], 140, 85, 0));
     }
     /*输出分类*/
     //$bcate_list = getCateList();
     /*输出商圈*/
     //$quan_list=getQuanList($city_id);
     //print_r($quan_list);exit;
     if ($bcate_list === false) {
         $root['bcate_list'] = array();
     } else {
         $root['bcate_list'] = $bcate_list;
     }
     if ($quan_list === false) {
         $root['quan_list'] = array();
     } else {
         $root['quan_list'] = $quan_list;
     }
     $root['item'] = $youhui_list;
     $root['page'] = array("page" => $page, "page_total" => $page_total, "page_size" => $page_size);
     $root['page_title'] = "优惠券列表";
     //fwb 2014-08-27
     $root['city_name'] = $city_name;
     output($root);
 }