/** * author: 微赞科技 * 中奖记录导出 */ public function doWebRDownload() { global $_W, $_GPC; $egid = $_GPC['egid']; $pid = $_GPC['pid']; $where = ''; $params = array(); $params[':egid'] = $egid; $status = $_GPC['status']; $ptype = $_GPC['ptype']; if ($_GPC['uid'] != '') { $where .= ' AND r.uid =:uid'; $params[':uid'] = $_GPC['uid']; } if ($pid != 0 && !empty($pid)) { $where .= ' AND r.pid =:pid'; $params[':pid'] = $pid; } if ($status == '') { $status = -1; } if ($status != -1) { $where .= ' AND r.status =:status'; $params[':status'] = $status; } if ($ptype != 0 && !empty($ptype)) { $where .= ' AND p.ptype =:ptype'; $params[':ptype'] = $ptype; } $list = pdo_fetchall("SELECT r.*,r.id as rid, p.ptype,p.jf , p.pname as ppname, (select u.uname from " . tablename(DBUtil::$TABLE_EGG_USER) . " u where u.id= r.uid) as uname, (select u2.tel from " . tablename(DBUtil::$TABLE_EGG_USER) . " u2 where u2.id= r.uid) as tel,(select u3.nickname from " . tablename(DBUtil::$TABLE_EGG_USER) . " u3 where u3.id= r.uid) as nickname FROM " . tablename(DBUtil::$TABLE_EGG_RECORD) . " r left join " . tablename(DBUtil::$TABLE_EGG_PRIZE) . " p on p.id = r.pid WHERE r.egid =:egid" . $where . " ORDER BY r.createtime DESC, r.id DESC ", $params); $i = 0; foreach ($list as $key => $value) { $arr[$i]['openid'] = $value['openid']; $arr[$i]['nickname'] = $value['nickname']; $arr[$i]['uname'] = $value['uname']; $arr[$i]['tel'] = $value['tel']; if ($value['ptype'] == 1) { $arr[$i]['ptype'] = '实物'; } if ($value['ptype'] == 2) { $arr[$i]['ptype'] = '积分'; } if ($value['ptype'] == 1) { $arr[$i]['jf'] = '-'; } else { if ($value['ptype'] == 2) { $arr[$i]['jf'] = $value['jf']; } } if ($value['status'] == self::$STATUS_UNKNOW) { $arr[$i]['status'] = '未中奖'; } if ($value['status'] == self::$STATUS_ZJ) { $arr[$i]['status'] = '已中奖'; } if ($value['status'] == self::$STATUS_DH) { $arr[$i]['status'] = '已兑换'; } $arr[$i]['createtime'] = date('Y-m-d H:i:s', $value['createtime']); $arr[$i]['dhtime'] = date('Y-m-d H:i:s', $value['dhtime']); $i++; } MonUtil::exportexcel($arr, array('openID', '昵称', '姓名', '手机', '物品类型', '积分', '状态', '中奖时间', '兑换时间'), '中奖记录'); }