|
@@ -1,6 +1,6 @@
|
|
|
<?php
|
|
|
|
|
|
-
|
|
|
+require_once(BASE_HELPER_PATH . '/PHPExcel/PHPExcel.php');
|
|
|
class provider_infoControl extends SystemControl
|
|
|
{
|
|
|
public function __construct()
|
|
@@ -187,4 +187,201 @@ class provider_infoControl extends SystemControl
|
|
|
echo json_encode(['to_bank_username' =>$to_bank_username, 'to_bank_name' => $to_bank_name]);
|
|
|
exit;
|
|
|
}
|
|
|
+
|
|
|
+ public function provider_evidenceOp()
|
|
|
+ {
|
|
|
+ $mod = Model('provider_evidence');
|
|
|
+ $condition = [];
|
|
|
+ if (trim($_GET['store_name']) != '') {
|
|
|
+ $condition['store_name'] = ['like', '%' . $_GET['store_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];
|
|
|
+ }
|
|
|
+
|
|
|
+ //上游充值申请列表
|
|
|
+ $evidence_list = $mod->getProviderEvidence($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.provider.evidence_list');
|
|
|
+ }
|
|
|
+
|
|
|
+ public function provider_evidence_addOp()
|
|
|
+ {
|
|
|
+ $provider_model = Model('refill_provider');
|
|
|
+ if (chksubmit()) {
|
|
|
+ $obj_validate = new Validator();
|
|
|
+ $obj_validate->validateparam = [
|
|
|
+ ["input" => $_POST["provider_id"], "require" => "true", "message" => '上游通道不能为空'],
|
|
|
+ ["input" => $_POST["bank_username"], "require" => "true", "message" => '开户人姓名不能为空'],
|
|
|
+ ["input" => $_POST["bank_name"], "require" => "true", "message" => '开户银行不能为空'],
|
|
|
+ ["input" => $_POST["to_bank_username"], "require" => "true", "message" => '上游开户人姓名不能为空'],
|
|
|
+ ["input" => $_POST["to_bank_name"], "require" => "true", "message" => '上游开户银行不能为空'],
|
|
|
+ ["input" => $_POST["amount"], "require" => "true", "message" => '预存金额不能为空'],
|
|
|
+ ["input" => $_POST["apply_time"], "require" => "true", "message" => '申请日期不能为空']
|
|
|
+ ];
|
|
|
+ $error = $obj_validate->validate();
|
|
|
+ if ($error != '') {
|
|
|
+ showMessage($error);
|
|
|
+ }
|
|
|
+ $provider_id = $_POST["provider_id"];
|
|
|
+ $provider_info = $provider_model->table('refill_provider,store')
|
|
|
+ ->where((['provider_id' => $provider_id]))
|
|
|
+ ->field('refill_provider.*,store.store_name')
|
|
|
+ ->join('inner')
|
|
|
+ ->on('store.store_id=refill_provider.store_id')
|
|
|
+ ->find();
|
|
|
+ if (!$provider_info) {
|
|
|
+ showMessage('对应店铺不存在');
|
|
|
+ }
|
|
|
+ $amount = $_POST['amount'];
|
|
|
+ $money = abs($amount);
|
|
|
+ if ($money == 0) {
|
|
|
+ showMessage('申请金额错误');
|
|
|
+ }
|
|
|
+ if(!empty($_FILES['voucher']['name'])) {
|
|
|
+ $upload = new UploadFile();
|
|
|
+ $upload->set('default_dir',ATTACH_UPFILE.'/provider');
|
|
|
+
|
|
|
+ $result = $upload->upfile('voucher');
|
|
|
+ if ($result){
|
|
|
+ $_POST['voucher'] = $upload->file_name;
|
|
|
+ $input['voucher_name'] = $_POST['voucher'];
|
|
|
+ }else {
|
|
|
+ showMessage($upload->error);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $input['store_name'] = $provider_info['store_name'];
|
|
|
+ $input['store_id'] = $provider_info['store_id'];
|
|
|
+ $input['amount'] = $amount;
|
|
|
+ $input['bank_username'] = $_POST['bank_username'];
|
|
|
+ $input['bank_name'] = $_POST['bank_name'];
|
|
|
+ $input['to_bank_username'] = $_POST['to_bank_username'];
|
|
|
+ $input['to_bank_name'] = $_POST['to_bank_name'];
|
|
|
+ $input['add_time'] = time();
|
|
|
+ $input['bz'] = $_POST['bz'];
|
|
|
+ $input['apply_time'] = strtotime($_POST['apply_time']);
|
|
|
+ $mod = Model('provider_evidence');
|
|
|
+ $res = $mod->addProviderEvidence($input);
|
|
|
+
|
|
|
+ if ($res) {
|
|
|
+ showMessage('操作成功',"index.php?act=provider_info&op=provider_evidence");
|
|
|
+ } else {
|
|
|
+ showMessage('操作失败');
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $provider_list = Model('')->table('refill_provider,store')
|
|
|
+ ->field('refill_provider.*,store.store_name')
|
|
|
+ ->join('inner')
|
|
|
+ ->on('store.store_id=refill_provider.store_id')
|
|
|
+ ->limit(1000)
|
|
|
+ ->select();
|
|
|
+ Tpl::output('provider_list', $provider_list);
|
|
|
+ Tpl::showpage('provider.evidence.add');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function importOp()
|
|
|
+ {
|
|
|
+ if(chksubmit()) {
|
|
|
+ $provider_list = Model('')->table('refill_provider,store')
|
|
|
+ ->field('refill_provider.provider_id,store.store_id,store.store_name')
|
|
|
+ ->join('inner')
|
|
|
+ ->on('store.store_id=refill_provider.store_id')
|
|
|
+ ->limit(1000)
|
|
|
+ ->select();
|
|
|
+ $store = [];
|
|
|
+ foreach ($provider_list as $provider) {
|
|
|
+ $store[$provider['provider_id']] = ['store_id' => $provider['store_id'], 'store_name' => $provider['store_name']];
|
|
|
+ }
|
|
|
+ if(empty($store)) {
|
|
|
+ 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 = 'RefillOrderImport_'.$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('provider_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;
|
|
|
+ }
|
|
|
+ $provider_id = intval($items[0]);
|
|
|
+ $params = [
|
|
|
+ 'store_id' => $store[$provider_id]['store_id'],
|
|
|
+ 'store_name' => $store[$provider_id]['store_name'],
|
|
|
+ '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("provider evidence import err,not find store info, provider_id: {$provider_id}, amount: {$params['amount']}",LOG::DEBUG);
|
|
|
+ }
|
|
|
+ $res = $mod->addProviderEvidence($params);
|
|
|
+ if(!$res){
|
|
|
+ Log::record("provider evidence import err, provider_id: {$provider_id}, amount: {$params['amount']}",LOG::DEBUG);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ showMessage('操作完成');
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Tpl::showpage('provider.evidence.import');
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|