Exemple #1
0
 public function expAction()
 {
     $orderid = reqstr('orderid', '');
     $username = reqstr('username', '');
     $id = reqstr('id', '');
     $where = '1=1 and flag=1';
     if (!empty($orderid)) {
         $where .= " and orderid='" . $orderid . "'";
     }
     if (!empty($username)) {
         $where .= ' and username='******',');
         $where .= " and id in (" . $id . ")";
     }
     $page = reqnum("page", 1);
     $pagesize = reqnum("pagesize", 1000);
     $m = new Psys_UserModel();
     $list = $m->GetList($where, '', $page, $pagesize, "id,username,mark,goodsid,num,ctime", 'rhi_mallorder');
     global $G_X;
     $filestr = 'charge' . date('YmdHis') . uniqid() . '.csv';
     $filename = PUBLIC_PATH . $G_X['prjstr'] . DIRECTORY_SEPARATOR . $filestr;
     //设置文件名
     if (!file_exists($filename)) {
         touch($filename);
         chmod($filename, 0777);
     }
     $fp = fopen($filename, 'w');
     $title = array("序号", "电话号码", '发放号码', '商品id', '数目', '兑换时间');
     foreach ($title as &$value) {
         $value = iconv('utf-8', 'gb2312', $value);
     }
     fputcsv($fp, $title);
     if ($list['allrow']) {
         foreach ($list['allrow'] as &$row) {
             $row['ctime'] = date('Y-m-d H:i:s', $row['ctime']);
             if (fputcsv($fp, $row)) {
                 $m->UpdateOne(array('ifuse' => 1), array('id' => $row['id']), 'rhi_mallorder');
             }
         }
     }
     fclose($fp);
     // 		header('Content-Type: application/octet-stream');
     // 		header('Content-Disposition: attachment; filename=' . $filestr);
     // 		header('Content-Transfer-Encoding: binary');
     // 		header('Content-Length: ' . filesize($fileName));
     // 		readfile($filename);
     return array('status' => 1, 'filename' => $filestr);
 }
Exemple #2
0
 public function expAction()
 {
     $appkey = reqstr('appkey', '');
     $username = reqstr('username', '');
     $moeny = reqstr('moeny', '');
     $isreceive = reqstr('isreceive');
     $isgive = '0';
     $indate = reqstr('indate', 0);
     $todate = reqstr('todate', 0);
     $where = '1=1 and flag=1';
     if (!empty($appkey)) {
         $where .= " and appkey='" . $appkey . "'";
     }
     if (!empty($moeny)) {
         $where .= ' and moeny=' . $moeny;
     }
     if (!empty($isreceive) || $isreceive === '0') {
         $where .= ' and isreceive=' . $isreceive;
     }
     if (!empty($isgive) || $isgive === '0') {
         $where .= ' and isgive=' . $isgive;
     }
     if (!empty($username)) {
         $where .= " and username='******'";
     }
     if ($indate > 0) {
         $where .= ' and ctime > ' . strtotime($indate);
     }
     if ($todate > 0) {
         $where .= ' and ctime <= ' . strtotime($todate);
     }
     $page = reqnum("page", 1);
     $pagesize = reqnum("pagesize", 1000);
     $m = new Psys_UserModel();
     $list = $m->GetList($where, 'id DESC', $page, $pagesize, "id,username,receiveno,moeny,ctime", 'rhi_useraward');
     global $G_X;
     $filestr = 'award' . date('YmdHis') . uniqid() . '.csv';
     $filename = PUBLIC_PATH . $G_X['prjstr'] . DIRECTORY_SEPARATOR . $filestr;
     //设置文件名
     if (!file_exists($filename)) {
         touch($filename);
         chmod($filename, 0777);
     }
     $fp = fopen($filename, 'w');
     $title = array("序号", "电话号码", '发放号码', '中奖金额', '更新时间');
     foreach ($title as &$value) {
         $value = iconv('utf-8', 'gb2312', $value);
     }
     fputcsv($fp, $title);
     if ($list['allrow']) {
         foreach ($list['allrow'] as &$row) {
             $row['ctime'] = date('Y-m-d H:i:s', $row['ctime']);
             if (fputcsv($fp, $row)) {
                 $m->UpdateOne(array('isgive' => 1), array('id' => $row['id']), 'rhi_useraward');
             }
         }
     }
     fclose($fp);
     // 		header('Content-Type: application/octet-stream');
     // 		header('Content-Disposition: attachment; filename=' . $filestr);
     // 		header('Content-Transfer-Encoding: binary');
     // 		header('Content-Length: ' . filesize($fileName));
     // 		readfile($filename);
     return array('status' => 1, 'filename' => $filestr);
 }