public function fund_export_csv($page = 1) { set_time_limit(0); $limit = ($page - 1) * intval(app_conf("BATCH_PAGE_SIZE")) . "," . intval(app_conf("BATCH_PAGE_SIZE")); //定义条件 $title_arrays = array("0" => "结存", "1" => "充值", "2" => "投标成功", "3" => "招标成功", "4" => "偿还本息", "5" => "回收本息", "6" => "提前还款", "7" => "提前回收", "8" => "申请提现", "9" => "提现手续费", "10" => "借款管理费", "11" => "逾期罚息", "12" => "逾期管理费", "13" => "人工操作", "14" => "借款服务费", "15" => "出售债权", "16" => "购买债权", "17" => "债权转让管理费", "18" => "开户奖励", "19" => "流标还返", "20" => "投标管理费", "21" => "投标逾期收入", "23" => "邀请返利", "24" => "投标返利", "25" => "签到成功", "26" => "逾期罚金(垫付后)", "27" => "其他费用", "28" => "投资奖励", "26" => "红包奖励"); $cate = isset($_REQUEST['cate']) ? intval($_REQUEST['cate']) >= 0 ? intval($_REQUEST['cate']) : -1 : -1; $extWhere = " 1=1 "; if ($cate >= 0) { $extWhere .= " AND type = " . $cate; } if (trim($_REQUEST['user_names']) != '') { $extWhere .= " and u.user_name like '%" . trim($_REQUEST['user_names']) . "%'"; } $begin_time = !isset($_REQUEST['begin_time']) ? 0 : (trim($_REQUEST['begin_time']) == "" ? 0 : to_timespan($_REQUEST['begin_time'], "Y-m-d")); $end_time = !isset($_REQUEST['end_time']) ? 0 : (trim($_REQUEST['end_time']) == "" ? 0 : to_timespan($_REQUEST['end_time'], "Y-m-d")); if ($begin_time > 0 || $end_time > 0) { if ($end_time == 0) { $extWhere .= " and uml.create_time >= {$begin_time} "; } else { $extWhere .= " and uml.create_time between {$begin_time} and {$end_time} "; } } $_REQUEST['begin_time'] = to_date($begin_time, "Y-m-d"); $_REQUEST['end_time'] = to_date($end_time, "Y-m-d"); $list = $GLOBALS['db']->getAll("select uml.*,u.user_name from " . DB_PREFIX . "user_money_log uml left join " . DB_PREFIX . "user u on uml.user_id=u.id where {$extWhere} order by id desc LIMIT " . $limit); foreach ($list as $k => $v) { $n = $list[$k]['type']; $list[$k]['type_format'] = $title_arrays[$n]; } if ($list) { register_shutdown_function(array(&$this, 'fund_export_csv'), $page + 1); $user_value = array('id' => '""', 'user_id' => '""', 'type_format' => '""', 'money' => '""', 'account_money' => '""', 'memo' => '""', 'create_time_ymd' => '""'); if ($page == 1) { $content = iconv("utf-8", "gbk", "编号,会员名,类型,操作金额,余额,备注,操作时间"); } $content = $content . "\n"; foreach ($list as $k => $v) { $fund_list = array(); $fund_list['id'] = iconv('utf-8', 'gbk', '"' . $v['id'] . '"'); $fund_list['user_name'] = iconv('utf-8', 'gbk', '"' . get_user_name_reals($v['user_id']) . '"'); $fund_list['type_format'] = iconv('utf-8', 'gbk', '"' . $v['type_format'] . '"'); $fund_list['money'] = iconv('utf-8', 'gbk', '"' . format_price($v['money']) . '"'); $fund_list['account_money'] = iconv('utf-8', 'gbk', '"' . format_price($v['account_money']) . '"'); $fund_list['memo'] = iconv('utf-8', 'gbk', '"' . $v['memo'] . '"'); $fund_list['create_time_ymd'] = iconv('utf-8', 'gbk', '"' . $v['create_time_ymd'] . '"'); $content .= implode(",", $fund_list) . "\n"; } header("Content-Disposition: attachment; filename=fund_list.csv"); echo $content; } else { if ($page == 1) { $this->error(L("NO_RESULT")); } } }
public function export_csv_site_money($page = 1) { set_time_limit(0); $limit = ($page - 1) * intval(app_conf("BATCH_PAGE_SIZE")) . "," . intval(app_conf("BATCH_PAGE_SIZE")); $type_name = array("9" => "提现手续费", "10" => "借款管理费", "12" => "逾期管理费", "13" => "人工操作", "14" => "借款服务费", "17" => "债权转让管理费", "18" => "开户奖励", "20" => "投标管理费", "23" => "邀请返利", "24" => "投标返利", "25" => "签到成功", "26" => "逾期罚金(垫付后)", "27" => "其他费用", "28" => "投资奖励", "29" => "红包奖励"); //定义条件 $begin_time = !isset($_REQUEST['begin_time']) ? 0 : (trim($_REQUEST['begin_time']) == "" ? 0 : to_timespan($_REQUEST['begin_time'], "Y-m-d")); $end_time = !isset($_REQUEST['end_time']) ? 0 : (trim($_REQUEST['end_time']) == "" ? 0 : to_timespan($_REQUEST['end_time'], "Y-m-d")); $status = !isset($_REQUEST['status']) ? 0 : (trim($_REQUEST['status']) == "" ? 0 : intval($_REQUEST['status'])); $condition = " 1=1 "; if ($status > 0) { $condition .= " AND type=" . $status; } if ($begin_time > 0 || $end_time > 0) { if ($end_time == 0) { $condition .= " and s.create_time >= {$begin_time} "; } else { $condition .= " and s.create_time between {$begin_time} and {$end_time} "; } } $_REQUEST['begin_time'] = to_date($begin_time, "Y-m-d"); $_REQUEST['end_time'] = to_date($end_time, "Y-m-d"); if (trim($_REQUEST['user_name']) != '') { $condition .= " and u.user_name like '%" . trim($_REQUEST['user_name']) . "%'"; } $sql_list = " select s.* ,u.user_name\r\n\t\t\t\t\t\tfrom " . DB_PREFIX . "site_money_log s left join " . DB_PREFIX . "user u on u.id=s.user_id\r\n\t\t\t\t\t\t\tWHERE {$condition} ORDER BY id desc "; $list = $GLOBALS['db']->getAll($sql_list); foreach ($list as $k => $v) { $list[$k]['type_format'] = $type_name[$v['type']]; } if ($list) { register_shutdown_function(array(&$this, 'export_csv'), $page + 1); $referrals_value = array('id' => '""', 'type_format' => '""', 'user_id' => '""', 'money' => '""', 'memo' => '""', 'create_time' => '""'); if ($page == 1) { $content = iconv("utf-8", "gbk", "编号,类型,关联用户,操作金额,操作备注,操作时间"); } $content = $content . "\n"; foreach ($list as $k => $v) { $site_money_list = array(); $site_money_list['id'] = iconv('utf-8', 'gbk', '"' . $v['id'] . '"'); $site_money_list['type_format'] = iconv('utf-8', 'gbk', '"' . $v['type_format'] . '"'); $site_money_list['user_id'] = iconv('utf-8', 'gbk', '"' . get_user_name_reals($v['user_id']) . '"'); $site_money_list['money'] = iconv('utf-8', 'gbk', '"' . $v['money'] . '"'); $site_money_list['memo'] = iconv('utf-8', 'gbk', '"' . $v['memo'] . '"'); $site_money_list['create_time'] = iconv('utf-8', 'gbk', '"' . to_date($v['create_time']) . '"'); $content .= implode(",", $site_money_list) . "\n"; } header("Content-Disposition: attachment; filename=site_money_list.csv"); echo $content; } else { if ($page == 1) { $this->error(L("NO_RESULT")); } } }
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")); //定义条件 $condition = " u.user_type in(0,1) AND r.pid > 0 "; if ($user_name !== "" && $user_name != 0) { $condition .= " and u.user_name like '%" . $user_name . "%' "; } $sql = "SELECT u.*,us.load_money,us.load_count,us.repay_deal_count,us.repay_amount FROM " . DB_PREFIX . "user u LEFT JOIN " . DB_PREFIX . "user r On r.pid =u.id left join " . DB_PREFIX . "user_sta us on u.id = us.user_id WHERE {$condition} GROUP BY u.id LIMIT " . $limit; $list = $GLOBALS['db']->getAll($sql); foreach ($list as $k => $v) { $list[$k]['pidcount'] = $GLOBALS['db']->getOne("SELECT count(*) FROM " . DB_PREFIX . "user where pid = " . $v['id']); //提成 $list[$k]['percentage'] = $GLOBALS['db']->getOne("SELECT sum(money) FROM " . DB_PREFIX . "referrals WHERE rel_user_id=" . $v['id'] . " AND pay_time >0 "); } if ($list) { register_shutdown_function(array(&$this, 'export_csv'), $page + 1); $user_value = array('id' => '""', 'id' => '""', 'pidcount' => '""', 'load_count' => '""', 'load_money' => '""', 'percentage' => '""', 'repay_deal_count' => '""', 'repay_amount' => '""'); if ($page == 1) { $content = iconv("utf-8", "gbk", "编号,推广人,推广人数,投资次数,投资总额,投资提成,还款次数,还款总额"); } $content = $content . "\n"; foreach ($list as $k => $v) { $promotion_human = array(); $promotion_human['id'] = iconv('utf-8', 'gbk', '"' . $v['id'] . '"'); $promotion_human['user_name'] = iconv('utf-8', 'gbk', '"' . get_user_name_reals($v['id']) . '"'); $promotion_human['pidcount'] = iconv('utf-8', 'gbk', '"' . $v['pidcount'] . '"'); $promotion_human['load_count'] = iconv('utf-8', 'gbk', '"' . $v['load_count'] . '"'); $promotion_human['load_money'] = iconv('utf-8', 'gbk', '"' . format_price($v['load_money']) . '"'); $promotion_human['percentage'] = iconv('utf-8', 'gbk', '"' . format_price($v['percentage']) . '"'); $promotion_human['repay_deal_count'] = iconv('utf-8', 'gbk', '"' . $v['repay_deal_count'] . '"'); $promotion_human['repay_amount'] = iconv('utf-8', 'gbk', '"' . format_price($v['repay_amount']) . '"'); $content .= implode(",", $promotion_human) . "\n"; } header("Content-Disposition: attachment; filename=promotion_human.csv"); echo $content; } else { if ($page == 1) { $this->error(L("NO_RESULT")); } } }
public function score_export_csv($page = 1) { set_time_limit(0); $limit = ($page - 1) * intval(app_conf("BATCH_PAGE_SIZE")) . "," . intval(app_conf("BATCH_PAGE_SIZE")); //定义条件 if (trim($_REQUEST['user_name']) != '') { $sql = "select group_concat(id) from " . DB_PREFIX . "user where user_name like '%" . trim($_REQUEST['user_name']) . "%'"; $ids = $GLOBALS['db']->getOne($sql); $map[DB_PREFIX . 'score_exchange_record.user_id'] = array("in", $ids); } $begin_time = trim($_REQUEST['begin_time']); $end_time = trim($_REQUEST['end_time']); if ($begin_time != '' || $end_time != '') { if ($end_time == 0) { $map[DB_PREFIX . 'score_exchange_record.exchange_date'] = array('egt', $begin_time); } else { $map[DB_PREFIX . 'score_exchange_record.exchange_date'] = array("between", array($begin_time, $end_time)); } } $list = M("ScoreExchangeRecord")->where($map)->limit($limit)->findAll(); if ($list) { register_shutdown_function(array(&$this, 'export_csv_score'), $page + 1); $score_list = array('id' => '""', 'user_id' => '""', 'vip_id' => '""', 'integral' => '""', 'cash' => '""', 'exchange_date' => '""'); if ($page == 1) { $content = iconv("utf-8", "gbk", "编号,VIP会员,VIP等级,兑现积分,兑现金额,兑现日期"); } if ($page == 1) { $content = $content . "\n"; } foreach ($list as $k => $v) { $list[$k]['integral'] = $list[$k]['integral'] . " 积分"; $list[$k]['vip_id'] = M("VipType")->where(" id=" . $list[$k]['vip_id'])->getField("vip_grade"); $score_list = array(); $score_list['id'] = iconv('utf-8', 'gbk', '"' . $list[$k]['id'] . '"'); $score_list['user_id'] = iconv('utf-8', 'gbk', '"' . get_user_name_reals($v['user_id']) . '"'); $score_list['vip_id'] = iconv('utf-8', 'gbk', '"' . $list[$k]['vip_id'] . '"'); $score_list['integral'] = iconv('utf-8', 'gbk', '"' . $list[$k]['integral'] . '"'); $score_list['cash'] = iconv('utf-8', 'gbk', '"' . format_price($v['cash']) . '"'); $score_list['exchange_date'] = iconv('utf-8', 'gbk', '"' . $v['exchange_date'] . '"'); $content .= implode(",", $welfare_value) . "\n"; } header("Content-Disposition: attachment; filename=score_list.csv"); echo $content; } else { if ($page == 1) { $this->error(L("NO_RESULT")); } } }
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")); //定义条件 $log_begin_time = trim($_REQUEST['log_begin_time']) == '' ? 0 : to_timespan($_REQUEST['log_begin_time']); $log_end_time = trim($_REQUEST['log_end_time']) == '' ? 0 : to_timespan($_REQUEST['log_end_time']); $condtion = " "; if ($log_begin_time > 0 && $log_end_time == 0) { $condtion .= " and r.repay_time > {$log_begin_time} "; } elseif ($log_begin_time == 0 && $log_end_time > 0) { $condtion .= " and r.repay_time < {$log_begin_time} "; } elseif ($log_begin_time > 0 && $log_end_time > 0) { $condtion .= " and (r.repay_time between {$log_begin_time} and {$log_end_time} )"; } $sql = "SELECT r.*,r.l_key +1 as l_key,u.referral_rate,dlr.true_interest_money,dlr.true_self_money,dlr.repay_date FROM " . DB_PREFIX . "referrals r " . "LEFT JOIN " . DB_PREFIX . "deal d ON d.id =r.deal_id " . "LEFT JOIN " . DB_PREFIX . "deal_load_repay dlr ON dlr.l_key =r.l_key AND dlr.load_id=r.load_id " . "LEFT JOIN " . DB_PREFIX . "user u ON u.id =r.user_id " . "WHERE 1=1 {$condtion} ORDER BY r.id DESC LIMIT " . $limit; $list = $GLOBALS['db']->getAll($sql); if ($list) { register_shutdown_function(array(&$this, 'export_csv'), $page + 1); $referrals_value = array('id' => '""', 'rel_user_id' => '""', 'user_id' => '""', 'true_self_money' => '""', 'true_interest_money' => '""', 'referral_rate' => '""', 'referral_type' => '""', 'money' => '""', 'deal_id' => '""', 'load_id' => '""', 'l_key' => '""', 'repay_date' => '""', 'pay_time' => '""'); if ($page == 1) { $content = iconv("utf-8", "gbk", "编号,推荐人,投资人,本金总额,利息总额,抽成比%,返利方式,返利金额,借款,投标编号,第几期,返利时间,返利发放时间"); } $content = $content . "\n"; foreach ($list as $k => $v) { $deal_name = D("Deal")->where("id=" . $v['deal_id'])->getfield("name"); $referrals_value = array(); $referrals_value['id'] = iconv('utf-8', 'gbk', '"' . $v['id'] . '"'); $referrals_value['rel_user_id'] = iconv('utf-8', 'gbk', '"' . get_user_name_reals($v['rel_user_id']) . '"'); $referrals_value['user_id'] = iconv('utf-8', 'gbk', '"' . get_user_name_reals($v['user_id']) . '"'); $referrals_value['true_self_money'] = iconv('utf-8', 'gbk', '"' . format_price($v['true_self_money']) . '"'); $referrals_value['true_interest_money'] = iconv('utf-8', 'gbk', '"' . format_price($v['true_interest_money']) . '"'); $referrals_value['referral_rate'] = iconv('utf-8', 'gbk', '"' . $v['referral_rate'] . '"'); $referrals_value['referral_type'] = iconv('utf-8', 'gbk', '"' . get_referral_type($v['referral_type']) . '"'); $referrals_value['money'] = iconv('utf-8', 'gbk', '"' . $v['money'] . '"'); $referrals_value['deal_id'] = iconv('utf-8', 'gbk', '"' . $deal_name . '"'); $referrals_value['load_id'] = iconv('utf-8', 'gbk', '"' . $v['load_id'] . '"'); $referrals_value['l_key'] = iconv('utf-8', 'gbk', '"' . $v['l_key'] . '"'); $referrals_value['repay_date'] = iconv('utf-8', 'gbk', '"' . $v['repay_date'] . '"'); $referrals_value['pay_time'] = iconv('utf-8', 'gbk', '"' . to_date($v['pay_time']) . '"'); $content .= implode(",", $referrals_value) . "\n"; } header("Content-Disposition: attachment; filename=referrals_list.csv"); echo $content; } else { if ($page == 1) { $this->error(L("NO_RESULT")); } } }
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")); //定义条件 $user_name = strim($_REQUEST['user_name']); $condition = " ( ru.user_type in (0,1) OR u.pid = 0 ) and u.user_type IN (0,1) "; if ($user_name != "") { $condition .= " and u.user_name like '%" . $user_name . "%' "; } $sql = "SELECT u.id,u.user_name,u.email,u.pid,u.referer_memo,u.referral_rate FROM " . DB_PREFIX . "user u left join " . DB_PREFIX . "user ru ON ru.id =u.pid WHERE {$condition} LIMIT " . $limit; $list = $GLOBALS['db']->getAll($sql); foreach ($list as $k => $v) { if ($list[$k]['pid'] == 0) { $list[$k]['status'] = "未关联"; } else { $list[$k]['status'] = "已关联"; } $list[$k]['humans'] = get_user_name_reals($list[$k]['pid']); } if ($list) { register_shutdown_function(array(&$this, 'export_csv'), $page + 1); $user_value = array('id' => '""', 'id' => '""', 'email' => '""', 'status' => '""', 'humans' => '""', 'referer_memo' => '""', 'referral_rate' => '""'); if ($page == 1) { $content = iconv("utf-8", "gbk", "编号,用户名,邮箱,状态,推广人,备注,返利%"); } $content = $content . "\n"; foreach ($list as $k => $v) { $create_relevance = array(); $create_relevance['id'] = iconv('utf-8', 'gbk', '"' . $v['id'] . '"'); $create_relevance['user_name'] = iconv('utf-8', 'gbk', '"' . get_user_name_reals($v['id']) . '"'); $create_relevance['email'] = iconv('utf-8', 'gbk', '"' . $v['email'] . '"'); $create_relevance['status'] = iconv('utf-8', 'gbk', '"' . $v['status'] . '"'); $create_relevance['humans'] = iconv('utf-8', 'gbk', '"' . $v['humans'] . '"'); $create_relevance['referer_memo'] = iconv('utf-8', 'gbk', '"' . $v['referer_memo'] . '"'); $create_relevance['referral_rate'] = iconv('utf-8', 'gbk', '"' . $v['referral_rate'] . '"'); $content .= implode(",", $create_relevance) . "\n"; } header("Content-Disposition: attachment; filename=create_relevance.csv"); echo $content; } else { if ($page == 1) { $this->error(L("NO_RESULT")); } } }
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")); //定义条件 if (trim($_REQUEST['user_name']) != '') { $sql = "select group_concat(id) from " . DB_PREFIX . "user where user_name like '%" . trim($_REQUEST['user_name']) . "%'"; $ids = $GLOBALS['db']->getOne($sql); $map[DB_PREFIX . 'gift_record.user_id'] = array("in", $ids); } if (trim($_REQUEST['name']) != '') { $sql = "select group_concat(id) from " . DB_PREFIX . "deal where name like '%" . trim($_REQUEST['name']) . "%'"; $idss = $GLOBALS['db']->getOne($sql); $map[DB_PREFIX . 'gift_record.deal_id'] = array("in", $idss); } if (isset($_REQUEST['gift_type'])) { if (intval($_REQUEST['gift_type']) == -1) { } elseif (intval($_REQUEST['gift_type']) == 1) { $map[DB_PREFIX . 'gift_record.gift_type'] = array("eq", 1); } elseif (intval($_REQUEST['gift_type']) == 2) { $map[DB_PREFIX . 'gift_record.gift_type'] = array("eq", 2); } elseif (intval($_REQUEST['gift_type']) == 3) { $map[DB_PREFIX . 'gift_record.gift_type'] = array("eq", 3); } elseif (intval($_REQUEST['gift_type']) == 4) { $map[DB_PREFIX . 'gift_record.gift_type'] = array("eq", 4); } } $begin_time = trim($_REQUEST['begin_time']); $end_time = trim($_REQUEST['end_time']); if ($begin_time != '' || $end_time != '') { if ($end_time == 0) { $map[DB_PREFIX . 'gift_record.release_date'] = array('egt', $begin_time); } else { $map[DB_PREFIX . 'gift_record.release_date'] = array("between", array($begin_time, $end_time)); } } $list = M("GiftRecord")->where($map)->limit($limit)->findAll(); if ($list) { register_shutdown_function(array(&$this, 'export_csv'), $page + 1); $gift_value = array('id' => '""', 'deal_id' => '""', 'user_id' => '""', 'gift_type' => '""', 'gift_value' => '""', 'status' => '""', 'release_date' => '""'); if ($page == 1) { $content = iconv("utf-8", "gbk", "编号,标题,用户名,收益类型,收益值,发放状态,发放时间"); } if ($page == 1) { $content = $content . "\n"; } foreach ($list as $k => $v) { if ($list[$k]['gift_type'] == 1) { $list[$k]['gift_value'] = $v['gift_value'] . " 元"; } elseif ($list[$k]['gift_type'] == 2) { if ($list[$k]['reward_money'] != 0) { $list[$k]['gift_value'] = $v['gift_value'] . "% (金额" . $list[$k]['reward_money'] . " 元)"; } else { $reward_money = M("DealLoadRepay")->where(" load_id=" . $list[$k]['load_id'])->getField("reward_money"); if ($reward_money != 0) { $list[$k]['gift_value'] = $list[$k]['gift_value'] . "% (金额" . $reward_money . " 元)"; } else { $list[$k]['gift_value'] = $list[$k]['gift_value'] . "%"; } } } elseif ($list[$k]['gift_type'] == 3) { $list[$k]['gift_value'] = $v['gift_value'] . " 积分"; } elseif ($list[$k]['gift_type'] == 4) { $name = M("VipGift")->where(" id=" . $list[$k]['gift_value'])->getField("name"); $list[$k]['gift_value'] = $name; } if ($list[$k]['gift_type'] == 1) { $list[$k]['gift_type'] = "红包"; } elseif ($list[$k]['gift_type'] == 2) { $list[$k]['gift_type'] = "收益率"; } elseif ($list[$k]['gift_type'] == 3) { $list[$k]['gift_type'] = "积分"; } elseif ($list[$k]['gift_type'] == 4) { $list[$k]['gift_type'] = "礼品"; } if ($list[$k]['status'] == 1) { $list[$k]['status'] = "已发放"; } else { $list[$k]['status'] = "未发放"; } $deal_name = M("Deal")->where(" id=" . $list[$k]['deal_id'])->getField("name"); $gift_value = array(); $gift_value['id'] = iconv('utf-8', 'gbk', '"' . $v['id'] . '"'); $gift_value['deal_id'] = iconv('utf-8', 'gbk', '"' . $deal_name . '"'); $gift_value['user_id'] = iconv('utf-8', 'gbk', '"' . get_user_name_reals($list[$k]['user_id']) . '"'); $gift_value['gift_type'] = iconv('utf-8', 'gbk', '"' . $list[$k]['gift_type'] . '"'); $gift_value['gift_value'] = iconv('utf-8', 'gbk', '"' . $list[$k]['gift_value'] . '"'); $gift_value['status'] = iconv('utf-8', 'gbk', '"' . $list[$k]['status'] . '"'); $gift_value['release_date'] = iconv('utf-8', 'gbk', '"' . $v['release_date'] . '"'); $content .= implode(",", $gift_value) . "\n"; } header("Content-Disposition: attachment; filename=gift_list.csv"); echo $content; } else { if ($page == 1) { $this->error(L("NO_RESULT")); } } }
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")); //定义条件 $list = M("GoodsOrder")->where($map)->limit($limit)->findAll(); foreach ($list as $k => $v) { if ($list[$k]['is_delivery'] == 0) { $list[$k]['is_delivery_format'] = "否"; } else { $list[$k]['is_delivery_format'] = "是"; } if ($list[$k]['order_status'] == 0) { $list[$k]['order_status_format'] = "未发货"; } elseif ($list[$k]['order_status'] == 1) { $list[$k]['order_status_format'] = "已发货"; } elseif ($list[$k]['order_status'] == 2) { $list[$k]['order_status_format'] = "无效订单"; } elseif ($list[$k]['order_status'] == 3) { $list[$k]['order_status_format'] = "用户删除"; } $list[$k]['user_name'] = get_user_name_reals($list[$k]['user_id']); } if ($list) { register_shutdown_function(array(&$this, 'export_csv'), $page + 1); $order_list = array('id' => '""', 'order_sn' => '""', 'goods_name' => '""', 'user_name' => '""', 'total_score' => '""', 'ex_time' => '""', 'delivery_time' => '""', 'order_status_format' => '""', 'is_delivery_format' => '""'); if ($page == 1) { $content = iconv("utf-8", "gbk", "编号,订单号,商品名称,会员名,所需积分,兑换时间,发货时间,订单状态,是否配送"); } if ($page == 1) { $content = $content . "\n"; } foreach ($list as $k => $v) { $order_list = array(); $order_list['id'] = iconv('utf-8', 'gbk', '"' . $v['id'] . '"'); $order_list['order_sn'] = iconv('utf-8', 'gbk', '"' . $v['order_sn'] . '"'); $order_list['goods_name'] = iconv('utf-8', 'gbk', '"' . $v['goods_name'] . '"'); $order_list['user_name'] = iconv('utf-8', 'gbk', '"' . $v['user_name'] . '"'); $order_list['total_score'] = iconv('utf-8', 'gbk', '"' . $v['total_score'] . '"'); $order_list['ex_time'] = iconv('utf-8', 'gbk', '"' . to_date($v['ex_time']) . '"'); $order_list['delivery_time'] = iconv('utf-8', 'gbk', '"' . to_date($v['delivery_time']) . '"'); $order_list['order_status_format'] = iconv('utf-8', 'gbk', '"' . $v['order_status_format'] . '"'); $order_list['is_delivery_format'] = iconv('utf-8', 'gbk', '"' . $v['is_delivery_format'] . '"'); $content .= implode(",", $order_list) . "\n"; } header("Content-Disposition: attachment; filename=order_list.csv"); echo $content; } else { if ($page == 1) { $this->error(L("NO_RESULT")); } } }