/** * 导出流水 */ public function exportAction() { $iType = (int) $this->getParam('type'); $iPage = max(1, intval($this->getParam('page'))); $aWhere = array('iUserID' => $this->aCurrUser['iUserID'], 'iStatus' => 1); if ($iType > 0 && $iType < 3) { $aWhere['iPayment'] = $iType; } $aList = Model_Finance::getAll(array('where' => $aWhere, 'order' => 'iAutoID DESC')); $aSource = Model_Finance::getSources(); $aPayment = Model_Finance::getPayments(); $aData = array(); foreach ($aList as $v) { $aData[] = array('iAutoID' => $v['iAutoID'], 'iTime' => date('Y-m-d H:i:s', $v['iCreateTime']), 'sType' => $aPayment[$v['iPayment']], 'iPayMoney' => $v['iPayMoney'], 'iUserMoney' => $v['iUserMoney'], 'sSource' => $aSource[$v['iSource']], 'sRemark' => $v['sRemark']); } $aTitle = array('iAutoID' => '订单编号', 'iTime' => '时间', 'sType' => '分类', 'iPayMoney' => '金额', 'iUserMoney' => '当前余额', 'sSource' => '账单明细', 'sRemark' => '备注'); Util_File::exportCsv('财务流水-' . date('Ymd') . '.csv', $aData, $aTitle); return false; }
/** * 导出 */ public function explodeAction() { $uWhere = array(); $aParam = $this->getParams(); $userid = ''; if (!empty($aParam['sRealName'])) { $uWhere['sRealName LIKE'] = '%' . $aParam['sRealName'] . '%'; $data_user = Model_User::getAll(array('where' => $uWhere)); $useridArr = array(); foreach ($data_user as $val) { if ($val['iUserID'] != '') { $useridArr[] = $val['iUserID']; } } if (count($useridArr) > 0) { $userid = implode(',', array_unique($useridArr)); } } $aWhere = array(); if (!empty($aParam['iUserID'])) { $aWhere['iUserID'] = $aParam['iUserID']; } if ($userid != '') { $aWhere['iUserID IN'] = $userid; } if (!empty($aParam['iPayment']) && $aParam['iPayment'] != '') { $aWhere['iPayment'] = $aParam['iPayment']; } if (!empty($aParam['iSource']) && $aParam['iSource'] != '') { $aWhere['iSource'] = $aParam['iSource']; } if (!empty($aParam['sRealName']) && $aParam['sRealName'] != '') { $aWhere['sRealName LIKE'] = '%' . $aParam['sRealName'] . '%'; } if (!empty($aParam['iPayType']) && $aParam['iPayType'] != '') { $aWhere['iPayType'] = $aParam['iPayType']; } if (!empty($aParam['iPayStatus']) && $aParam['iPayStatus'] != '') { $aWhere['iPayStatus'] = $aParam['iPayStatus']; } $aList = Model_Finance::getAll(array('where', $aWhere)); header("Content-type:application/vnd.ms-excel"); header("Content-Disposition:filename=财务_" . date('Y-m-d', time()) . ".xls"); $str_explode = "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'><html xmlns='http://www.w3.org/1999/xhtml'><head><meta http-equiv='Content-Type' content='text/html; charset=UTF-8' /><title>导出</title><style>td{text-align:center;font-size:12px;font-family:Arial, Helvetica, sans-serif;border:#1C7A80 1px solid;color:#152122;width:100px;}table,tr{border-style:none;}.title{background:#7DDCF0;color:#FFFFFF;font-weight:bold;}</style></head><body>"; $str_explode .= '<table cellspacing="0" cellpadding="3" rules="rows" border="1" id="" style="border-style:None;width:100%;border-collapse:collapse;"> <tr> <th scope="col">用户名称/th> <th scope="col">收支情况</th> <th scope="col">事件来源</th> <th scope="col">申请人</th> <th scope="col">支付类型</th> <th scope="col">本次金额</th> <th scope="col">用户余额</th> <th scope="col">银行开户姓名</th> <th scope="col">开户银行</th> <th scope="col">支付帐号</th> <th scope="col">支付状态</th> <th scope="col">支付流水号</th> <th scope="col">备注</th> <th scope="col">时间</th> </tr>'; foreach ($aList as $key => $val) { $row = Model_User::getDetail($val['iUserID']); $sUserRealName = isset($row) && $row['sRealName'] != '' ? $row['sRealName'] : ''; $iPayment = isset($val['iPayment']) && $val['iPayment'] == '1' ? '收入' : '支出'; $iSource = ''; if ($val['iSource'] == '1') { $iSource = '自主充值'; } elseif ($val['iSource'] == '2') { $iSource = '付款充值'; } elseif ($val['iSource'] == '3') { $iSource = '拒单退款'; } elseif ($val['iSource'] == '4') { $iSource = '取现'; } elseif ($val['iSource'] == '5') { $iSource = '广告费用'; } $sRealName = $val['sRealName']; $iPayType = ''; if ($val['iPayType'] == '1') { $iPayType = '支付宝'; } elseif ($val['iPayType'] == '2') { $iPayType = '微信'; } elseif ($val['iPayType'] == '3') { $iPayType = '银行卡'; } $iPayMoney = $val['iPayMoney']; $iUserMoney = $val['iUserMoney']; $sOpenName = $val['sOpenName']; $sBankName = $val['sBankName']; $sPayAccount = $val['sPayAccount']; $iPayStatus = isset($val['iPayStatus']) && $val['iPayStatus'] == '0' ? '未支付' : '已支付'; $sPayOrder = $val['sPayOrder']; $sRemark = $val['sRemark']; $iCreateTime = date('Y-m-d H:i:s', $val['iCreateTime']); $str_explode .= '<tr> <td align="left">' . $sUserRealName . '</td> <td align="left">' . $iPayment . '</td> <td align="left">' . $iSource . '</td> <td align="left">' . $sRealName . '</td> <td align="left">' . $iPayType . '</td> <td align="left">' . $iPayMoney . '</td> <td align="left">' . $iUserMoney . '</td> <td align="left">' . $sOpenName . '</td> <td align="left">' . $sBankName . '</td> <td align="left">' . $sPayAccount . '</td> <td align="left">' . $iPayStatus . '</td> <td align="left">' . $sPayOrder . '</td> <td align="left">' . $sRemark . '</td> <td align="left">' . $iCreateTime . '</td> </tr>'; } $str_explode .= '</table>'; $str_explode .= "</body></html>"; echo $str_explode; }