|
@@ -1,6 +1,6 @@
|
|
|
<?php
|
|
|
|
|
|
-
|
|
|
+require_once(BASE_HELPER_PATH . '/PHPExcel/PHPExcel.php');
|
|
|
class merchant_infoControl extends SystemControl
|
|
|
{
|
|
|
public function __construct()
|
|
@@ -111,4 +111,193 @@ class merchant_infoControl extends SystemControl
|
|
|
}
|
|
|
showMessage('删除成功','index.php?act=merchant_info&op=index');
|
|
|
}
|
|
|
+
|
|
|
+ public function merchant_evidenceOp()
|
|
|
+ {
|
|
|
+ $mod = Model('merchant_evidence');
|
|
|
+ $condition = [];
|
|
|
+ if (trim($_GET['company_name']) != '') {
|
|
|
+ $condition['company_name'] = $_GET['company_name'];
|
|
|
+ }
|
|
|
+ $start_unixtime = intval(strtotime($_GET['query_start_time']));
|
|
|
+ $end_unixtime = intval(strtotime($_GET['query_end_time']));
|
|
|
+ if ($start_unixtime > 0 && $end_unixtime > $start_unixtime) {
|
|
|
+ $condition['apply_time'] = [['egt', $start_unixtime], ['lt', $end_unixtime], 'and'];
|
|
|
+ } elseif ($start_unixtime > 0) {
|
|
|
+ $condition['apply_time'] = ['egt', $start_unixtime];
|
|
|
+ } elseif ($end_unixtime > 0) {
|
|
|
+ $condition['apply_time'] = ['lt', $end_unixtime];
|
|
|
+ }
|
|
|
+ if(!empty($_GET['export'])) {
|
|
|
+ $this->MerchantEvidenceExport($condition);
|
|
|
+ }
|
|
|
+ //上游充值申请列表
|
|
|
+ $evidence_list = $mod->getMerchantEvidence($condition, 30, '*', 'apply_time desc');
|
|
|
+ $stats = $mod->field('sum(amount) as amounts')->where($condition)->find();
|
|
|
+ Tpl::output('amounts', $stats['amounts']);
|
|
|
+ Tpl::output('evidence_list', $evidence_list);
|
|
|
+ Tpl::output('page', $mod->showpage());
|
|
|
+ Tpl::showpage('merchant.evidence.list');
|
|
|
+ }
|
|
|
+
|
|
|
+ public function importOp()
|
|
|
+ {
|
|
|
+ if(chksubmit()) {
|
|
|
+ $merchant = [];
|
|
|
+ $merchant_list = Model('')->table('merchant')->limit(1000)->select();
|
|
|
+ foreach ($merchant_list as $key => $value) {
|
|
|
+ $merchant[$value['mchid']] = $value['company_name'];
|
|
|
+ }
|
|
|
+ if(empty($merchant)) {
|
|
|
+ showMessage('机构通道为空,不可导入');
|
|
|
+ }
|
|
|
+ //得到导入文件
|
|
|
+ $filename = $_FILES['csv']['name'];
|
|
|
+ $tmp_name = $_FILES['csv']['tmp_name'];
|
|
|
+ $extend = strrchr($filename,'.');
|
|
|
+ $extendLower = strtolower($extend);
|
|
|
+ if (!in_array($extendLower, ['.xls', '.xlsx', '.csv']))
|
|
|
+ {
|
|
|
+ showMessage('文件格式有误');
|
|
|
+ }
|
|
|
+ $filePath = BASE_ROOT_PATH . '/data/upload/upfile/provider/';
|
|
|
+
|
|
|
+ /** Error reporting */
|
|
|
+ error_reporting(E_ALL);
|
|
|
+ //注意设置时区
|
|
|
+ $time=date("m-d-H-i-s");//去当前上传的时间
|
|
|
+ //根据当前时间外加后五位产生一个 防止多个用户同时操作产生的重复概率
|
|
|
+ $randnum = 'MerchantEvidenceImport_'.$time.str_pad(mt_rand(1, 99999), 5, '0', STR_PAD_LEFT);
|
|
|
+ //上传后的文件名
|
|
|
+ $name=$randnum.$extendLower;
|
|
|
+
|
|
|
+ $upload_filename=$filePath.$name;//上传后的文件名地址
|
|
|
+
|
|
|
+ $result=move_uploaded_file($tmp_name,$upload_filename);
|
|
|
+ if(!$result){
|
|
|
+ showMessage('上传失败,稍后再试!');
|
|
|
+ exit;
|
|
|
+ }
|
|
|
+
|
|
|
+ $fileType = PHPExcel_IOFactory::identify($upload_filename);
|
|
|
+ $objReader = PHPExcel_IOFactory::createReader($fileType);
|
|
|
+ $objPHPExcel = $objReader->load($upload_filename);
|
|
|
+
|
|
|
+ $time = time();
|
|
|
+ $mod = Model('merchant_evidence');
|
|
|
+ foreach ($objPHPExcel->getWorkSheetIterator() as $sheet)
|
|
|
+ {
|
|
|
+ foreach ($sheet->getRowIterator() as $row)
|
|
|
+ {
|
|
|
+ $index = $row->getRowIndex();
|
|
|
+ if ($index == 1) continue;
|
|
|
+ $items = [];
|
|
|
+ foreach ($row->getCellIterator() as $cell) {
|
|
|
+ $data = $cell->getValue();
|
|
|
+ $items[] = $data;
|
|
|
+ }
|
|
|
+ $mchid = intval($items[0]);
|
|
|
+ $params = [
|
|
|
+ 'mchid' => $mchid,
|
|
|
+ 'company_name' => $merchant[$mchid],
|
|
|
+ 'amount' => $items[1] ?? '',
|
|
|
+ 'bank_username' => trim($items[2]) ?? '',
|
|
|
+ 'bank_name' => trim($items[3]) ?? '',
|
|
|
+ 'to_bank_username' => trim($items[4]) ?? '',
|
|
|
+ 'to_bank_name' => trim($items[5]) ?? '',
|
|
|
+ 'apply_time' => strtotime($items[6]) ?? '',
|
|
|
+ 'add_time' => $time
|
|
|
+ ];
|
|
|
+ if(!empty($items[7])) {
|
|
|
+ $params['bz'] = $items[7];
|
|
|
+ }
|
|
|
+ $json_txt = json_encode($params);
|
|
|
+ Log::record("import data: {$json_txt}",LOG::DEBUG);
|
|
|
+ if(empty($params['store_id']) || empty($params['store_name'])) {
|
|
|
+ Log::record("merchant evidence import err,not find store info, mchid: {$mchid}, amount: {$params['amount']}",LOG::DEBUG);
|
|
|
+ }
|
|
|
+ $res = $mod->addMerchantEvidence($params);
|
|
|
+ if(!$res){
|
|
|
+ Log::record("merchant evidence import err, mchid: {$mchid}, amount: {$params['amount']}",LOG::DEBUG);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ showMessage('操作完成');
|
|
|
+ exit;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Tpl::showpage('merchant.evidence.import');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function apply_delOp()
|
|
|
+ {
|
|
|
+ $apply_id = $_GET['apply_id'] ?? $_POST['apply_id'];
|
|
|
+ $mod = Model('merchant_evidence');
|
|
|
+ $provider_evidence_info = $mod->getMerchantEvidenceInfo(['apply_id' => $apply_id]);
|
|
|
+ if (empty($provider_evidence_info)) {
|
|
|
+ showMessage('申请信息不存在');
|
|
|
+ }
|
|
|
+ $result = $mod->DelMerchantEvidence(['apply_id' => $apply_id]);
|
|
|
+ if (!$result) {
|
|
|
+ showMessage('删除失败');
|
|
|
+ }
|
|
|
+ showMessage('删除成功','index.php?act=merchant_info&op=merchant_evidence');
|
|
|
+ }
|
|
|
+
|
|
|
+ private function MerchantEvidenceExport($condition)
|
|
|
+ {
|
|
|
+ $i = 0;
|
|
|
+ $result = [];
|
|
|
+ while (true) {
|
|
|
+ $start = $i * 1000;
|
|
|
+ $evidence_list = Model('')->table('merchant_evidence')->where($condition)->order('apply_time desc')->limit("{$start},1000")->select();
|
|
|
+ if (empty($evidence_list)) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ $i++;
|
|
|
+ foreach ($evidence_list as $value) {
|
|
|
+ $result[] = $value;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $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' => '备注');
|
|
|
+ //data
|
|
|
+ foreach ((array)$data as $v) {
|
|
|
+ $tmp = array();
|
|
|
+ $tmp[] = array('data' => $v['company_name']);
|
|
|
+ $tmp[] = array('data' => $v['amount']);
|
|
|
+ $tmp[] = array('data' => $v['bank_username']);
|
|
|
+ $tmp[] = array('data' => $v['bank_name']);
|
|
|
+ $tmp[] = array('data' => $v['to_bank_username']);
|
|
|
+ $tmp[] = array('data' => $v['to_bank_name']);
|
|
|
+ $tmp[] = array('data' => date('Y-m-d H:i:s', $v['apply_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;
|
|
|
+ }
|
|
|
}
|