HousePay.php 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111
  1. <?php
  2. namespace app\admin\controller;
  3. use think\App;
  4. use think\Db;
  5. class HousePay extends Auth
  6. {
  7. public function __construct(App $app = null) {
  8. parent::__construct($app);
  9. $this->table='house_pay';
  10. $this->model= new \app\common\model\HousePay();
  11. }
  12. public function index(){
  13. if(request()->isAjax()){
  14. //分页参数
  15. $length = input('rows',10,'intval'); //每页条数
  16. $page = input('page',1,'intval'); //第几页
  17. $start = ($page - 1) * $length; //分页开始位置
  18. //排序
  19. $sortRow = input('sidx','id','trim'); //排序列
  20. $sort = input('sord','desc','trim'); //排序方式
  21. $order = $sortRow.' '.$sort;
  22. $sn = input('sn','','trim');
  23. if($sn){
  24. $map[] = ['sn','like','%'.$sn.'%'];
  25. }
  26. $name = input('name','','trim');//用户
  27. if($name){
  28. $map1[] = ['name','like','%'.$name.'%'];
  29. $user = Db::name('owner')
  30. ->where($map1)
  31. ->where('del',0)
  32. ->where('enable',1)
  33. ->where('org_id',$this->orgId)
  34. ->column('id');
  35. if(!empty($user)){
  36. $map[] = ['owner_id','in',$user];
  37. }else{
  38. $map[] = ['owner_id','=',0];
  39. }
  40. }
  41. $status = input('status','','trim');
  42. if($status != ''){
  43. $map[] = ['status','=',$status];
  44. }
  45. $b = input('start','','trim');
  46. $e = input('end','','trim');
  47. if($b){
  48. $b = date('Y-m-d 00:00:00',strtotime($b));
  49. $map[] = ['create_time','>=',$b];
  50. }
  51. if($e){
  52. $e = date('Y-m-d 23:59:59',strtotime($e));
  53. $map[] = ['create_time','<=',$e];
  54. }
  55. $map2 = [];
  56. $c = input('wstart','','trim');
  57. $d = input('wend','','trim');
  58. if($c && $d){
  59. if($c <= $d){
  60. $c = date('Y-m-d',strtotime($c));
  61. $d = date('Y-m-d',strtotime($d));
  62. $map2[] = ['end','>=',$c];
  63. $map2[] = ['start','<=',$d];
  64. }
  65. }
  66. if($c && $d==''){
  67. $c = date('Y-m-d',strtotime($c));
  68. $map2[] = ['end','>=',$c];
  69. }
  70. if($c=='' && $d){
  71. $d = date('Y-m-d',strtotime($d));
  72. $map2[] = ['start','<=',$d];
  73. }
  74. if(!empty($map2)){
  75. $logs = Db::name('house_pay_log')->where($map2)
  76. ->where('org_id',$this->orgId)
  77. ->distinct(true)->column('pay_id');
  78. if($logs){
  79. $map[] = ['id','in',$logs];
  80. }else{
  81. $map[] = ['id','=',-1];
  82. }
  83. }
  84. $map[] = ['del','=',0];
  85. $map[] = ['org_id','=',$this->orgId];
  86. $map= empty($map) ? true: $map;
  87. //数据查询
  88. $lists = db($this->table)->where($map)->limit($start,$length)->order($order)->select();
  89. foreach ($lists as $k=>$v){
  90. $lists[$k]['full_name'] = Db::name('owner')
  91. ->where('id',$v['owner_id'])
  92. ->value('name');
  93. }
  94. //数据返回
  95. $totalCount = db($this->table)->where($map)->count();
  96. $totalPage = ceil($totalCount/$length);
  97. $result['zys'] = db($this->table)->where($map)->sum('money');
  98. $result['zsh'] = db($this->table)->where($map)->sum('true_money');
  99. $result['zyfk'] = db($this->table)->where($map)->sum('pre_money');
  100. $result['page'] = $page;
  101. $result['total'] = $totalPage;
  102. $result['records'] = $totalCount;
  103. $result['rows'] = $lists;
  104. return json($result);
  105. }else{
  106. return $this->fetch();
  107. }
  108. }
  109. public function detail($id){
  110. $info = $this->model->show_info($id);
  111. $this->assign('info',$info);
  112. $this->assign('userId',$this->userId);
  113. $this->assign('curDate',date('Y-m-d'));
  114. return $this->fetch();
  115. }
  116. public function pay(){
  117. $post = [
  118. 'id' => input('id',0),
  119. 'true_money' => input('true_money/f',0),
  120. 'pay_time' => getTime(),
  121. 'payee' => input('payee',''),
  122. 'remark' => input('remark',''),
  123. 'pay_type' => input('pay_type',0),
  124. 'pay_data' => input('pay_data',[]),
  125. ];
  126. if($post['id'] <= 0){
  127. $this->error('参数错误');
  128. }
  129. if($post['true_money'] <= 0){
  130. $this->error('实收金额必须大于0');
  131. }
  132. if(!in_array($post['pay_type'],[1,2,3,4,5,6])){
  133. $this->error('请选择收款方式');
  134. }
  135. if($post['pay_type'] == 6 && empty($post['pay_data'])){
  136. $this->error('参数错误');
  137. }
  138. $paydata = [];
  139. if($post['pay_type'] == 6){
  140. foreach ($post['pay_data'] as $k=>$v){
  141. $v = floatval($v);
  142. if($v > 0){
  143. $paydata[$k] = $v;
  144. }
  145. }
  146. }
  147. $post['pay_data'] = $paydata?json_encode($paydata):'';
  148. $user = Db::name('user')
  149. ->where('id',$this->userId)->find();
  150. $post['payee'] = $user?$user['real_name']:'';
  151. $ret = $this->model->paysave($post,$this->userId);
  152. if($ret){
  153. $this->success('操作成功');
  154. }else{
  155. $this->error($this->model->geterror());
  156. }
  157. }
  158. public function print($id){
  159. $info = $this->model->show_info($id);
  160. $this->assign('info',$info);
  161. $this->assign('curDate',getTime());
  162. return $this->fetch();
  163. }
  164. public function cancel($id) {
  165. if(request()->isGet()){
  166. $this->assign('id',$id);
  167. return $this->fetch();
  168. }else{
  169. $post = request()->post();
  170. if(!isset($post['cancel_reason'])|| empty($post['cancel_reason'])){
  171. $this->error('返销原因不能为空');
  172. }
  173. $ret = $this->model->cancel($post,$id,$this->userId);
  174. if($ret){
  175. $this->success('操作成功');
  176. }else{
  177. $this->error($this->model->getError());
  178. }
  179. }
  180. }
  181. public function export(){
  182. include_once env('root_path').'/extend/phpexcel/Classes/PHPExcel.php';
  183. set_time_limit(0);
  184. ini_set("memory_limit", "1024M");
  185. //实例化PHPExcel类
  186. $excel = new \PHPExcel();
  187. $sheet = $excel->setActiveSheetIndex(0);
  188. $arr = array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
  189. foreach ($arr as $k=>$v) {
  190. $excel->getActiveSheet()->getStyle($v)->getAlignment()->setWrapText(false);//换行
  191. $excel->getActiveSheet()->getStyle($v.'1')->getFont()->setBold(true);
  192. $excel->getActiveSheet()->getStyle($v.'1')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  193. $excel->getActiveSheet()->getStyle($v.'1')->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
  194. $excel->getActiveSheet()->getStyle($v)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  195. $excel->getActiveSheet()->getStyle($v)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
  196. $excel->getActiveSheet()->getColumnDimension($v)->setWidth(18);
  197. }
  198. $sn = input('sn','','trim');
  199. if($sn){
  200. $map[] = ['sn','like','%'.$sn.'%'];
  201. }
  202. $name = input('name','','trim');//用户
  203. if($name){
  204. $map1[] = ['name','like','%'.$name.'%'];
  205. $user = Db::name('owner')
  206. ->where($map1)
  207. ->where('del',0)
  208. ->where('org_id',$this->orgId)
  209. ->where('enable',1)
  210. ->column('id');
  211. if(!empty($user)){
  212. $map[] = ['owner_id','in',$user];
  213. }else{
  214. $map[] = ['owner_id','=',0];
  215. }
  216. }
  217. $status = input('status','','trim');
  218. if($status != ''){
  219. $map[] = ['status','=',$status];
  220. }
  221. $b = input('start','','trim');
  222. $e = input('end','','trim');
  223. if($b){
  224. $b = date('Y-m-d 00:00:00',strtotime($b));
  225. $map[] = ['create_time','>=',$b];
  226. }
  227. if($e){
  228. $e = date('Y-m-d 23:59:59',strtotime($e));
  229. $map[] = ['create_time','<=',$e];
  230. }
  231. $map2 = [];
  232. $c = input('wstart','','trim');
  233. $d = input('wend','','trim');
  234. if($c){
  235. $c = date('Y-m-d',strtotime($c));
  236. $map2[] = ['end','>=',$c];
  237. }
  238. if($d){
  239. $d = date('Y-m-d',strtotime($d));
  240. $map2[] = ['start','<=',$d];
  241. }
  242. if(!empty($map2)){
  243. $logs = Db::name('house_pay_log')->where($map2)
  244. ->where('org_id',$this->orgId)
  245. ->distinct(true)->column('pay_id');
  246. if($logs){
  247. $map[] = ['id','in',$logs];
  248. }else{
  249. $map[] = ['id','=',-1];
  250. }
  251. }
  252. $map[] = ['del','=',0];
  253. $map[] = ['org_id','=',$this->orgId];
  254. $map= empty($map) ? true: $map;
  255. //数据查询
  256. $lists = db($this->table)->where($map)->order('id','desc')->select();
  257. foreach ($lists as $k=>$v){
  258. $lists[$k]['full_name'] = Db::name('owner')
  259. ->where('id',$v['owner_id'])
  260. ->value('name');
  261. $lists[$k]['xq_title'] = $this->getTableField('house_areas',['id'=>$v['area_id']],'title');
  262. $lists[$k]['name'] = $this->getTableField('owner',['id'=>$v['owner_id']],'name');
  263. $logs = Db::name('house_pay_log')->where('pay_id',$v['id'])
  264. ->select();
  265. $lists[$k]['logs'] = $logs;
  266. }
  267. $input = input();
  268. $fees = $this->model->show_all_fee($this->orgId,$input);
  269. $sheet->setCellValueByColumnAndRow(0, 1, '小区');
  270. $sheet->setCellValueByColumnAndRow(1, 1, '客户');
  271. $sheet->setCellValueByColumnAndRow(2, 1, '票据号');
  272. $sheet->setCellValueByColumnAndRow(3, 1, '收费日期');
  273. $sheet->setCellValueByColumnAndRow(4, 1, '收款人');
  274. $sheet->setCellValueByColumnAndRow(5, 1, '收费方式');
  275. $sheet->setCellValueByColumnAndRow(6, 1, '预付款');
  276. $n = 6;
  277. foreach ($fees as $k=>$v){
  278. $n++;
  279. $sheet->setCellValueByColumnAndRow($n, 1, $v['title']);
  280. }
  281. $sheet->setCellValueByColumnAndRow($n+1, 1, '总计');
  282. foreach ($lists as $k=>$v) {
  283. $sheet->setCellValueByColumnAndRow(0, $k + 2, $v['xq_title']);
  284. $sheet->setCellValueByColumnAndRow(1, $k + 2, $v['name']);
  285. $sheet->setCellValueByColumnAndRow(2, $k + 2, $v['sn']);
  286. $sheet->setCellValueByColumnAndRow(3, $k + 2, $v['pay_time']);
  287. $sheet->setCellValueByColumnAndRow(4, $k + 2, $v['payee']);
  288. $payType = ['','现金','预付款','支付宝','银行托收','微信','组合付款'];
  289. if($v['pay_type'] != 6){ // 1=现金 2=预付款 3=支付宝 4=银行托收 5=微信 6=组合付款
  290. $sheet->setCellValueByColumnAndRow(5, $k + 2, $payType[$v['pay_type']]);
  291. }else{
  292. $str = '组合付款';
  293. $paydata = $v['pay_data']?json_decode($v['pay_data'],true):[];
  294. $arr = [];
  295. foreach ($paydata as $kk=>$vv){
  296. $arr[] = $payType[$kk].':'.$vv;
  297. }
  298. if($arr){
  299. $str .= '('.implode(';',$arr).')';
  300. }
  301. $sheet->setCellValueByColumnAndRow(5, $k + 2, $str);
  302. }
  303. $sheet->setCellValueByColumnAndRow(6, $k + 2, $v['pre_money']);
  304. $n = 6;
  305. foreach ($fees as $kk=>$vv){
  306. $logs = $v['logs'];
  307. $n++;
  308. foreach ($logs as $kkk=>$vvv){
  309. if($vvv['fee_id'] == $vv['fee_id']){
  310. $sheet->setCellValueByColumnAndRow($n, $k + 2, $vvv['money']);
  311. }
  312. }
  313. }
  314. $sheet->setCellValueByColumnAndRow($n+1, $k + 2, $v['money']);
  315. }
  316. //设置保存的Excel表格名称
  317. $filename = '缴费单记录' . date('YmdHis', time()) . '.xls';
  318. //设置当前激活的sheet表格名称
  319. $excel->getActiveSheet()->setTitle('缴费单记录');
  320. //设置浏览器窗口下载表格
  321. ob_end_clean();
  322. header("Content-Type: application/force-download");
  323. header("Content-Type: application/octet-stream");
  324. header("Content-Type: application/download");
  325. header('Content-Disposition:inline;filename="' . $filename);
  326. //生成excel文件
  327. $objWriter = \PHPExcel_IOFactory::createWriter($excel, 'Excel5');
  328. //下载文件在浏览器窗口
  329. return $objWriter->save('php://output');
  330. }
  331. public function flist(){
  332. if(request()->isAjax()){
  333. //分页参数
  334. $length = input('rows',10,'intval'); //每页条数
  335. $page = input('page',1,'intval'); //第几页
  336. $start = ($page - 1) * $length; //分页开始位置
  337. //排序
  338. $sortRow = input('sidx','id','trim'); //排序列
  339. $sort = input('sord','desc','trim'); //排序方式
  340. $order = $sortRow.' '.$sort;
  341. $map = $this->model->getFeeSearch();
  342. //数据查询
  343. $lists = db('house_pay_log_view')->where($map)->limit($start,$length)->order($order)->select();
  344. foreach ($lists as $k=>$v) {
  345. $lists[$k]['cate_name'] = (new \app\common\model\House())->cate[$v['cate']];
  346. $refundMoney = Db::name('house_refund_log')
  347. ->where('pay_id',$v['id'])
  348. ->where('status','in',[1,2])
  349. ->sum('money');
  350. $lists[$k]['refundMoney'] = floatval($refundMoney);
  351. $t = Db::name('house_refund_log')
  352. ->where('pay_id',$v['id'])
  353. ->count();
  354. $lists[$k]['is_show_log'] = $t;
  355. $lists[$k]['cur_user_id'] = $this->userId;
  356. }
  357. //数据返回
  358. $totalCount = db('house_pay_log_view')->where($map)->count();
  359. $totalPage = ceil($totalCount/$length);
  360. $result['zje'] = db('house_pay_log_view')
  361. ->where($map)->sum('money');
  362. $result['page'] = $page;
  363. $result['total'] = $totalPage;
  364. $result['records'] = $totalCount;
  365. $result['rows'] = $lists;
  366. return json($result);
  367. }else{
  368. $cType =Db::name('house_c_type')
  369. ->where('org_id',$this->orgId)
  370. ->where('del',0)
  371. ->where('enable',1)
  372. ->select();
  373. $fees = (new \app\common\model\HouseFee())->getTree(cur_org_id());;
  374. $fees = $fees?json_decode(json_encode($fees),true):[];
  375. $arrs = [];
  376. foreach ($fees as $kk=>$vv){
  377. $children = $vv['child']?$vv['child']:[];
  378. foreach ($children as $kkk=>$vvv){
  379. $vvv['parent_title'] = $vv['title'];
  380. $arrs[] = $vvv;
  381. }
  382. }
  383. $this->assign('cType',$cType);
  384. $this->assign('fee',$arrs);
  385. return $this->fetch();
  386. }
  387. }
  388. public function refund($id) {
  389. if(request()->isGet()){
  390. $info = Db::name('house_pay_log_view')
  391. ->where('id',$id)
  392. ->find();
  393. $this->assign('name',$info['name']);
  394. $this->assign('id',$id);
  395. return $this->fetch();
  396. }else{
  397. $post = request()->post();
  398. $ret = $this->model->refund($post,$id,$this->userId,$this->orgId);
  399. if($ret){
  400. $this->success('操作成功');
  401. }else{
  402. $this->error($this->model->getError());
  403. }
  404. }
  405. }
  406. public function fexport()
  407. {
  408. include_once env('root_path').'/extend/phpexcel/Classes/PHPExcel.php';
  409. set_time_limit(0);
  410. ini_set("memory_limit", "1024M");
  411. //排序
  412. $sortRow = input('sidx','id','trim'); //排序列
  413. $sort = input('sord','desc','trim'); //排序方式
  414. $order = $sortRow.' '.$sort;
  415. $map = $this->model->getFeeSearch();
  416. //数据查询
  417. $lists = db('house_pay_log_view')->where($map)->order($order)->select();
  418. foreach ($lists as $k=>$v) {
  419. $lists[$k]['cate_name'] = (new \app\common\model\House())->cate[$v['cate']];
  420. $refundMoney = Db::name('house_refund_log')
  421. ->where('pay_id',$v['id'])
  422. ->where('status','in',[1,2])
  423. ->sum('money');
  424. $lists[$k]['refundMoney'] = floatval($refundMoney);
  425. $t = Db::name('house_refund_log')
  426. ->where('pay_id',$v['id'])
  427. ->count();
  428. $lists[$k]['is_show_log'] = $t;
  429. $lists[$k]['cur_user_id'] = $this->userId;
  430. }
  431. //实例化PHPExcel类
  432. $excel = new \PHPExcel();
  433. $sheet = $excel->setActiveSheetIndex(0);
  434. $arr = array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
  435. foreach ($arr as $k=>$v) {
  436. $excel->getActiveSheet()->getStyle($v)->getAlignment()->setWrapText(false);//换行
  437. $excel->getActiveSheet()->getStyle($v.'1')->getFont()->setBold(true);
  438. $excel->getActiveSheet()->getStyle($v.'1')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  439. $excel->getActiveSheet()->getStyle($v.'1')->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
  440. $excel->getActiveSheet()->getStyle($v)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  441. $excel->getActiveSheet()->getStyle($v)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
  442. $excel->getActiveSheet()->getColumnDimension($v)->setWidth(18);
  443. }
  444. $sheet->setCellValueByColumnAndRow(0, 1, '单据号');
  445. $sheet->setCellValueByColumnAndRow(1, 1, '业主');
  446. $sheet->setCellValueByColumnAndRow(2, 1, '小区');
  447. $sheet->setCellValueByColumnAndRow(3, 1, '资源名称');
  448. $sheet->setCellValueByColumnAndRow(4, 1, '资源属性');
  449. $sheet->setCellValueByColumnAndRow(5, 1, '类型');
  450. $sheet->setCellValueByColumnAndRow(6, 1, '收费科目');
  451. $sheet->setCellValueByColumnAndRow(7, 1, '金额');
  452. $sheet->setCellValueByColumnAndRow(8, 1, '起止日期');
  453. $sheet->setCellValueByColumnAndRow(9, 1, '备注');
  454. $sheet->setCellValueByColumnAndRow(10, 1, '创建日期');
  455. $sheet->setCellValueByColumnAndRow(11, 1, '退费金额');
  456. foreach ($lists as $k=>$v) {
  457. $sheet->setCellValueByColumnAndRow(0, $k + 2, $v['sn']);
  458. $sheet->setCellValueByColumnAndRow(1, $k + 2, $v['name']);
  459. $sheet->setCellValueByColumnAndRow(2, $k + 2, $v['area_title']);
  460. $sheet->setCellValueByColumnAndRow(3, $k + 2, $v['title']);
  461. $cates = ['','住房','商铺','营业房','储藏室','停车位'];
  462. $sheet->setCellValueByColumnAndRow(4, $k + 2, $cates[$v['cate']]);
  463. $sheet->setCellValueByColumnAndRow(5, $k + 2, $v['c_type_name']);
  464. $sheet->setCellValueByColumnAndRow(6, $k + 2, $v['fee_title']);
  465. $sheet->setCellValueByColumnAndRow(7, $k + 2, $v['money']);
  466. if($v['start']){
  467. $sheet->setCellValueByColumnAndRow(8, $k + 2, $v['start'].' ~ '.$v['end']);
  468. }else{
  469. $sheet->setCellValueByColumnAndRow(8, $k + 2, '');
  470. }
  471. $sheet->setCellValueByColumnAndRow(9, $k + 2, $v['remark']);
  472. $sheet->setCellValueByColumnAndRow(10, $k + 2, $v['create_time']);
  473. $sheet->setCellValueByColumnAndRow(11, $k + 2, $v['refundMoney']);
  474. }
  475. //设置保存的Excel表格名称
  476. $filename = '资源缴费明细_' . date('YmdHis', time()) . '.xls';
  477. //设置当前激活的sheet表格名称
  478. $excel->getActiveSheet()->setTitle('资源缴费明细_');
  479. //设置浏览器窗口下载表格
  480. ob_end_clean();
  481. header("Content-Type: application/force-download");
  482. header("Content-Type: application/octet-stream");
  483. header("Content-Type: application/download");
  484. header('Content-Disposition:inline;filename="' . $filename);
  485. //生成excel文件
  486. $objWriter = \PHPExcel_IOFactory::createWriter($excel, 'Excel5');
  487. //下载文件在浏览器窗口
  488. return $objWriter->save('php://output');
  489. }
  490. public function selfFlist2($id=0){
  491. if(request()->isAjax()){
  492. //分页参数
  493. $length = input('rows',10,'intval'); //每页条数
  494. $page = input('page',1,'intval'); //第几页
  495. $start = ($page - 1) * $length; //分页开始位置
  496. //排序
  497. $sortRow = input('sidx','id','trim'); //排序列
  498. $sort = input('sord','desc','trim'); //排序方式
  499. $order = $sortRow.' '.$sort;
  500. $map = $this->model->getFeeSearch();
  501. $map1[] = ['pay_id','=',$id];
  502. //数据查询
  503. $lists = db('house_refund_log_view')
  504. ->where($map)->where($map1)
  505. ->limit($start,$length)->order($order)->select();
  506. foreach ($lists as $k=>$v) {
  507. $lists[$k]['cate_name'] = (new \app\common\model\House())->cate[$v['cate']];
  508. }
  509. //数据返回
  510. $totalCount = db('house_refund_log_view')
  511. ->where($map)
  512. ->where($map1)
  513. ->count();
  514. $totalPage = ceil($totalCount/$length);
  515. $result['money'] = db('house_refund_log_view')
  516. ->where($map)
  517. ->where($map1)
  518. ->where('status','in',[1,2])
  519. ->sum('money');
  520. $result['page'] = $page;
  521. $result['total'] = $totalPage;
  522. $result['records'] = $totalCount;
  523. $result['rows'] = $lists;
  524. return json($result);
  525. }else{
  526. $cType =Db::name('house_c_type')
  527. ->where('org_id',$this->orgId)
  528. ->where('del',0)
  529. ->where('enable',1)
  530. ->select();
  531. $fees = (new \app\common\model\HouseFee())->getTree(cur_org_id());;
  532. $fees = $fees?json_decode(json_encode($fees),true):[];
  533. $arrs = [];
  534. foreach ($fees as $kk=>$vv){
  535. $children = $vv['child']?$vv['child']:[];
  536. foreach ($children as $kkk=>$vvv){
  537. $vvv['parent_title'] = $vv['title'];
  538. $arrs[] = $vvv;
  539. }
  540. }
  541. $info = Db::name('house_pay')
  542. ->where('id',$id)
  543. ->find();
  544. $this->assign('m_name','['.$info['sn'].']退款记录');
  545. $this->assign('cType',$cType);
  546. $this->assign('fee',$arrs);
  547. $this->assign('id',$id);
  548. return $this->fetch();
  549. }
  550. }
  551. public function selfFexport2($id)
  552. {
  553. include_once env('root_path').'/extend/phpexcel/Classes/PHPExcel.php';
  554. set_time_limit(0);
  555. ini_set("memory_limit", "1024M");
  556. $map = $this->model->getFeeSearch();
  557. //排序
  558. $sortRow = input('sidx','id','trim'); //排序列
  559. $sort = input('sord','desc','trim'); //排序方式
  560. $order = $sortRow.' '.$sort;
  561. $map1[] = ['pay_id','=',$id];
  562. //数据查询
  563. $lists = db('house_refund_log_view')
  564. ->where($map)->where($map1)
  565. ->order($order)->select();
  566. foreach ($lists as $k=>$v) {
  567. $lists[$k]['cate_name'] = (new \app\common\model\House())->cate[$v['cate']];
  568. }
  569. //实例化PHPExcel类
  570. $excel = new \PHPExcel();
  571. $sheet = $excel->setActiveSheetIndex(0);
  572. $arr = array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
  573. foreach ($arr as $k=>$v) {
  574. $excel->getActiveSheet()->getStyle($v)->getAlignment()->setWrapText(false);//换行
  575. $excel->getActiveSheet()->getStyle($v.'1')->getFont()->setBold(true);
  576. $excel->getActiveSheet()->getStyle($v.'1')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  577. $excel->getActiveSheet()->getStyle($v.'1')->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
  578. $excel->getActiveSheet()->getStyle($v)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  579. $excel->getActiveSheet()->getStyle($v)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
  580. $excel->getActiveSheet()->getColumnDimension($v)->setWidth(18);
  581. }
  582. $sheet->setCellValueByColumnAndRow(0, 1, '单据号');
  583. $sheet->setCellValueByColumnAndRow(1, 1, '业主');
  584. $sheet->setCellValueByColumnAndRow(2, 1, '小区');
  585. $sheet->setCellValueByColumnAndRow(3, 1, '资源名称');
  586. $sheet->setCellValueByColumnAndRow(4, 1, '资源属性');
  587. $sheet->setCellValueByColumnAndRow(5, 1, '类型');
  588. $sheet->setCellValueByColumnAndRow(6, 1, '收费科目');
  589. $sheet->setCellValueByColumnAndRow(7, 1, '金额');
  590. $sheet->setCellValueByColumnAndRow(8, 1, '起止日期');
  591. $sheet->setCellValueByColumnAndRow(9, 1, '备注');
  592. $sheet->setCellValueByColumnAndRow(10, 1, '状态');
  593. $sheet->setCellValueByColumnAndRow(11, 1, '退款原因');
  594. $sheet->setCellValueByColumnAndRow(12, 1, '创建日期');
  595. $sheet->setCellValueByColumnAndRow(13, 1, '退款姓名');
  596. $sheet->setCellValueByColumnAndRow(14, 1, '退款账号');
  597. $sheet->setCellValueByColumnAndRow(15, 1, '退款卡号');
  598. foreach ($lists as $k=>$v) {
  599. $sheet->setCellValueByColumnAndRow(0, $k + 2, $v['sn']);
  600. $sheet->setCellValueByColumnAndRow(1, $k + 2, $v['name']);
  601. $sheet->setCellValueByColumnAndRow(2, $k + 2, $v['area_title']);
  602. $sheet->setCellValueByColumnAndRow(3, $k + 2, $v['title']);
  603. $cates = ['','住房','商铺','营业房','储藏室','停车位'];
  604. $sheet->setCellValueByColumnAndRow(4, $k + 2, $cates[$v['cate']]);
  605. $sheet->setCellValueByColumnAndRow(5, $k + 2, $v['c_type_name']);
  606. $sheet->setCellValueByColumnAndRow(6, $k + 2, $v['fee_title']);
  607. $sheet->setCellValueByColumnAndRow(7, $k + 2, $v['money']);
  608. if($v['start']){
  609. $sheet->setCellValueByColumnAndRow(8, $k + 2, $v['start'].' ~ '.$v['end']);
  610. }else{
  611. $sheet->setCellValueByColumnAndRow(8, $k + 2, '');
  612. }
  613. $sheet->setCellValueByColumnAndRow(9, $k + 2, $v['remark']);
  614. $sheet->setCellValueByColumnAndRow(10, $k + 2, $v['status']==0?'已拒绝':($v['status']==1?'退款中':'已退款'));
  615. $sheet->setCellValueByColumnAndRow(11, $k + 2, $v['reason']);
  616. $sheet->setCellValueByColumnAndRow(12, $k + 2, $v['refund_time']);
  617. $sheet->setCellValueByColumnAndRow(13, $k + 2, $v['refund_name']);
  618. $sheet->setCellValueByColumnAndRow(14, $k + 2, $v['refund_account']);
  619. $sheet->setCellValueByColumnAndRow(15, $k + 2, $v['refund_bank']);
  620. }
  621. //设置保存的Excel表格名称
  622. $filename = '退款记录_' . date('YmdHis', time()) . '.xls';
  623. //设置当前激活的sheet表格名称
  624. $excel->getActiveSheet()->setTitle('退款记录_');
  625. //设置浏览器窗口下载表格
  626. ob_end_clean();
  627. header("Content-Type: application/force-download");
  628. header("Content-Type: application/octet-stream");
  629. header("Content-Type: application/download");
  630. header('Content-Disposition:inline;filename="' . $filename);
  631. //生成excel文件
  632. $objWriter = \PHPExcel_IOFactory::createWriter($excel, 'Excel5');
  633. //下载文件在浏览器窗口
  634. return $objWriter->save('php://output');
  635. }
  636. public function flist2Print($id){
  637. $info = Db::name('house_refund_log_view')
  638. ->where('id',$id)
  639. ->find();
  640. $y = date('Y');
  641. $m = date('m');
  642. $d = date('d');
  643. $this->assign('value',$info);
  644. $this->assign('curDate',getTime());
  645. $this->assign('y',$y);
  646. $this->assign('m',$m);
  647. $this->assign('d',$d);
  648. return $this->fetch();
  649. }
  650. public function flist3() {
  651. if (request()->isAjax()) {
  652. //分页参数
  653. $length = input('rows', 10, 'intval'); //每页条数
  654. $page = input('page', 1, 'intval'); //第几页
  655. $start = ($page - 1) * $length; //分页开始位置
  656. //排序
  657. $sortRow = input('sidx', 'id', 'trim'); //排序列
  658. $sort = input('sord', 'desc', 'trim'); //排序方式
  659. $order = $sortRow . ' ' . $sort;
  660. $map = $this->model->getFeeSearch();
  661. //数据查询
  662. $lists = db('house_pay_log_view')->where($map)->limit($start, $length)->order($order)->select();
  663. foreach ($lists as $k => $v) {
  664. $lists[$k]['cate_name'] = (new \app\common\model\House())->cate[$v['cate']];
  665. }
  666. //数据返回
  667. $totalCount = db('house_pay_log_view')->where($map)->count();
  668. $totalPage = ceil($totalCount / $length);
  669. $result['zje'] = db('house_pay_log_view')
  670. ->where($map)->sum('money');
  671. $result['page'] = $page;
  672. $result['total'] = $totalPage;
  673. $result['records'] = $totalCount;
  674. $result['rows'] = $lists;
  675. return json($result);
  676. }
  677. else {
  678. $cType = Db::name('house_c_type')
  679. ->where('org_id', $this->orgId)
  680. ->where('del', 0)
  681. ->where('enable', 1)
  682. ->select();
  683. $fees = (new \app\common\model\HouseFee())->getTree(cur_org_id());;
  684. $fees = $fees ? json_decode(json_encode($fees), true) : [];
  685. $arrs = [];
  686. foreach ($fees as $kk => $vv) {
  687. $children = $vv['child'] ? $vv['child'] : [];
  688. foreach ($children as $kkk => $vvv) {
  689. $vvv['parent_title'] = $vv['title'];
  690. $arrs[] = $vvv;
  691. }
  692. }
  693. $this->assign('cType', $cType);
  694. $this->assign('fee', $arrs);
  695. return $this->fetch();
  696. }
  697. }
  698. public function fexport3()
  699. {
  700. include_once env('root_path').'/extend/phpexcel/Classes/PHPExcel.php';
  701. set_time_limit(0);
  702. ini_set("memory_limit", "1024M");
  703. //排序
  704. $sortRow = input('sidx','id','trim'); //排序列
  705. $sort = input('sord','desc','trim'); //排序方式
  706. $order = $sortRow.' '.$sort;
  707. $map = $this->model->getFeeSearch();
  708. //数据查询
  709. $lists = db('house_pay_log_view')->where($map)->order($order)->select();
  710. foreach ($lists as $k=>$v) {
  711. $lists[$k]['cate_name'] = (new \app\common\model\House())->cate[$v['cate']];
  712. }
  713. //实例化PHPExcel类
  714. $excel = new \PHPExcel();
  715. $sheet = $excel->setActiveSheetIndex(0);
  716. $arr = array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
  717. foreach ($arr as $k=>$v) {
  718. $excel->getActiveSheet()->getStyle($v)->getAlignment()->setWrapText(false);//换行
  719. $excel->getActiveSheet()->getStyle($v.'1')->getFont()->setBold(true);
  720. $excel->getActiveSheet()->getStyle($v.'1')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  721. $excel->getActiveSheet()->getStyle($v.'1')->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
  722. $excel->getActiveSheet()->getStyle($v)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  723. $excel->getActiveSheet()->getStyle($v)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
  724. $excel->getActiveSheet()->getColumnDimension($v)->setWidth(18);
  725. }
  726. $sheet->setCellValueByColumnAndRow(0, 1, '单据号');
  727. $sheet->setCellValueByColumnAndRow(1, 1, '业主');
  728. $sheet->setCellValueByColumnAndRow(2, 1, '小区');
  729. $sheet->setCellValueByColumnAndRow(3, 1, '资源名称');
  730. $sheet->setCellValueByColumnAndRow(4, 1, '资源属性');
  731. $sheet->setCellValueByColumnAndRow(5, 1, '类型');
  732. $sheet->setCellValueByColumnAndRow(6, 1, '收费科目');
  733. $sheet->setCellValueByColumnAndRow(7, 1, '金额');
  734. $sheet->setCellValueByColumnAndRow(8, 1, '起止日期');
  735. $sheet->setCellValueByColumnAndRow(9, 1, '备注');
  736. $sheet->setCellValueByColumnAndRow(10, 1, '创建日期');
  737. foreach ($lists as $k=>$v) {
  738. $sheet->setCellValueByColumnAndRow(0, $k + 2, $v['sn']);
  739. $sheet->setCellValueByColumnAndRow(1, $k + 2, $v['name']);
  740. $sheet->setCellValueByColumnAndRow(2, $k + 2, $v['area_title']);
  741. $sheet->setCellValueByColumnAndRow(3, $k + 2, $v['title']);
  742. $cates = ['','住房','商铺','营业房','储藏室','停车位'];
  743. $sheet->setCellValueByColumnAndRow(4, $k + 2, $cates[$v['cate']]);
  744. $sheet->setCellValueByColumnAndRow(5, $k + 2, $v['c_type_name']);
  745. $sheet->setCellValueByColumnAndRow(6, $k + 2, $v['fee_title']);
  746. $sheet->setCellValueByColumnAndRow(7, $k + 2, $v['money']);
  747. if($v['start']){
  748. $sheet->setCellValueByColumnAndRow(8, $k + 2, $v['start'].' ~ '.$v['end']);
  749. }else{
  750. $sheet->setCellValueByColumnAndRow(8, $k + 2, '');
  751. }
  752. $sheet->setCellValueByColumnAndRow(9, $k + 2, $v['remark']);
  753. $sheet->setCellValueByColumnAndRow(10, $k + 2, $v['create_time']);
  754. }
  755. //设置保存的Excel表格名称
  756. $filename = '子级收费报表明细_' . date('YmdHis', time()) . '.xls';
  757. //设置当前激活的sheet表格名称
  758. $excel->getActiveSheet()->setTitle('子级收费报表明细_');
  759. //设置浏览器窗口下载表格
  760. ob_end_clean();
  761. header("Content-Type: application/force-download");
  762. header("Content-Type: application/octet-stream");
  763. header("Content-Type: application/download");
  764. header('Content-Disposition:inline;filename="' . $filename);
  765. //生成excel文件
  766. $objWriter = \PHPExcel_IOFactory::createWriter($excel, 'Excel5');
  767. //下载文件在浏览器窗口
  768. return $objWriter->save('php://output');
  769. }
  770. public function show2(){
  771. if(request()->isAjax()){
  772. //分页参数
  773. $length = input('rows',10,'intval'); //每页条数
  774. $page = input('page',1,'intval'); //第几页
  775. $start = ($page - 1) * $length; //分页开始位置
  776. //排序
  777. $sortRow = input('sidx','id','trim'); //排序列
  778. $sort = input('sord','desc','trim'); //排序方式
  779. $order = $sortRow.' '.$sort;
  780. $sn = input('sn','','trim');
  781. if($sn){
  782. $map[] = ['sn','like','%'.$sn.'%'];
  783. }
  784. $name = input('name','','trim');//用户
  785. if($name){
  786. $map1[] = ['name','like','%'.$name.'%'];
  787. $user = Db::name('owner')
  788. ->where($map1)
  789. ->where('del',0)
  790. ->where('enable',1)
  791. ->where('org_id',$this->orgId)
  792. ->column('id');
  793. if(!empty($user)){
  794. $map[] = ['owner_id','in',$user];
  795. }else{
  796. $map[] = ['owner_id','=',0];
  797. }
  798. }
  799. $status = input('status','','trim');
  800. if($status != ''){
  801. $map[] = ['status','=',$status];
  802. }
  803. $b = input('start','','trim');
  804. $e = input('end','','trim');
  805. if($b){
  806. $b = date('Y-m-d 00:00:00',strtotime($b));
  807. $map[] = ['create_time','>=',$b];
  808. }
  809. if($e){
  810. $e = date('Y-m-d 23:59:59',strtotime($e));
  811. $map[] = ['create_time','<=',$e];
  812. }
  813. $map2 = [];
  814. $c = input('wstart','','trim');
  815. $d = input('wend','','trim');
  816. if($c){
  817. $c = date('Y-m-d',strtotime($c));
  818. $map2[] = ['end','>=',$c];
  819. }
  820. if($d){
  821. $d = date('Y-m-d',strtotime($d));
  822. $map2[] = ['start','<=',$d];
  823. }
  824. if(!empty($map2)){
  825. $logs = Db::name('house_pay_log')->where($map2)
  826. ->distinct(true)->column('pay_id');
  827. if($logs){
  828. $map[] = ['id','in',$logs];
  829. }else{
  830. $map[] = ['id','=',-1];
  831. }
  832. }
  833. $map[] = ['del','=',0];
  834. $map[] = ['org_id','=',$this->orgId];
  835. $map[] = ['is_cancel','=',1];
  836. $map= empty($map) ? true: $map;
  837. //数据查询
  838. $lists = db($this->table)->where($map)->limit($start,$length)->order($order)->select();
  839. foreach ($lists as $k=>$v){
  840. $lists[$k]['full_name'] = Db::name('owner')
  841. ->where('id',$v['owner_id'])
  842. ->value('name');
  843. }
  844. //数据返回
  845. $totalCount = db($this->table)->where($map)->count();
  846. $totalPage = ceil($totalCount/$length);
  847. $result['dsh'] = db($this->table)
  848. ->where($map)
  849. ->where('status',2)
  850. ->count();
  851. $result['page'] = $page;
  852. $result['total'] = $totalPage;
  853. $result['records'] = $totalCount;
  854. $result['rows'] = $lists;
  855. return json($result);
  856. }else{
  857. return $this->fetch();
  858. }
  859. }
  860. public function detail2($id){
  861. $info = $this->model->show_info($id);
  862. $this->assign('curDate',date('Y-m-d'));
  863. $this->assign('info',$info);
  864. return $this->fetch();
  865. }
  866. public function agree($id){
  867. $ret = $this->model->dealpay(3,$id,$this->userId);
  868. if($ret){
  869. $this->success('操作成功');
  870. }else{
  871. $this->error($this->model->getError());
  872. }
  873. }
  874. public function disagree($id){
  875. $ret = $this->model->dealpay(1,$id,$this->userId);
  876. if($ret){
  877. $this->success('操作成功');
  878. }else{
  879. $this->error($this->model->getError());
  880. }
  881. }
  882. public function flist2(){
  883. if(request()->isAjax()){
  884. //分页参数
  885. $length = input('rows',10,'intval'); //每页条数
  886. $page = input('page',1,'intval'); //第几页
  887. $start = ($page - 1) * $length; //分页开始位置
  888. //排序
  889. $sortRow = input('sidx','id','trim'); //排序列
  890. $sort = input('sord','desc','trim'); //排序方式
  891. $order = $sortRow.' '.$sort;
  892. $map = $this->model->getFeeSearch();
  893. //数据查询
  894. $lists = db('house_refund_log_view')
  895. ->where($map)
  896. ->limit($start,$length)->order($order)->select();
  897. foreach ($lists as $k=>$v) {
  898. $lists[$k]['cate_name'] = (new \app\common\model\House())->cate[$v['cate']];
  899. }
  900. //数据返回
  901. $totalCount = db('house_refund_log_view')
  902. ->where($map)
  903. ->count();
  904. $totalPage = ceil($totalCount/$length);
  905. $result['money'] = db('house_refund_log_view')
  906. ->where($map)
  907. ->where('status','in',[1,2])
  908. ->sum('money');
  909. $result['dsh'] = db('house_refund_log_view')
  910. ->where($map)
  911. ->where('status',1)
  912. ->count();
  913. $result['page'] = $page;
  914. $result['total'] = $totalPage;
  915. $result['records'] = $totalCount;
  916. $result['rows'] = $lists;
  917. return json($result);
  918. }else{
  919. $cType =Db::name('house_c_type')
  920. ->where('org_id',$this->orgId)
  921. ->where('del',0)
  922. ->where('enable',1)
  923. ->select();
  924. $fees = (new \app\common\model\HouseFee())->getTree(cur_org_id());;
  925. $fees = $fees?json_decode(json_encode($fees),true):[];
  926. $arrs = [];
  927. foreach ($fees as $kk=>$vv){
  928. $children = $vv['child']?$vv['child']:[];
  929. foreach ($children as $kkk=>$vvv){
  930. $vvv['parent_title'] = $vv['title'];
  931. $arrs[] = $vvv;
  932. }
  933. }
  934. $this->assign('cType',$cType);
  935. $this->assign('fee',$arrs);
  936. return $this->fetch();
  937. }
  938. }
  939. public function agreeRefund($id) {
  940. if(request()->isGet()){
  941. $this->assign('id',$id);
  942. return $this->fetch();
  943. }else{
  944. $post = request()->post();
  945. if(!isset($post['voucher'])||!$post['voucher']){
  946. $this->error('请上传凭证');
  947. }
  948. $ret = $this->model->agreeRefund($id,$this->userId,$post);
  949. if($ret){
  950. $this->success('操作成功');
  951. }else{
  952. $this->error($this->model->getError());
  953. }
  954. }
  955. }
  956. public function disagreeRefund($id) {
  957. $ret = $this->model->disagreeRefund($id,$this->userId);
  958. if($ret){
  959. $this->success('操作成功');
  960. }else{
  961. $this->error($this->model->getError());
  962. }
  963. }
  964. public function fexport2()
  965. {
  966. include_once env('root_path').'/extend/phpexcel/Classes/PHPExcel.php';
  967. set_time_limit(0);
  968. ini_set("memory_limit", "1024M");
  969. $map = $this->model->getFeeSearch();
  970. //排序
  971. $sortRow = input('sidx','id','trim'); //排序列
  972. $sort = input('sord','desc','trim'); //排序方式
  973. $order = $sortRow.' '.$sort;
  974. //数据查询
  975. $lists = db('house_refund_log_view')
  976. ->where($map)
  977. ->order($order)->select();
  978. foreach ($lists as $k=>$v) {
  979. $lists[$k]['cate_name'] = (new \app\common\model\House())->cate[$v['cate']];
  980. }
  981. //实例化PHPExcel类
  982. $excel = new \PHPExcel();
  983. $sheet = $excel->setActiveSheetIndex(0);
  984. $arr = array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
  985. foreach ($arr as $k=>$v) {
  986. $excel->getActiveSheet()->getStyle($v)->getAlignment()->setWrapText(false);//换行
  987. $excel->getActiveSheet()->getStyle($v.'1')->getFont()->setBold(true);
  988. $excel->getActiveSheet()->getStyle($v.'1')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  989. $excel->getActiveSheet()->getStyle($v.'1')->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
  990. $excel->getActiveSheet()->getStyle($v)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  991. $excel->getActiveSheet()->getStyle($v)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
  992. $excel->getActiveSheet()->getColumnDimension($v)->setWidth(18);
  993. }
  994. $sheet->setCellValueByColumnAndRow(0, 1, '单据号');
  995. $sheet->setCellValueByColumnAndRow(1, 1, '业主');
  996. $sheet->setCellValueByColumnAndRow(2, 1, '小区');
  997. $sheet->setCellValueByColumnAndRow(3, 1, '资源名称');
  998. $sheet->setCellValueByColumnAndRow(4, 1, '资源属性');
  999. $sheet->setCellValueByColumnAndRow(5, 1, '类型');
  1000. $sheet->setCellValueByColumnAndRow(6, 1, '收费科目');
  1001. $sheet->setCellValueByColumnAndRow(7, 1, '金额');
  1002. $sheet->setCellValueByColumnAndRow(8, 1, '起止日期');
  1003. $sheet->setCellValueByColumnAndRow(9, 1, '备注');
  1004. $sheet->setCellValueByColumnAndRow(10, 1, '状态');
  1005. $sheet->setCellValueByColumnAndRow(11, 1, '退款原因');
  1006. $sheet->setCellValueByColumnAndRow(12, 1, '创建日期');
  1007. $sheet->setCellValueByColumnAndRow(13, 1, '退款姓名');
  1008. $sheet->setCellValueByColumnAndRow(14, 1, '退款账号');
  1009. $sheet->setCellValueByColumnAndRow(15, 1, '退款卡号');
  1010. foreach ($lists as $k=>$v) {
  1011. $sheet->setCellValueByColumnAndRow(0, $k + 2, $v['sn']);
  1012. $sheet->setCellValueByColumnAndRow(1, $k + 2, $v['name']);
  1013. $sheet->setCellValueByColumnAndRow(2, $k + 2, $v['area_title']);
  1014. $sheet->setCellValueByColumnAndRow(3, $k + 2, $v['title']);
  1015. $cates = ['','住房','商铺','营业房','储藏室','停车位'];
  1016. $sheet->setCellValueByColumnAndRow(4, $k + 2, $cates[$v['cate']]);
  1017. $sheet->setCellValueByColumnAndRow(5, $k + 2, $v['c_type_name']);
  1018. $sheet->setCellValueByColumnAndRow(6, $k + 2, $v['fee_title']);
  1019. $sheet->setCellValueByColumnAndRow(7, $k + 2, $v['money']);
  1020. if($v['start']){
  1021. $sheet->setCellValueByColumnAndRow(8, $k + 2, $v['start'].' ~ '.$v['end']);
  1022. }else{
  1023. $sheet->setCellValueByColumnAndRow(8, $k + 2, '');
  1024. }
  1025. $sheet->setCellValueByColumnAndRow(9, $k + 2, $v['remark']);
  1026. $sheet->setCellValueByColumnAndRow(10, $k + 2, $v['status']==0?'已拒绝':($v['status']==1?'退款中':'已退款'));
  1027. $sheet->setCellValueByColumnAndRow(11, $k + 2, $v['reason']);
  1028. $sheet->setCellValueByColumnAndRow(12, $k + 2, $v['refund_time']);
  1029. $sheet->setCellValueByColumnAndRow(13, $k + 2, $v['refund_name']);
  1030. $sheet->setCellValueByColumnAndRow(14, $k + 2, $v['refund_account']);
  1031. $sheet->setCellValueByColumnAndRow(15, $k + 2, $v['refund_bank']);
  1032. }
  1033. //设置保存的Excel表格名称
  1034. $filename = '退款记录_' . date('YmdHis', time()) . '.xls';
  1035. //设置当前激活的sheet表格名称
  1036. $excel->getActiveSheet()->setTitle('退款记录_');
  1037. //设置浏览器窗口下载表格
  1038. ob_end_clean();
  1039. header("Content-Type: application/force-download");
  1040. header("Content-Type: application/octet-stream");
  1041. header("Content-Type: application/download");
  1042. header('Content-Disposition:inline;filename="' . $filename);
  1043. //生成excel文件
  1044. $objWriter = \PHPExcel_IOFactory::createWriter($excel, 'Excel5');
  1045. //下载文件在浏览器窗口
  1046. return $objWriter->save('php://output');
  1047. }
  1048. }