0 && $end_unixtime > $start_unixtime) { $condition['refund_time'] = [['egt', $start_unixtime], ['lt', $end_unixtime], 'and']; } elseif ($start_unixtime > 0) { $condition['refund_time'] = ['egt', $start_unixtime]; } elseif ($end_unixtime > 0) { $condition['refund_time'] = ['lt', $end_unixtime]; } $providers = []; $provider_list = $this->providers(); foreach ($provider_list as $provider) { $providers[$provider['provider_id']] = $provider; } $merchants = []; $merchant_list = $this->merchants(); foreach ($merchant_list as $value) { $merchants[$value['mchid']] = $value; } if($_GET['export'] == 1) { $this->RefillRefundExport($condition,$providers,$merchants); }else{ $refund_list = $mod->getRefillRefundList($condition,50); $refund_list = $this->DataFormat($refund_list,$providers,$merchants); } Tpl::output('provider_list', $providers); Tpl::output('merchants', $merchants); Tpl::output('info_list', $refund_list); Tpl::output('show_page', $mod->showpage()); Tpl::showpage('refill.refund'); } private function DataFormat($refund_list,$providers,$merchants) { $providers[-1] = [ 'name' => 'yezi', 'store_name' => '椰子退费' ]; foreach ($refund_list as $key => $value) { $refund_list[$key]['provider_name'] = $providers[$value['provider_id']]['name']; $refund_list[$key]['store_name'] = $providers[$value['provider_id']]['store_name']; $refund_list[$key]['merchant_name'] = $merchants[$value['mchid']]['name']; $refund_list[$key]['company_name'] = $merchants[$value['mchid']]['company_name']; $refund_list[$key]['card_type_text'] = $this->scard_type($value['card_type']); } return $refund_list; } private function RefillRefundExport($condition,$providers,$merchants) { $i = 0; $result = []; while (true) { $start = $i * 1000; $list = Model('')->table('refill_refund')->where($condition)->order('refund_time desc')->limit("{$start},1000")->select(); if (empty($list)) { break; } $i++; foreach ($list as $value) { $result[] = $value; } } $result = $this->DataFormat($result,$providers,$merchants); $this->createExcel($result); } private function createExcel($data = array()) { Language::read('export'); import('libraries.excel'); $excel_obj = new Excel(); $excel_data = array(); //设置样式 $excel_obj->setStyle(array('id' => 's_title', 'Font' => array('FontName' => '宋体', 'Size' => '12', 'Bold' => '1'))); //header $excel_data[0][] = array('styleid' => 's_title', 'data' => '通道名称'); $excel_data[0][] = array('styleid' => 's_title', 'data' => '通道退款金额'); $excel_data[0][] = array('styleid' => 's_title', 'data' => '机构编码'); $excel_data[0][] = array('styleid' => 's_title', 'data' => '机构名称'); $excel_data[0][] = array('styleid' => 's_title', 'data' => '机构退款金额'); $excel_data[0][] = array('styleid' => 's_title', 'data' => '退款卡号'); $excel_data[0][] = array('styleid' => 's_title', 'data' => '退款卡类型'); $excel_data[0][] = array('styleid' => 's_title', 'data' => '退款面值'); $excel_data[0][] = array('styleid' => 's_title', 'data' => '退款日期'); $excel_data[0][] = array('styleid' => 's_title', 'data' => '备注'); //data foreach ((array)$data as $v) { $mch_name = $v['company_name'] ?? $v['name']; $tmp = array(); $tmp[] = array('data' => "{$v['provider_name']}({$v['store_name']})"); $tmp[] = array('data' => $v['channel_amount']); $tmp[] = array('data' => $v['mchid']); $tmp[] = array('data' => $mch_name); $tmp[] = array('data' => $v['mch_amount']); $tmp[] = array('data' => $v['card_no']); $tmp[] = array('data' => $v['card_type_text']); $tmp[] = array('data' => $v['refill_amount']); $tmp[] = array('data' => date('Y-m-d H:i:s', $v['refund_time'])); $tmp[] = array('data' => $v['bz']); $excel_data[] = $tmp; } $excel_data = $excel_obj->charset($excel_data, CHARSET); $excel_obj->addArray($excel_data); $excel_obj->addWorksheet($excel_obj->charset(L('exp_od_order'), CHARSET)); $excel_obj->generateXML($excel_obj->charset(L('exp_od_order'), CHARSET) . date('Y-m-d-H', time())); exit; } public function addOp() { if (chksubmit()) { $obj_validate = new Validator(); $obj_validate->validateparam = [ ["input" => $_POST["mchid"], "require" => "true", "message" => '机构不能为空'], ["input" => $_POST["provider_id"], "require" => "true", "message" => '通道不能为空'], ["input" => $_POST["mch_amount"], "require" => "true", "message" => '机构退款金额不能为空'], ["input" => $_POST["channel_amount"], "require" => "true", "message" => '通道退款金额不能为空'], ["input" => $_POST["refund_time"], "require" => "true", "message" => '退款日期不能为空'], ["input" => $_POST["card_no"], "require" => "true", "message" => '退款卡号不能为空'], ["input" => $_POST["card_type"], "require" => "true", "message" => '卡类型不能为空'], ["input" => $_POST["refill_amount"], "require" => "true", "message" => '面值不能为空'] ]; $error = $obj_validate->validate(); if ($error != '') { showMessage($error); } else { $merchant = Model('merchant')->getMerchantInfo(['mchid' => $_POST['mchid']]); if(empty($merchant)) { showMessage('此机构不存在!'); } $provider = Model('refill_provider')->getProviderInfo(['provider_id' => $_POST['provider_id']]); if(empty($provider) && $_POST['provider_id'] != -1) { showMessage('此上游通道不存在!'); } $mod = Model('refill_refund'); $insert_array['mchid'] = $_POST['mchid']; $insert_array['provider_id'] = $_POST['provider_id']; $insert_array['mch_amount'] = $_POST['mch_amount']; $insert_array['channel_amount'] = $_POST['channel_amount']; $insert_array['refund_time'] = strtotime($_POST['refund_time']); $insert_array['card_no'] = $_POST['card_no']; $insert_array['card_type'] = $_POST['card_type']; $insert_array['refill_amount'] = $_POST['refill_amount']; $insert_array['bz'] = $_POST['bz'] ?? ''; $insert_array['add_time'] = time(); $result = $mod->addRefund($insert_array); if ($result) { showMessage('添加成功', 'index.php?act=refill_refund&op=index'); } else { showMessage('添加失败'); } } } else { $merchant_list = Model('')->table('merchant')->limit(1000)->select(); $provider_list = Model('')->table('refill_provider,store')->field('refill_provider.provider_id,store.store_name')->join('inner') ->on('store.store_id=refill_provider.store_id')->limit(1000)->select(); Tpl::output('provider_list', $provider_list); Tpl::output('merchant_list', $merchant_list); Tpl::showpage('refill.refund.add'); } } public function editOp() { $id = $_GET['id'] ?? $_POST['id']; $mod = Model('refill_refund'); $refund_info = $mod->getRefundInfo(['id' => $id]); if (empty($refund_info)) { showMessage('退款信息不存在'); } if (chksubmit()) { $obj_validate = new Validator(); $obj_validate->validateparam = [ ["input" => $_POST["mchid"], "require" => "true", "message" => '机构不能为空'], ["input" => $_POST["provider_id"], "require" => "true", "message" => '通道不能为空'], ["input" => $_POST["mch_amount"], "require" => "true", "message" => '机构退款金额不能为空'], ["input" => $_POST["channel_amount"], "require" => "true", "message" => '通道退款金额不能为空'], ["input" => $_POST["refund_time"], "require" => "true", "message" => '退款日期不能为空'], ["input" => $_POST["card_no"], "require" => "true", "message" => '退款卡号不能为空'], ["input" => $_POST["card_type"], "require" => "true", "message" => '卡类型不能为空'], ["input" => $_POST["refill_amount"], "require" => "true", "message" => '面值不能为空'] ]; $error = $obj_validate->validate(); if ($error != '') { showMessage($error); exit; } $update['mchid'] = trim($_POST['mchid']); $update['provider_id'] = trim($_POST['provider_id']); $update['mch_amount'] = trim($_POST['mch_amount']); $update['channel_amount'] = trim($_POST['channel_amount']); $update['refund_time'] = strtotime($_POST['refund_time']); $update['card_no'] = trim($_POST['card_no']); $update['card_type'] = trim($_POST['card_type']); $update['refill_amount'] = trim($_POST['refill_amount']); $update['bz'] = $_POST['bz'] ?? ''; $result = $mod->editRefund($update, ['id' => $id]); if (!$result) { showMessage('编辑失败'); } showMessage('编辑成功','index.php?act=refill_refund&op=index'); } else { $merchant_list = Model('')->table('merchant')->limit(1000)->select(); $provider_list = Model('')->table('refill_provider,store')->field('refill_provider.provider_id,store.store_name')->join('inner') ->on('store.store_id=refill_provider.store_id')->limit(1000)->select(); Tpl::output('provider_list', $provider_list); Tpl::output('merchant_list', $merchant_list); Tpl::output('refund_info', $refund_info); Tpl::showpage('refill.refund.edit'); } } public function delOp() { $id = $_GET['id']; $mod = Model('refill_refund'); $provider_info = $mod->getRefundInfo(['id' => $id]); if (empty($provider_info)) { showMessage('退款信息不存在'); } $result = $mod->DelRefund(['id' => $id]); if (!$result) { showMessage('删除失败'); } showMessage('删除成功','index.php?act=refill_refund&op=index'); } }