public function index() { init_app_page(); $s_account_info = $GLOBALS["account_info"]; $supplier_id = intval($s_account_info['supplier_id']); $name = strim($_REQUEST['name']); $begin_time = strim($_REQUEST['begin_time']); $end_time = strim($_REQUEST['end_time']); $begin_time_s = to_timespan($begin_time, "Y-m-d H:i"); $end_time_s = to_timespan($end_time, "Y-m-d H:i"); $condition = ""; if ($name != "") { $youhui_ids = $GLOBALS['db']->getRow("select group_concat(id SEPARATOR ',') as ids from " . DB_PREFIX . "youhui where name like '%" . $name . "%'"); $condition .= " and log.youhui_id in (" . $youhui_ids['ids'] . ") "; } if ($begin_time_s) { $condition .= " and log.create_time > " . $begin_time_s . " "; } if ($end_time_s) { $condition .= " and log.create_time < " . $end_time_s . " "; } $GLOBALS['tmpl']->assign("name", $name); $GLOBALS['tmpl']->assign("begin_time", $begin_time); $GLOBALS['tmpl']->assign("end_time", $end_time); //分页 $page_size = 15; $page = intval($_REQUEST['p']); if ($page == 0) { $page = 1; } $limit = ($page - 1) * $page_size . "," . $page_size; $list = $GLOBALS['db']->getAll("select distinct(log.id),log.* from " . DB_PREFIX . "youhui_log as log left join " . DB_PREFIX . "youhui_location_link as l on l.youhui_id = log.youhui_id where l.location_id in (" . implode(",", $s_account_info['location_ids']) . ") " . $condition . " order by log.create_time desc limit " . $limit); foreach ($list as $k => $v) { $list[$k]['user_name'] = load_user($v['user_id']); $list[$k]['user_name'] = $list[$k]['user_name']['user_name']; $youhui_info = load_auto_cache("youhui", array('id' => $v['youhui_id'])); $list[$k]['youhui_name'] = $youhui_info['name']; $location_info = load_auto_cache("store", array('id' => $v['location_id'])); $list[$k]['location_name'] = $location_info['name']; if ($list[$k]['expire_time'] != 0 && $list[$k]['expire_time'] < NOW_TIME) { $list[$k]['expire_time'] = "已过期"; } elseif ($list[$k]['expire_time'] == 0) { $list[$k]['expire_time'] = "永久有效"; } else { $list[$k]['expire_time'] = to_date($list[$k]['expire_time']); } $list[$k]['url'] = url('index', 'youhui#' . $v['youhui_id']); } $total = $GLOBALS['db']->getOne("select count(distinct(log.id)) from " . DB_PREFIX . "youhui_log as log left join " . DB_PREFIX . "youhui_location_link as l on l.youhui_id = log.youhui_id where l.location_id in (" . implode(",", $s_account_info['location_ids']) . ") " . $condition); $page = new Page($total, $page_size); //初始化分页对象 $p = $page->show(); $GLOBALS['tmpl']->assign('pages', $p); $GLOBALS['tmpl']->assign("list", $list); $GLOBALS['tmpl']->assign("head_title", "优惠券下载记录"); $GLOBALS['tmpl']->display("pages/youhuio/index.html"); }
public function index() { global_run(); init_app_page(); $GLOBALS['tmpl']->assign("no_nav", true); //无分类下拉 if (check_save_login() != LOGIN_STATUS_LOGINED) { app_redirect(url("index", "user#login")); } $GLOBALS['tmpl']->assign("page_title", "我的消息"); $user_info = $GLOBALS['user_info']; require_once APP_ROOT_PATH . "app/Lib/page.php"; $page_size = app_conf("PAGE_SIZE"); $page = intval($_REQUEST['p']); if ($page == 0) { $page = 1; } $limit = ($page - 1) * $page_size . "," . $page_size; $sql = "select * from " . DB_PREFIX . "msg_box where user_id = " . $GLOBALS['user_info']['id'] . " and is_delete = 0 order by create_time desc limit " . $limit; $sql_count = "select count(*) from " . DB_PREFIX . "msg_box where user_id = " . $GLOBALS['user_info']['id'] . " and is_delete = 0 "; $list = $GLOBALS['db']->getAll($sql); $ids[] = 0; foreach ($list as $k => $v) { $list[$k] = load_msg($v['type'], $v); $list[$k]['create_time'] = to_date($v['create_time']); $ids[] = $v['id']; } $count = $GLOBALS['db']->getOne($sql_count); $page = new Page($count, $page_size); //初始化分页对象 $p = $page->show(); $GLOBALS['tmpl']->assign('pages', $p); $GLOBALS['tmpl']->assign("list", $list); $ids_str = implode(",", $ids); $GLOBALS['db']->query("update " . DB_PREFIX . "msg_box set is_read = 1 where user_id = " . $GLOBALS['user_info']['id'] . " and id in (" . $ids_str . ")"); require_once APP_ROOT_PATH . "system/model/user.php"; load_user($GLOBALS['user_info']['id'], true); assign_uc_nav_list(); $GLOBALS['tmpl']->assign("user_info", $user_info); $GLOBALS['tmpl']->display("uc/uc_msg.html"); }
public function index() { init_app_page(); $s_account_info = $GLOBALS["account_info"]; $supplier_id = intval($s_account_info['supplier_id']); require_once APP_ROOT_PATH . "system/model/user.php"; $name = strim($_REQUEST['name']); $begin_time = strim($_REQUEST['begin_time']); $end_time = strim($_REQUEST['end_time']); $begin_time_s = to_timespan($begin_time, "Y-m-d H:i"); $end_time_s = to_timespan($end_time, "Y-m-d H:i"); $condition = ""; if ($name != "") { $event_ids = $GLOBALS['db']->getRow("select group_concat(id SEPARATOR ',') as ids from " . DB_PREFIX . "event where name like '%" . $name . "%'"); $condition .= " and es.event_id in (" . $event_ids['ids'] . ") "; } if ($begin_time_s) { $condition .= " and es.create_time > " . $begin_time_s . " "; } if ($end_time_s) { $condition .= " and es.create_time < " . $end_time_s . " "; } $GLOBALS['tmpl']->assign("name", $name); $GLOBALS['tmpl']->assign("begin_time", $begin_time); $GLOBALS['tmpl']->assign("end_time", $end_time); //分页 $page_size = 10; $page = intval($_REQUEST['p']); if ($page == 0) { $page = 1; } $limit = ($page - 1) * $page_size . "," . $page_size; $list = $GLOBALS['db']->getAll("select distinct(es.id),es.* from " . DB_PREFIX . "event_submit as es left join " . DB_PREFIX . "event_location_link as l on l.event_id = es.event_id where l.location_id in (" . implode(",", $s_account_info['location_ids']) . ") " . $condition . " order by es.is_verify asc,es.create_time desc limit " . $limit); $event_id = 0; foreach ($list as $k => $v) { $list[$k]['user_name'] = load_user($v['user_id']); $list[$k]['user_name'] = $list[$k]['user_name']['user_name']; $location_info = load_auto_cache("store", array('id' => $v['location_id'])); $list[$k]['location_name'] = $location_info['name']; if ($event_id != $v['event_id']) { $event_fields = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "event_field where event_id = " . $v['event_id'] . " order by sort asc"); $event_info = load_auto_cache("event", array("id" => $v['event_id'])); $event_id = $v['id']; } foreach ($event_fields as $kk => $vv) { $event_fields[$kk]['result'] = $GLOBALS['db']->getOne("select result from " . DB_PREFIX . "event_submit_field where submit_id = " . $v['id'] . " and field_id = " . $vv['id'] . " and event_id = " . $v['event_id']); } $list[$k]['fields'] = $event_fields; $list[$k]['event_name'] = $event_info['name']; $list[$k]['url'] = url('index', 'event#' . $v['event_id']); $list[$k]['go_url'] = url('biz', 'evento#approval', array('id' => $v['id'], 'ajax' => 1)); $list[$k]['refuse_url'] = url('biz', 'evento#refuse', array('id' => $v['id'], 'ajax' => 1)); } //print_r($list); $total = $GLOBALS['db']->getOne("select count(distinct(es.id)) from " . DB_PREFIX . "event_submit as es left join " . DB_PREFIX . "event_location_link as l on l.event_id = es.event_id where l.location_id in (" . implode(",", $s_account_info['location_ids']) . ") " . $condition); $page = new Page($total, $page_size); //初始化分页对象 $p = $page->show(); $GLOBALS['tmpl']->assign('pages', $p); $GLOBALS['tmpl']->assign("list", $list); $GLOBALS['tmpl']->assign("head_title", "活动报名"); $GLOBALS['tmpl']->display("pages/evento/index.html"); }
public function index() { init_app_page(); $s_account_info = $GLOBALS["account_info"]; $supplier_id = intval($s_account_info['supplier_id']); $name = strim($_REQUEST['name']); $begin_time = strim($_REQUEST['begin_time']); $end_time = strim($_REQUEST['end_time']); $begin_time_s = to_timespan($begin_time, "Y-m-d H:i"); $end_time_s = to_timespan($end_time, "Y-m-d H:i"); $condition = ""; if ($name != "") { $condition .= " and (doi.name like '%" . $name . "%' or doi.sub_name like '%" . $name . "%') "; } if ($begin_time_s) { $condition .= " and do.create_time > " . $begin_time_s . " "; } if ($end_time_s) { $condition .= " and do.create_time < " . $end_time_s . " "; } $GLOBALS['tmpl']->assign("name", $name); $GLOBALS['tmpl']->assign("begin_time", $begin_time); $GLOBALS['tmpl']->assign("end_time", $end_time); //分页 $page_size = 10; $page = intval($_REQUEST['p']); if ($page == 0) { $page = 1; } $limit = ($page - 1) * $page_size . "," . $page_size; require_once APP_ROOT_PATH . "system/model/deal_order.php"; $order_item_table_name = get_supplier_order_item_table_name($supplier_id); $order_table_name = get_supplier_order_table_name($supplier_id); $sql = "select distinct(doi.id),doi.*,do.delivery_id,do.memo,do.create_time,do.order_sn,do.total_price,do.pay_amount,doi.refund_status,do.region_lv1,do.region_lv2,do.region_lv3,do.region_lv4,do.consignee,do.address,do.zip,do.mobile from " . $order_item_table_name . " as doi left join " . $order_table_name . " as do on doi.order_id = do.id left join " . DB_PREFIX . "deal_location_link as l on doi.deal_id = l.deal_id " . " where l.location_id in (" . implode(",", $s_account_info['location_ids']) . ") and do.is_delete = 0 and do.type = 0 and doi.is_shop = 1 and do.pay_status = 2 {$condition} order by doi.id desc limit " . $limit; $sql_count = "select count(distinct(doi.id)) from " . $order_item_table_name . " as doi left join " . $order_table_name . " as do on doi.order_id = do.id left join " . DB_PREFIX . "deal_location_link as l on doi.deal_id = l.deal_id " . " where l.location_id in (" . implode(",", $s_account_info['location_ids']) . ") and do.is_delete = 0 and do.type = 0 and doi.is_shop = 1 and do.pay_status = 2 {$condition} "; $list = $GLOBALS['db']->getAll($sql); $region_conf = load_auto_cache("cache_delivery_region_conf"); $delivery_conf = load_auto_cache("cache_delivery"); foreach ($list as $k => $v) { $uinfo = load_user($v['user_id']); $list[$k]['user_name'] = $uinfo['user_name']; $list[$k]['create_time'] = to_date($v['create_time']); $deal_info = load_auto_cache("deal", array("id" => $v['deal_id'])); $list[$k]['url'] = $deal_info['url']; $list[$k]['s_total_price'] = $v['balance_total_price'] + $v['add_balance_price_total']; $list[$k]['region_lv1'] = $region_conf[$v['region_lv1']]['name']; $list[$k]['region_lv2'] = $region_conf[$v['region_lv2']]['name']; $list[$k]['region_lv3'] = $region_conf[$v['region_lv3']]['name']; $list[$k]['region_lv4'] = $region_conf[$v['region_lv4']]['name']; $list[$k]['delivery'] = $delivery_conf[$v['delivery_id']]['name']; $list[$k]['delivery_notice'] = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "delivery_notice where order_item_id = " . $v['id'] . " order by delivery_time desc limit 1"); } $total = $GLOBALS['db']->getOne($sql_count); $page = new Page($total, $page_size); //初始化分页对象 $p = $page->show(); $GLOBALS['tmpl']->assign('pages', $p); $GLOBALS['tmpl']->assign('NOW_TIME', NOW_TIME); $GLOBALS['tmpl']->assign("list", $list); $GLOBALS['tmpl']->assign("ORDER_DELIVERY_EXPIRE", ORDER_DELIVERY_EXPIRE); $GLOBALS['tmpl']->assign("head_title", "商品订单记录"); $GLOBALS['tmpl']->display("pages/goodso/index.html"); }
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); }
public function export_csv($page = 1) { set_time_limit(0); $limit = ($page - 1) * intval(app_conf("BATCH_PAGE_SIZE")) . "," . intval(app_conf("BATCH_PAGE_SIZE")); //处理-1情况的select if (!isset($_REQUEST['pay_status'])) { $_REQUEST['pay_status'] = -1; } if (!isset($_REQUEST['delivery_status'])) { $_REQUEST['delivery_status'] = -1; } if (!isset($_REQUEST['extra_status'])) { $_REQUEST['extra_status'] = -1; } if (!isset($_REQUEST['after_sale'])) { $_REQUEST['after_sale'] = -1; } if (!isset($_REQUEST['refund_status'])) { $_REQUEST['refund_status'] = -1; } if (!isset($_REQUEST['is_refuse_delivery'])) { $_REQUEST['is_refuse_delivery'] = -1; } if (!isset($_REQUEST['order_status'])) { $_REQUEST['order_status'] = -1; } $where = " 1=1 "; //定义条件 if (isset($_REQUEST['referer']) && strim($_REQUEST['referer']) != '') { if (intval($_REQUEST['referer']) == -1) { $where .= " and " . DB_PREFIX . "deal_order.referer = ''"; } else { $where .= " and " . DB_PREFIX . "deal_order.referer = '" . strim($_REQUEST['referer']) . "'"; } } if (strim($_REQUEST['user_name']) != '') { $where .= " and " . DB_PREFIX . "deal_order.user_name = '" . strim($_REQUEST['user_name']) . "'"; } if (intval($_REQUEST['deal_id']) > 0) { $where .= " and " . DB_PREFIX . "deal_order.deal_ids = " . intval($_REQUEST['deal_id']) . " "; } $where .= " and " . DB_PREFIX . "deal_order.is_delete = 0 "; $where .= " and " . DB_PREFIX . "deal_order.type = 0 "; if (strim($_REQUEST['order_sn']) != '') { $where .= " and " . DB_PREFIX . "deal_order.order_sn = '" . strim($_REQUEST['order_sn']) . "' "; } if (intval($_REQUEST['pay_status']) >= 0) { $where .= " and " . DB_PREFIX . "deal_order.pay_status = " . intval($_REQUEST['pay_status']); } if (intval($_REQUEST['delivery_status']) >= 0) { $where .= " and " . DB_PREFIX . "deal_order.delivery_status = " . intval($_REQUEST['delivery_status']); } if (intval($_REQUEST['extra_status']) >= 0) { $where .= " and " . DB_PREFIX . "deal_order.extra_status = " . intval($_REQUEST['extra_status']); } if (intval($_REQUEST['after_sale']) >= 0) { $where .= " and " . DB_PREFIX . "deal_order.after_sale = " . intval($_REQUEST['after_sale']); } if (intval($_REQUEST['refund_status']) >= 0) { $where .= " and " . DB_PREFIX . "deal_order.refund_status = " . intval($_REQUEST['refund_status']); } if (intval($_REQUEST['is_refuse_delivery']) >= 0) { $where .= " and " . DB_PREFIX . "deal_order.is_refuse_delivery = " . intval($_REQUEST['is_refuse_delivery']); } if (intval($_REQUEST['order_status']) >= 0) { $where .= " and " . DB_PREFIX . "deal_order.order_status = " . intval($_REQUEST['order_status']); } require_once APP_ROOT_PATH . "system/model/user.php"; $list = M("DealOrder")->where($where)->field(DB_PREFIX . 'deal_order.*')->limit($limit)->findAll(); if ($list) { register_shutdown_function(array(&$this, 'export_csv'), $page + 1); $order_value = array('sn' => '""', 'user_name' => '""', 'deal_name' => '""', 'number' => '""', 'create_time' => '""', 'total_price' => '""', 'pay_amount' => '""', 'consignee' => '""', 'address' => '""', 'zip' => '""', 'email' => '""', 'mobile' => '""', 'memo' => '""', 'pay_status' => '""', 'delivery_status' => '""', 'refund_status' => '""', 'is_refuse_delivery' => '""', 'order_status' => '""'); if ($page == 1) { $content = iconv("utf-8", "gbk", "订单编号,用户名,商品名称,订购数量,下单时间,订单总额,已收金额,收货人,发货地址,邮编,用户邮件,手机号码,订单留言,支付状态,发货状态,退款申请,维权申请,订单状态"); $content = $content . "\n"; } foreach ($list as $k => $v) { $user_info = load_user($v['user_id']); $order_value['sn'] = '"' . "sn:" . iconv('utf-8', 'gbk', $v['order_sn']) . '"'; $order_value['user_name'] = '"' . iconv('utf-8', 'gbk', $v['user_name']) . '"'; $order_items = unserialize($v['deal_order_item']); $names = ""; $total_num = 0; foreach ($order_items as $key => $row) { $names .= addslashes($row['name']) . "[" . $row['number'] . "]"; if ($key < count($order_items) - 1) { $names .= "\n"; } $total_num += $row['number']; } $order_value['deal_name'] = '"' . iconv('utf-8', 'gbk', $names) . '"'; $order_value['number'] = '"' . iconv('utf-8', 'gbk', $total_num) . '"'; $order_value['create_time'] = '"' . iconv('utf-8', 'gbk', to_date($v['create_time'])) . '"'; $order_value['total_price'] = '"' . iconv('utf-8', 'gbk', floatval($v['total_price']) . "元") . '"'; $order_value['pay_amount'] = '"' . iconv('utf-8', 'gbk', floatval($v['pay_amount']) . "元") . '"'; $order_value['consignee'] = '"' . iconv('utf-8', 'gbk', $v['consignee']) . '"'; $region_lv1_name = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "delivery_region where id = " . $v['region_lv1']); $region_lv2_name = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "delivery_region where id = " . $v['region_lv2']); $region_lv3_name = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "delivery_region where id = " . $v['region_lv3']); $region_lv4_name = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "delivery_region where id = " . $v['region_lv4']); $address = $region_lv1_name . $region_lv2_name . $region_lv3_name . $region_lv4_name . $v['address']; $order_value['address'] = '"' . iconv('utf-8', 'gbk', $address) . '"'; $order_value['zip'] = '"' . iconv('utf-8', 'gbk', $v['zip']) . '"'; $order_value['email'] = '"' . iconv('utf-8', 'gbk', $user_info['email']) . '"'; if ($v['mobile'] != '') { $mobile = $v['mobile']; } else { $mobile = $user_info['mobile']; } $order_value['mobile'] = '"' . iconv('utf-8', 'gbk', $mobile) . '"'; $order_value['memo'] = '"' . iconv('utf-8', 'gbk', $v['memo']) . '"'; $order_value['pay_status'] = '"' . iconv('utf-8', 'gbk', l("PAY_STATUS_" . $v['pay_status'])) . '"'; $order_value['delivery_status'] = '"' . iconv('utf-8', 'gbk', l("ORDER_DELIVERY_STATUS_" . $v['delivery_status'])) . '"'; $refund_status = $v['refund_status'] == 1 ? "有" : "无"; $order_value['refund_status'] = '"' . iconv('utf-8', 'gbk', $refund_status) . '"'; $is_refuse_delivery = $v['is_refuse_delivery'] == 1 ? "有" : "无"; $order_value['is_refuse_delivery'] = '"' . iconv('utf-8', 'gbk', $is_refuse_delivery) . '"'; $order_value['order_status'] = '"' . iconv('utf-8', 'gbk', get_order_status_csv($v['order_status'], $v)) . '"'; $content .= implode(",", $order_value) . "\n"; } header("Content-Disposition: attachment; filename=order_list.csv"); echo $content; } else { if ($page == 1) { $this->error(L("NO_RESULT")); } } }
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); }
<?php require_once "config.php"; require_once "models.php"; session_start(); $client = load_user(); $client->update_groups(); if ($_GET && $_GET["ajax"]) { } else { header('Location: tvlisting.php'); }
function refresh_user_info() { global $user_info; global $user_logined; //实时刷新会员数据 if ($user_info) { $user_info = load_user($user_info['id']); $user_level = load_auto_cache("cache_user_level"); $user_info['level'] = $user_level[$user_info['level_id']]['level']; $user_info['level_name'] = $user_level[$user_info['level_id']]['name']; es_session::set('user_info', $user_info); $user_logined_time = intval(es_session::get("user_logined_time")); $user_logined = es_session::get("user_logined"); if (NOW_TIME - $user_logined_time >= MAX_LOGIN_TIME) { es_session::set("user_logined_time", 0); es_session::set("user_logined", false); $user_logined = false; } else { if ($user_logined) { es_session::set("user_logined_time", NOW_TIME); } } } }
/** * Produces the Javascript code that prefills the comment form (either when * previewing or being a registered visitor). * * @param string $name * @param string $email * @param string $url * @param string $cookie * @param string $comm * @param integer $notify * @param integer $hidemail * @return string */ function fill_comment_form($name = '', $email = '', $url = '', $cookie = '', $comm = '', $notify = 0, $hidemail = 0) { global $Paths; require_once $Paths['pivot_path'] . "modules/module_userreg.php"; // if user is logged in as registered visitor, we must always use // that info in the form. if ($user = load_user($_COOKIE['piv_reguser'])) { $name = $user['name']; $email = $user['email']; $url = $user['url']; $notify = $user['notify_default']; $hidemail = 1 - $user['show_address']; } // Clean up user input $name = js_sanctify($name); $email = js_sanctify($email); $url = js_sanctify($url); $comm = js_sanctify($comm, '<b>,<i>,<em>,<strong>'); $output = "<script type=\"text/javascript\">\n"; $output .= "var form = document.getElementById('form');\n"; $output .= "if (form) { "; if ($name != "") { $output .= "form.piv_name.value='" . $name . "';\n"; } if ($email != "") { $output .= "form.piv_email.value='" . $email . "';\n"; } if ($url != "") { $output .= "form.piv_url.value='" . $url . "';\n"; } if ($comm != "") { $output .= "form.piv_comment.value='" . $comm . "';\n"; } if ($cookie == "yes") { $output .= "form.piv_rememberinfo[0].checked=true;\n"; } else { $output .= "form.piv_rememberinfo[1].checked=true;\n"; } if ($notify == 1) { $output .= "form.piv_notify.checked=true;\n"; } else { $output .= "form.piv_notify.checked=false;\n"; } if ($hidemail == 1) { $output .= "form.piv_discreet.checked=true;\n"; } else { $output .= "form.piv_discreet.checked=false;\n"; } $output .= "}"; $output .= "</script>\n"; return $output; }
public function set_syn_weibo() { global_run(); if (!$GLOBALS['user_info']) { $result['status'] = -1; $result['info'] = "请先登录后操作!"; ajax_return($result); } $class_name = strim($_REQUEST['class_name']); $apis = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "api_login where is_weibo = 1"); foreach ($apis as $k => $v) { $api_class[$v['class_name']] = strtolower($v['class_name']); } if (!in_array(strtolower($class_name), $api_class)) { $result['status'] = 0; $result['info'] = "参数错误"; ajax_return($result); } //引入接口 if (file_exists(APP_ROOT_PATH . "system/api_login/" . $class_name . "_api.php")) { require_once APP_ROOT_PATH . "system/api_login/" . $class_name . "_api.php"; $class_name_obj = $class_name . "_api"; $api_obj = new $class_name_obj($api_class[$class_name]); $result = $api_obj->set_syn_weibo(); require_once APP_ROOT_PATH . "system/model/user.php"; load_user($GLOBALS['user_info']['id'], true); ajax_return($result); } else { $result['status'] = 0; $result['info'] = "接口不存在"; ajax_return($result); } }
public function callback() { global_run(); require_once APP_ROOT_PATH . "system/api_login/qqv2/qqConnectAPI.php"; $qc = new QC(); $access_token = $qc->qq_callback(); $openid = $qc->get_openid(); $use_info_keysArr = array("access_token" => $access_token, "openid" => $openid, "oauth_consumer_key" => $this->api['config']['app_key']); $use_info_url = "https://graph.qq.com/user/get_user_info"; $graph_use_info_url = $qc->urlUtils->combineURL($use_info_url, $use_info_keysArr); $response = $qc->urlUtils->get_contents($graph_use_info_url); if ($response['ret'] != 0) { showErr("授权失败,错误信息:" . $response['msg']); die; } $response = json_decode($response, 1); $msg['field'] = 'qqv2_id'; $msg['id'] = $openid; $msg['name'] = $response["nickname"]; es_session::set("api_user_info", $msg); $user_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where qqv2_id = '" . $openid . "' and qqv2_id <> '' and is_effect=1 and is_delete=0"); $is_bind = intval(es_session::get("is_bind")); if ($user_data) { $GLOBALS['db']->query("update " . DB_PREFIX . "user set qq_token = '" . $access_token . "',login_ip = '" . CLIENT_IP . "',login_time= " . NOW_TIME . " where id =" . $user_data['id']); es_session::delete("api_user_info"); if ($is_bind) { if (intval($user_data['id']) != intval($GLOBALS['user_info']['id'])) { showErr("该帐号已经被别的会员绑定过,请直接用帐号登录", 0, url("index", "uc_account")); } else { require_once APP_ROOT_PATH . "system/model/user.php"; load_user($user_data['id'], true); es_session::set("user_info", $user_data); app_redirect(url("index", "uc_account")); } } else { require_once APP_ROOT_PATH . "system/model/user.php"; auto_do_login_user($user_data['user_name'], $user_data['user_pwd'], $from_cookie = false); app_redirect(url("index", "index")); } } elseif ($is_bind == 1 && $GLOBALS['user_info']) { //当有用户身份且要求绑定时 $GLOBALS['db']->query("update " . DB_PREFIX . "user set qqv2_id= '" . $msg['id'] . "', qq_token ='" . $access_token . "' where id =" . $GLOBALS['user_info']['id']); require_once APP_ROOT_PATH . "system/model/user.php"; load_user($GLOBALS['user_info']['id'], true); app_redirect(url("index", "uc_account")); } else { $user_info = $this->create_user(); require_once APP_ROOT_PATH . "system/model/user.php"; auto_do_login_user($user_info['user_name'], $user_info['user_pwd'], $from_cookie = false); app_redirect(url("index", "index")); } }
public function index() { init_app_page(); $s_account_info = $GLOBALS['account_info']; $supplier_id = intval($s_account_info['supplier_id']); $name = strim($_REQUEST['name']); $begin_time = strim($_REQUEST['begin_time']); $end_time = strim($_REQUEST['end_time']); $begin_time_s = to_timespan($begin_time, "Y-m-d H:i"); $end_time_s = to_timespan($end_time, "Y-m-d H:i"); $condition = ""; if ($name != "") { $condition .= " and (doi.name like '%" . $name . "%' or doi.sub_name like '%" . $name . "%') "; } if ($begin_time_s) { $condition .= " and do.create_time > " . $begin_time_s . " "; } if ($end_time_s) { $condition .= " and do.create_time < " . $end_time_s . " "; } $GLOBALS['tmpl']->assign("name", $name); $GLOBALS['tmpl']->assign("begin_time", $begin_time); $GLOBALS['tmpl']->assign("end_time", $end_time); //分页 $page_size = 10; $page = intval($_REQUEST['p']); if ($page == 0) { $page = 1; } $limit = ($page - 1) * $page_size . "," . $page_size; require_once APP_ROOT_PATH . "system/model/deal_order.php"; $order_item_table_name = get_supplier_order_item_table_name($supplier_id); $order_table_name = get_supplier_order_table_name($supplier_id); $sql = "select distinct(doi.id),doi.*,do.memo,do.create_time,do.order_sn,do.total_price,do.pay_amount,doi.refund_status from " . $order_item_table_name . " as doi left join " . $order_table_name . " as do on doi.order_id = do.id left join " . DB_PREFIX . "deal_location_link as l on doi.deal_id = l.deal_id " . " where l.location_id in (" . implode(",", $s_account_info['location_ids']) . ") and do.is_delete = 0 and do.type = 0 and doi.is_shop = 0 and do.pay_status = 2 {$condition} order by doi.id desc limit " . $limit; $sql_count = "select count(distinct(doi.id)) from " . $order_item_table_name . " as doi left join " . $order_table_name . " as do on doi.order_id = do.id left join " . DB_PREFIX . "deal_location_link as l on doi.deal_id = l.deal_id " . " where l.location_id in (" . implode(",", $s_account_info['location_ids']) . ") and do.is_delete = 0 and do.type = 0 and doi.is_shop = 0 and do.pay_status = 2 {$condition} "; $list = $GLOBALS['db']->getAll($sql); foreach ($list as $k => $v) { $uinfo = load_user($v['user_id']); $list[$k]['user_name'] = $uinfo['user_name']; $mobile = $uinfo['mobile']; //保护手机号 // $mobile_end = substr($mobile,-4,4); // $mobile_show_length = strlen($mobile) - 4 - 3; // $mobile = substr($mobile,0,3); // for($i=0;$i<$mobile_show_length;$i++) // { // $mobile.="*"; // } // $mobile.=$mobile_end; $list[$k]['user_mobile'] = $mobile; $list[$k]['create_time'] = to_date($v['create_time']); $deal_info = load_auto_cache("deal", array("id" => $v['deal_id'])); $list[$k]['url'] = $deal_info['url']; $list[$k]['s_total_price'] = $v['balance_total_price'] + $v['add_balance_price_total']; $verify_count_0 = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_coupon where order_deal_id = " . $v['id'] . " and confirm_time <> 0 and deal_type = 0"); $verify_count_1 = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_coupon where order_deal_id = " . $v['id'] . " and confirm_time <> 0 and deal_type = 1"); $refund_status_1_0 = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_coupon where order_deal_id = " . $v['id'] . " and refund_status = 1 and deal_type = 0"); $refund_status_1_1 = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_coupon where order_deal_id = " . $v['id'] . " and refund_status = 1 and deal_type = 1"); $refund_status_2_0 = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_coupon where order_deal_id = " . $v['id'] . " and refund_status = 2 and deal_type = 0"); $refund_status_2_1 = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_coupon where order_deal_id = " . $v['id'] . " and refund_status = 2 and deal_type = 1"); $list[$k]['verify_count'] = $verify_count_0 + $verify_count_1 * $v['number']; $list[$k]['refund_status_1'] = $refund_status_1_0 + $refund_status_1_1 * $v['number']; $list[$k]['refund_status_2'] = $refund_status_2_0 + $refund_status_2_1 * $v['number']; } $total = $GLOBALS['db']->getOne($sql_count); $page = new Page($total, $page_size); //初始化分页对象 $p = $page->show(); $GLOBALS['tmpl']->assign('pages', $p); $GLOBALS['tmpl']->assign("list", $list); $GLOBALS['tmpl']->assign("head_title", "团购订单记录"); $GLOBALS['tmpl']->display("pages/dealo/index.html"); }
public function index() { require_once APP_ROOT_PATH . "system/model/user.php"; if (strim($GLOBALS['request']['act_2']) == 'bm') { $root['status'] = 1; $city_name = strim($GLOBALS['request']['city_name']); //城市名称 //检查用户,用户密码 $user_data = $GLOBALS['user_info']; //报名 if ($user_data) { $root['user_login_status'] = 1; $event_id = intval($GLOBALS['request']['event_id']); $user_id = intval($GLOBALS['user_info']['id']); require_once APP_ROOT_PATH . "system/model/event.php"; // $event = $GLOBALS['db']->getRow("select * from ".DB_PREFIX."event where id = ".$event_id." and is_effect = 1"); $event = get_event($event_id); if ($event) { if ($event['xpoint'] == '') { $event['xpoint'] = 0; } if ($event['ypoint'] == '') { $event['ypoint'] = 0; } if ($event['submit_begin_time'] > NOW_TIME) { $root['return'] = 0; $root['info'] = "活动未开始"; } elseif ($event['submit_end_time'] > 0 && $event['submit_end_time'] < NOW_TIME) { $root['return'] = 0; $root['info'] = "活动报名已结束"; } elseif ($event['submit_count'] >= $event['total_count'] && $event['total_count'] > 0) { $root['return'] = 0; $root['info'] = "活动名额已满"; } else { //开始提交报名 $user_id = intval($GLOBALS['user_info']['id']); $user_submit = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "event_submit where user_id = " . $user_id . " and event_id = " . $event_id); if ($user_submit) { if ($user_submit['is_verify'] == 1) { $root['return'] = 0; $root['info'] = "您已经报过名了"; } elseif ($user_submit['is_verify'] == 2) { $root['return'] = 0; $root['info'] = "您的报名审核不通过"; } else { //已经报名,仅作修改 $bm = $GLOBALS['request']['bm']; $GLOBALS['db']->query("delete from " . DB_PREFIX . "event_submit_field where submit_id = " . $user_submit['id']); foreach ($bm as $field_id => $bm_result) { $field_data = array(); $field_data['submit_id'] = $user_submit['id']; $field_data['field_id'] = $field_id; $field_data['event_id'] = $event_id; $field_data['result'] = strim($bm_result); $GLOBALS['db']->autoExecute(DB_PREFIX . "event_submit_field", $field_data, "INSERT"); } $root['return'] = 1; $root['info'] = "报名修改成功"; } } else { $submit_data = array(); $submit_data['user_id'] = $user_id; $submit_data['event_id'] = $event_id; $submit_data['create_time'] = get_gmtime(); $GLOBALS['db']->autoExecute(DB_PREFIX . "event_submit", $submit_data, "INSERT"); $submit_id = $GLOBALS['db']->insert_id(); if ($submit_id) { $bm = $GLOBALS['request']['bm']; //file_put_contents(APP_ROOT_PATH. "sjmapi/log/bm_".strftime("%Y%m%d%H%M%S",time()).".txt",print_r($GLOBALS['request'],true)); //$bm = (unserialize($GLOBALS['request']['bm'])); foreach ($bm as $field_id => $bm_result) { $field_data = array(); $field_data['submit_id'] = $submit_id; $field_data['field_id'] = $field_id; $field_data['event_id'] = $event_id; $field_data['result'] = strim($bm_result); $GLOBALS['db']->autoExecute(DB_PREFIX . "event_submit_field", $field_data, "INSERT"); } $GLOBALS['db']->query("update " . DB_PREFIX . "event set submit_count = submit_count+1 where id=" . $event_id); if ($event['is_auto_verify'] == 1) { //自动审核,发券 $sn = verify_event_submit($submit_id); } //同步分享 // $title = "报名参加了".$event['name']; // $content = "报名参加了".$event['name']." - ".$event['brief']; // $url_route = array( // 'rel_app_index' => 'youhui', // 'rel_route' => 'edetail', // 'rel_param' => 'id='.$event['id'] // ); // $tid = insert_topic($content,$title,$type="eventsubmit",$group="", $relay_id = 0, $fav_id = 0,$group_data ="",$attach_list=array(),$url_route); // if($tid) // { // $GLOBALS['db']->query("update ".DB_PREFIX."topic set source_name = '".$GLOBALS['request']['source']."' where id = ".intval($tid)); // } //同步分享 $title = "报名参加了" . $event['name']; $content = "报名参加了" . $event['name'] . " - " . $event['brief']; $url_route = array('rel_app_index' => 'index', 'rel_route' => 'event#' . $event['id'], 'rel_param' => ''); require_once APP_ROOT_PATH . "system/model/topic.php"; $tid = insert_topic($content, $title, $type = "eventsubmit", $group = "", $relay_id = 0, $fav_id = 0, $group_data = "", $attach_list = array(), $url_route); if ($tid) { $GLOBALS['db']->query("update " . DB_PREFIX . "topic set source_name = '" . $GLOBALS['request']['source'] . "' where id = " . intval($tid)); } require_once APP_ROOT_PATH . "system/model/user.php"; modify_account(array("score" => "-" . $event['score_limit']), $user_id, "活动报名:" . $event['name']); $root['return'] = 1; $root['info'] = "报名成功"; if ($sn) { $root['info'] .= " 验证码:" . $sn; } else { $root['info'] .= " 请等待审核"; } rm_auto_cache("event", array("id" => $event['id'])); } else { $root['return'] = 0; $root['info'] = "报名失败"; } } } } else { $root['return'] = 0; $root['info'] = "没有该活动数据"; } } else { $root['return'] = 0; $root['user_login_status'] = 0; $root['info'] = "请先登录"; } output($root); //报名 } //报名结束 $page = intval($GLOBALS['request']['page']); //分页,无用 if ($page == 0) { $page = 1; } $event_id = intval($GLOBALS['request']['event_id']); if ($event_id) { $user_data = $GLOBALS['user_info']; require_once APP_ROOT_PATH . "system/model/event.php"; $event = get_event($event_id); if ($event['xpoint'] == '') { $event['xpoint'] = 0; } if ($event['ypoint'] == '') { $event['ypoint'] = 0; } $pattern = "/<img([^>]*)\\/>/i"; $replacement = "<img width=300 \$1 />"; $event['icon'] = get_abs_img_root($event['icon']); $pattern = "/<[img|IMG].*?src=[\\'|\"](.*?(?:[\\.gif|\\.jpg|\\.png]))[\\'|\"].*?[\\/]?>/i"; //$replacement = "<img width=300 $1 />"; $replacement = "<img src='\$1' width='278' />"; $event['content'] = get_abs_img_root(preg_replace($pattern, $replacement, $event['content'])); //$event['content'] = get_abs_img_root(get_spec_image($event['content'], 278,168,1)); $event['content'] = preg_replace($pattern, $replacement, $event['content']); $event['event_begin_time'] = to_date($event['event_begin_time'], 'Y-m-d'); $event['event_end_time'] = to_date($event['event_end_time'], 'Y-m-d'); //验证是否报名 //$is_submit = $GLOBALS['db']->getOne("select count(*) from ".DB_PREFIX."event_submit where user_id = ".intval($GLOBALS['user_info']['id'])." and event_id = ".$event['id']); // $event_fields = $GLOBALS['db']->getAll("select * from ".DB_PREFIX."event_field where event_id = ".$event_id." order by sort asc"); // foreach($event_fields as $k=>$v) // { // $event_fields[$k]['value_scope'] = explode(" ",$v['value_scope']); // } // $event['field_list'] = $event_fields; // $event['is_submit'] = $is_submit; // $event['field_list_json']=json_encode($event_fields); $user_submit = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "event_submit where user_id = " . $user_data['id'] . " and event_id = " . $event_id); if ($user_submit) { if ($user_submit['is_verify'] == 1) { $event['is_submit'] = 1; //已报名 $event['is_verify'] = 1; //已审核 } elseif ($user_submit['is_verify'] == 2) { $event['is_submit'] = 1; //已报名 $event['is_verify'] = 2; //审核失败 } else { //未审核 $event_fields = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "event_field where event_id = " . $event_id . " order by sort asc"); foreach ($event_fields as $k => $v) { $event_fields[$k]['result'] = $GLOBALS['db']->getOne("select result from " . DB_PREFIX . "event_submit_field where submit_id = " . $user_submit['id'] . " and field_id = " . $v['id'] . " and event_id = " . $event_id); $event_fields[$k]['value_scope'] = explode(" ", $v['value_scope']); } $event['event_fields'] = $event_fields; $event['is_submit'] = 1; //已报名 $event['is_verify'] = 0; //未审核 // $GLOBALS['tmpl']->assign("event_fields",$event_fields); // $GLOBALS['tmpl']->assign("user_submit",$user_submit); //表示修改已报名记录 // $GLOBALS['tmpl']->assign("btn_name","修改报名"); } } else { $event_fields = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "event_field where event_id = " . $event_id . " order by sort asc"); foreach ($event_fields as $k => $v) { $event_fields[$k]['value_scope'] = explode(" ", $v['value_scope']); } $event['event_fields'] = $event_fields; $event['is_submit'] = 0; //已报名 } } //$res = m_get_event_reply($event_id,$page); //$event['comments'] = $res['list']; //$root['page'] = $res['page']; require_once APP_ROOT_PATH . "system/model/review.php"; require_once APP_ROOT_PATH . "system/model/user.php"; $message_re = get_dp_list(3, $param = array("deal_id" => 0, "youhui_id" => 0, "event_id" => $event_id, "location_id" => 0, "tag" => ""), "", ""); foreach ($message_re['list'] as $k => $v) { $message_re['list'][$k]['width'] = $v['point'] / 5 * 100; $uinfo = load_user($v['user_id']); $message_re['list'][$k]['user_name'] = $uinfo['user_name']; foreach ($message_re['list'][$k]['images'] as $kk => $vv) { $message_re['list'][$k]['images'][$kk] = get_abs_img_root(get_spec_image($vv, 60, 60, 1)); $message_re['list'][$k]['oimages'][$kk] = get_abs_img_root($vv); } } $root['message_list'] = $message_re['list']; if (count($message_re['list']) > 0) { $sql = "select count(*) from " . DB_PREFIX . "supplier_location_dp where " . $message_re['condition']; $message_re['count'] = $GLOBALS['db']->getOne($sql); } $root['message_count'] = $message_re['count']; $root['return'] = 1; $root['item'] = $event; $root['page_title'] = "活动详情"; $root['city_name'] = $city_name; output($root); }
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); }
/** * 处理会员登录 * @param $user_name_or_email 用户名或邮箱地址 * @param $user_pwd 密码 * */ function do_login_user($user_name_or_email, $user_pwd) { $user_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where (user_name='" . $user_name_or_email . "' or email = '" . $user_name_or_email . "' or mobile = '" . $user_name_or_email . "') and is_delete = 0"); //载入会员整合 $integrate_code = strim(app_conf("INTEGRATE_CODE")); if ($integrate_code != '' && $GLOBALS['request']['from'] != 'wap') { $integrate_file = APP_ROOT_PATH . "system/integrate/" . $integrate_code . "_integrate.php"; if (file_exists($integrate_file)) { require_once $integrate_file; $integrate_class = $integrate_code . "_integrate"; $integrate_obj = new $integrate_class(); } } if ($integrate_obj) { $result = $integrate_obj->login($user_name_or_email, $user_pwd); } $user_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where (user_name='" . $user_name_or_email . "' or email = '" . $user_name_or_email . "' or mobile = '" . $user_name_or_email . "') and is_delete = 0"); if (!$user_data) { $result['status'] = 0; $result['data'] = ACCOUNT_NO_EXIST_ERROR; return $result; } else { $result['user'] = $user_data; if ($user_data['user_pwd'] != md5($user_pwd . $user_data['code']) && $user_data['user_pwd'] != $user_pwd) { $result['status'] = 0; $result['data'] = ACCOUNT_PASSWORD_ERROR; return $result; } elseif ($user_data['is_effect'] != 1) { $result['status'] = 0; $result['data'] = ACCOUNT_NO_VERIFY_ERROR; return $result; } else { if (intval($result['status']) == 0) { $result['status'] = 1; } //登录成功自动检测关于会员等级以及自动登录商家 $account_name = $user_data['merchant_name']; $account = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "supplier_account where account_name = '" . $account_name . "' and is_effect = 1 and is_delete = 0"); if ($account) { $account_locations = $GLOBALS['db']->getAll("select location_id from " . DB_PREFIX . "supplier_account_location_link where account_id = " . $account['id']); $account_location_ids = array(0); foreach ($account_locations as $row) { $account_location_ids[] = $row['location_id']; } $account['location_ids'] = $account_location_ids; es_session::set("account_info", $account); $GLOBALS['db']->query("update " . DB_PREFIX . "supplier_account set login_ip = '" . CLIENT_IP . "' where id=" . $account['id']); } $user_current_group = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_group where id = " . intval($user_data['group_id'])); $user_group = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_group where score <=" . intval($user_data['total_score']) . " order by score desc"); if ($user_current_group['score'] < $user_group['score']) { $user_data['group_id'] = intval($user_group['id']); $GLOBALS['db']->query("update " . DB_PREFIX . "user set group_id = " . $user_data['group_id'] . " where id = " . $user_data['id']); $pm_content = "恭喜您,您已经成为" . $user_group['name'] . "。"; if ($user_group['discount'] < 1) { $pm_content .= "您将享有" . $user_group['discount'] * 10 . "折的购物优惠"; } send_msg($user_data['id'], $pm_content, "notify", 0); } $user_current_level = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_level where id = " . intval($user_data['level_id'])); $user_level = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_level where point <=" . intval($user_data['point']) . " order by point desc"); if ($user_current_level['point'] < $user_level['point']) { $user_data['level_id'] = intval($user_level['id']); $GLOBALS['db']->query("update " . DB_PREFIX . "user set level_id = " . $user_data['level_id'] . " where id = " . $user_data['id']); $pm_content = "恭喜您,您已经成为" . $user_level['name'] . "。"; send_msg($user_data['id'], $pm_content, "notify", 0); } if ($user_current_level['point'] > $user_level['point']) { $user_data['level_id'] = intval($user_level['id']); $GLOBALS['db']->query("update " . DB_PREFIX . "user set level_id = " . $user_data['level_id'] . " where id = " . $user_data['id']); $pm_content = "很报歉,您已经降为" . $user_level['name'] . "。"; send_msg($user_data['id'], $pm_content, "notify", 0); } send_system_msg($user_data['id']); $user_data = load_user($user_data['id'], true); es_session::set("user_info", $user_data); $GLOBALS['user_info'] = $user_data; es_session::set("user_logined", true); $GLOBALS['user_logined'] = true; es_session::set("user_logined_time", NOW_TIME); $GLOBALS['db']->query("update " . DB_PREFIX . "deal_cart set user_id = " . $GLOBALS['user_info']['id'] . " where session_id = '" . es_session::id() . "'"); require_once APP_ROOT_PATH . "system/model/cart.php"; load_cart_list(true); //检测勋章 $medal_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "medal where is_effect = 1 and allow_check = 1"); foreach ($medal_list as $medal) { $file = APP_ROOT_PATH . "system/medal/" . $medal['class_name'] . "_medal.php"; $cls = $medal['class_name'] . "_medal"; if (file_exists($file)) { require_once $file; if (class_exists($cls)) { $o = new $cls(); $check_result = $o->check_medal(); if ($check_result['status'] == 0) { send_msg($user_data['id'], $check_result['info'], "notify", 0); } } } } //签到 $signin_result = signin($GLOBALS['user_info']['id']); if ($signin_result['status']) { es_session::set("signin_result", $signin_result); } $GLOBALS['db']->query("update " . DB_PREFIX . "user set login_ip = '" . CLIENT_IP . "',login_time= " . NOW_TIME . ",group_id=" . intval($user_data['group_id']) . " where id =" . $user_data['id']); $s_api_user_info = es_session::get("api_user_info"); if ($s_api_user_info) { $GLOBALS['db']->query("update " . DB_PREFIX . "user set " . $s_api_user_info['field'] . " = '" . $s_api_user_info['id'] . "' where id = " . $user_data['id'] . " and (" . $s_api_user_info['field'] . " = 0 or " . $s_api_user_info['field'] . "='')"); es_session::delete("api_user_info"); } $result['step'] = intval($user_data["step"]); return $result; } } }
public function callback() { global_run(); es_session::start(); require_once APP_ROOT_PATH . 'system/api_login/Tencent/Tencent.php'; OAuth::init($this->api['config']['app_key'], $this->api['config']['app_secret']); $code = strim($_REQUEST['code']); $openid = strim($_REQUEST['openid']); $openkey = strim($_REQUEST['openkey']); if ($this->api['config']['app_url'] == "") { $app_url = SITE_DOMAIN . APP_ROOT . "/api_callback.php?c=Tencent"; } else { $app_url = $this->api['config']['app_url']; } $token_url = OAuth::getAccessToken($code, $app_url); $result = Http::request($token_url); $result = preg_replace('/[^\\x20-\\xff]*/', "", $result); //清除不可见字符 $result = iconv("utf-8", "utf-8//ignore", $result); //UTF-8转码 //过滤返回数据 parse_str($result, $result_arr); $is_bind = intval(es_session::get("is_bind")); if (intval($result_arr['errorCode']) != 0) { showErr("授权失败,错误代码:" . $result_arr['errorMsg']); die; } if (!$result_arr['name']) { app_redirect(url("index")); exit; } $msg['field'] = 'tencent_id'; $msg['id'] = $openid; $msg['t_openid'] = $result_arr['openid']; $msg['t_openkey'] = $openkey; $msg['t_access_token'] = $result_arr['access_token']; $msg['refresh_token'] = $result_arr['refresh_token']; $msg['t_name'] = $result_arr['name']; //没有登录用户无绑定情况下,创建用户时候使用到 es_session::set("api_user_info", $msg); $user_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where tencent_id = '" . $msg['id'] . "' and tencent_id <> 0"); $is_bind = intval(es_session::get("is_bind")); //存在用户直接登录 if ($user_data) { $GLOBALS['db']->query("update " . DB_PREFIX . "user set t_access_token = '" . $msg['t_access_token'] . "',login_ip = '" . CLIENT_IP . "',login_time= " . NOW_TIME . " where id =" . $user_data['id']); es_session::delete("api_user_info"); if ($is_bind) { if (intval($user_data['id']) != intval($GLOBALS['user_info']['id'])) { showErr("该帐号已经被别的会员绑定过,请直接用帐号登录", 0, url("index", "uc_account")); } else { require_once APP_ROOT_PATH . "system/model/user.php"; load_user($user_data['id'], true); es_session::set("user_info", $user_data); app_redirect(url("index", "uc_account")); } } else { require_once APP_ROOT_PATH . "system/model/user.php"; auto_do_login_user($user_data['user_name'], $user_data['user_pwd'], $from_cookie = false); app_redirect(url("index", "index")); } } elseif ($is_bind == 1 && $GLOBALS['user_info']) { //登录了站内用户,用户又不存在如果来自绑定就进行绑定 $GLOBALS['db']->query("update " . DB_PREFIX . "user set t_access_token ='" . $msg['t_access_token'] . "',t_openkey = '" . $msg['t_openkey'] . "',tencent_id = '" . $msg['id'] . "',t_name='" . $msg['t_name'] . "' where id =" . $GLOBALS['user_info']['id']); require_once APP_ROOT_PATH . "system/model/user.php"; load_user($GLOBALS['user_info']['id'], true); app_redirect(url("index", "uc_account")); } else { //没有登录站内用户,直接进行创建临时用户 $user_info = $this->create_user(); require_once APP_ROOT_PATH . "system/model/user.php"; auto_do_login_user($user_info['user_name'], $user_info['user_pwd'], $from_cookie = false); app_redirect(url("index", "index")); } }
$filelink .= substr($query, 0, -1); } // Redirect header("HTTP/1.1 301 Moved Permanently"); header("Location: {$filelink}"); exit; } // load an entry if (isset($Pivot_Vars['id'])) { execute_hook("display_entry", "pre", $Pivot_Vars['id'], $override_weblog); $output = parse_entry($Pivot_Vars['id'], $override_weblog); // If registered user, override the other settings.. if (isset($_COOKIE['piv_reguser'])) { list($reg_name, $reg_hash) = explode("|", $Pivot_Cookies['piv_reguser']); if (check_user_hash($reg_name, $reg_hash)) { $reg_user = load_user($reg_name); if ($reg_user['show_address'] == 1) { $_COOKIE['piv_email'] = $reg_user['email']; } else { $_COOKIE['piv_email'] = ""; } $_COOKIE['piv_name'] = $reg_user['name']; $_COOKIE['piv_url'] = $reg_user['url']; } } if (count($_COOKIE) > 0) { $cookie = @fill_comment_form($_COOKIE['piv_name'], $_COOKIE['piv_email'], $_COOKIE['piv_url'], $_COOKIE['piv_rememberinfo'], $_COOKIE['piv_comment']); $cookie = i18n_str_to_utf8($cookie); $output = str_replace("</body>", $cookie . "</body>", $output); } add_hook("display_entry", "post");
<?php function load_user($user_id) { return \Drupal\user\Entity\User::load($user_id); } // Get database connection \Drupal\Core\Database\Database::setActiveConnection(); $connection = \Drupal\Core\Database\Database::getConnection(); // Get all the users $results = $connection->query('SELECT u.uid, d.name, d.mail FROM users AS u INNER JOIN users_field_data AS d ON u.uid = d.uid;')->fetchAll(); // For each user, remove the user_picture and then save the user if ($results) { foreach ($results as $record) { $user_id = $record->uid; $user_name = $record->name; $user_email = $record->mail; print "Removing user_picture from {$user_name} ({$user_email})...\n"; $user = load_user($user_id); $user->set("user_picture", NULL); $user->save(); } }
<?php $uid = isset($_POST['uid']) ? $_POST['uid'] : ''; $user = load_user($uid); if (isset($_POST['submit'])) { delete_user($_POST['id']); sleep(3); header('Location: /user'); } ?> <h3>Do you want to delete the user "<?php print $user['name']; ?> "?</h3> <form method="post" action=""> <input type="hidden" name="id" value="<?php print $uid; ?> "/> <input type="submit" name="submit" value="Delete" /> <a class="button" href="/user">Cancel</a> </form>
function snippet_label($label) { if ($label != "register") { $output = lang('weblog_text', $label); } else { // One small expection for label 'register'.. If the user if ($user = load_user($_COOKIE['piv_reguser'])) { $output = lang('commentuser', 'loggedinas') . " " . $user['name']; } else { $output = lang('weblog_text', $label); } } return $output; }
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); }
<?php global $user; $invalid = false; require 'db.php'; function fields_are_valid() { return $_POST["username"] != "" && $_POST["password"] != ""; } if ($_POST) { if (fields_are_valid()) { if (true) { $user = load_user($_POST["username"]); } if ($user) { $_SESSION["user"] = $user; header("Location: index.php"); } } else { $invalid = true; } } ?> <form id="loginform" action="index.php" method="post"> <p>Login:</p> <p><label>username: <input id="username" name="username" type="text" value="jeremy" /></label></p> <p><label>password: <input id="password" name="password" type="password" value="12345" /></label></p> <p><input id="submit" type="submit" /></p>
public function callback() { global_run(); require_once APP_ROOT_PATH . 'system/api_login/sina/saetv2.ex.class.php'; //$sina_keys = es_session::get("sina_keys"); $o = new SaeTOAuthV2($this->api['config']['app_key'], $this->api['config']['app_secret']); if (isset($_REQUEST['code'])) { $keys = array(); $keys['code'] = $_REQUEST['code']; if ($this->api['config']['app_url'] == "") { $app_url = SITE_DOMAIN . APP_ROOT . "/api_callback.php?c=Sina"; } else { $app_url = $this->api['config']['app_url']; } $keys['redirect_uri'] = $app_url; try { $token = $o->getAccessToken('code', $keys); } catch (OAuthException $e) { //print_r($e);exit; showErr("授权失败,错误信息:" . $e->getMessage()); die; } } $c = new SaeTClientV2($this->api['config']['app_key'], $this->api['config']['app_secret'], $token['access_token']); $ms = $c->home_timeline(); // done $uid_get = $c->get_uid(); $uid = $uid_get['uid']; $msg = $c->show_user_by_id($uid); //根据ID获取用户等基本信息 if (intval($msg['error_code']) != 0) { showErr("授权失败,错误代码:" . $msg['error_code']); die; } $msg['field'] = 'sina_id'; $msg['sina_token'] = $token['access_token']; es_session::set("api_user_info", $msg); if (!$msg['name']) { app_redirect(url("index")); exit; } //print_r($msg);die(); $user_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where sina_id = '" . $msg['id'] . "' and sina_id <> '' and is_effect=1 and is_delete=0"); $is_bind = intval(es_session::get("is_bind")); if ($user_data) { $GLOBALS['db']->query("update " . DB_PREFIX . "user set sina_token = '" . $token['access_token'] . "',login_ip = '" . CLIENT_IP . "',login_time= " . NOW_TIME . " where id =" . $user_data['id']); es_session::delete("api_user_info"); if ($is_bind) { if (intval($user_data['id']) != intval($GLOBALS['user_info']['id'])) { showErr("该帐号已经被别的会员绑定过,请直接用帐号登录", 0, url("index", "uc_account")); } else { require_once APP_ROOT_PATH . "system/model/user.php"; load_user($user_data['id'], true); es_session::set("user_info", $user_data); app_redirect(url("index", "uc_account")); } } else { require_once APP_ROOT_PATH . "system/model/user.php"; auto_do_login_user($user_data['user_name'], $user_data['user_pwd'], $from_cookie = false); app_redirect(url("index", "index")); } } elseif ($is_bind == 1 && $GLOBALS['user_info']) { //当有用户身份且要求绑定时 $GLOBALS['db']->query("update " . DB_PREFIX . "user set sina_id= '" . $msg['id'] . "', sina_token ='" . $token['access_token'] . "' where id =" . $GLOBALS['user_info']['id']); require_once APP_ROOT_PATH . "system/model/user.php"; load_user($GLOBALS['user_info']['id'], true); app_redirect(url("index", "uc_account")); } else { $user_info = $this->create_user(); require_once APP_ROOT_PATH . "system/model/user.php"; auto_do_login_user($user_info['user_name'], $user_info['user_pwd'], $from_cookie = false); app_redirect(url("index", "index")); } }
function do_send_pass() { global $input, $message; if ($user = load_user($input['name'])) { if ($user['name'] == $input['name'] && $user['email'] == $input['email']) { $message = lang('commentuser', 'pass_sent'); mail_pass($user); do_show_login(); } else { $message = lang('commentuser', 'user_pass_nomatch'); do_show_login(); } } else { $message = lang('commentuser', 'user_pass_nomatch'); do_show_login(); } }