|
@@ -9,7 +9,7 @@ include('/share/lib/php/dever_package/excel/src/PHPExcel.php');
|
|
|
class Import
|
|
|
{
|
|
|
private $path = '/www/churen/data/';
|
|
|
- private $name = 'qiquan_2022_06_16_05.xlsx';
|
|
|
+ private $name = 'qiquan_1.xlsx';
|
|
|
# 导入账户
|
|
|
public function get_api()
|
|
|
{
|
|
@@ -19,7 +19,7 @@ class Import
|
|
|
$data = Dever::excelImport($file, 1, 5, 'excel');
|
|
|
|
|
|
$table = array();
|
|
|
- $table['head'] = array('序列号', '姓名', '手机号', '身份证号', '说明');
|
|
|
+ $table['head'] = array('序列号', '公司ID', '姓名', '手机号', '身份证号', '说明');
|
|
|
$table['body'] = array();
|
|
|
|
|
|
$table_status = array();
|
|
@@ -42,6 +42,7 @@ class Import
|
|
|
$key = trim($v['A']);
|
|
|
$where['key'] = trim($v['A']);
|
|
|
$where['mobile'] = trim($v['C']);
|
|
|
+ $where['company_id'] = (isset($v['F']) && $v['F']) ? trim($v['F']) : 1;
|
|
|
$where['clear'] = true;
|
|
|
$info = Dever::db('option/member')->one($where);
|
|
|
$update = $where;
|
|
@@ -56,7 +57,7 @@ class Import
|
|
|
$id = Dever::db('option/member')->update($update);
|
|
|
}
|
|
|
if (!$id) {
|
|
|
- $table['body'][] = array($update['key'], $update['name'], $update['mobile'], $update['idcard'], '账户导入失败,请重新导入');
|
|
|
+ $table['body'][] = array($update['key'], $update['company_id'], $update['name'], $update['mobile'], $update['idcard'], '账户导入失败,请重新导入');
|
|
|
} else {
|
|
|
if ($update['main'] == 2) {
|
|
|
$table_status['body'][0][1] += 1;
|
|
@@ -79,7 +80,7 @@ class Import
|
|
|
$member[$key] = $account['id'];
|
|
|
}
|
|
|
if (!$member[$key]) {
|
|
|
- $table['body'][] = array($update['key'], $update['name'], $update['mobile'], $update['idcard'], '生成主账户失败');
|
|
|
+ $table['body'][] = array($update['key'], $update['company_id'], $update['name'], $update['mobile'], $update['idcard'], '生成主账户失败');
|
|
|
} else {
|
|
|
$table_status['body'][0][0] += 1;
|
|
|
}
|
|
@@ -152,6 +153,7 @@ class Import
|
|
|
if ($state) {
|
|
|
$key = $v['A'];
|
|
|
$mobile = $v['C'];
|
|
|
+ $company_id = (isset($v['F']) && $v['F']) ? trim($v['F']) : 1;
|
|
|
$update = array();
|
|
|
$update['main'] = $v['E'] == 1 ? 1 : 2;
|
|
|
if (!isset($check[$key])) {
|
|
@@ -237,7 +239,7 @@ class Import
|
|
|
$data = Dever::excelImport($file, 2, 5, 'excel');
|
|
|
|
|
|
$table = array();
|
|
|
- $table['head'] = array('手机号', '身份证号', '交付金额', '期权类型', '说明');
|
|
|
+ $table['head'] = array('公司ID', '手机号', '身份证号', '交付金额', '期权类型', '说明');
|
|
|
$table['body'] = array();
|
|
|
|
|
|
$table_status = array();
|
|
@@ -248,47 +250,53 @@ class Import
|
|
|
|
|
|
if ($data) {
|
|
|
foreach ($data as $k => $v) {
|
|
|
- $state = preg_match(Dever::rule('mobile'), $v['A']);
|
|
|
+ $mobile = trim($v['A']);
|
|
|
+ $state = preg_match(Dever::rule('mobile'), $mobile);
|
|
|
if ($state) {
|
|
|
+ $company_id = (isset($v['F']) && $v['F']) ? trim($v['F']) : 1;
|
|
|
if ($v['C'] > 0) {
|
|
|
$where['clear'] = true;
|
|
|
- $where['mobile'] = trim($v['A']);
|
|
|
+ $where['mobile'] = $mobile;
|
|
|
+ $where['company_id'] = $company_id;
|
|
|
$type_name = trim($v['D']);
|
|
|
- if ($type_name == '期权') {
|
|
|
- $type = 1;
|
|
|
- } else {
|
|
|
- $type = 4;
|
|
|
- }
|
|
|
- $info = Dever::db('option/member')->find($where);
|
|
|
- if ($info) {
|
|
|
- $idcard = strtoupper(trim($v['B']));
|
|
|
- if ($info['idcard'] != $idcard) {
|
|
|
- $table['body'][] = array($info['mobile'], $info['idcard'], $idcard, $type_name, '手机号和身份证不对应');
|
|
|
- } else {
|
|
|
- $account = Dever::db('option/account')->find(array('id' => $info['aid'], 'clear' => true));
|
|
|
- if ($account && $account['status'] < 3) {
|
|
|
- if ($check == 1) {
|
|
|
- $state = true;
|
|
|
- } else {
|
|
|
- $state = Dever::load('option/lib/cash')->up($account['id'], $info['id'], $type, $v['C'], $v['E'], false);
|
|
|
- }
|
|
|
-
|
|
|
- if ($state) {
|
|
|
- $table_status['body'][0][0] += 1;
|
|
|
- $table_status['body'][0][1] += $v['C'];
|
|
|
+ $type_info = Dever::db('option/company_qiquan')->find(array('name' => $type_name, 'company_id' => $where['company_id']));
|
|
|
+ if ($type_info) {
|
|
|
+ $type = $type_info['id'];
|
|
|
+
|
|
|
+ $info = Dever::db('option/member')->find($where);
|
|
|
+ if ($info) {
|
|
|
+ $idcard = strtoupper(trim($v['B']));
|
|
|
+ if ($info['idcard'] != $idcard) {
|
|
|
+ $table['body'][] = array($company_id, $info['mobile'], $info['idcard'], $idcard, $type_name, '手机号和身份证不对应');
|
|
|
+ } else {
|
|
|
+ $account = Dever::db('option/account')->find(array('id' => $info['aid'], 'clear' => true));
|
|
|
+ if ($account && $account['status'] < 3) {
|
|
|
+ if ($check == 1) {
|
|
|
+ $state = true;
|
|
|
+ } else {
|
|
|
+ $state = Dever::load('option/lib/cash')->up($account['id'], $info['id'], $type, 'jiaofu', $v['C'], $v['E'], false);
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($state) {
|
|
|
+ $table_status['body'][0][0] += 1;
|
|
|
+ $table_status['body'][0][1] += $v['C'];
|
|
|
+ } else {
|
|
|
+ $table['body'][] = array($company_id, $info['mobile'], $info['idcard'], $v['C'], $type_name, '导入到数据表失败');
|
|
|
+ }
|
|
|
} else {
|
|
|
- $table['body'][] = array($info['mobile'], $info['idcard'], $v['C'], $type_name, '导入到数据表失败');
|
|
|
+ $table['body'][] = array($company_id, $info['mobile'], $info['idcard'], $v['C'], $type_name, '未找到主账户');
|
|
|
}
|
|
|
- } else {
|
|
|
- $table['body'][] = array($info['mobile'], $info['idcard'], $v['C'], $type_name, '未找到主账户');
|
|
|
}
|
|
|
+
|
|
|
+ } else {
|
|
|
+ $table['body'][] = array($company_id, $mobile, $v['B'], $v['C'], $type_name, '未找到期权账户');
|
|
|
}
|
|
|
-
|
|
|
} else {
|
|
|
- $table['body'][] = array($where['mobile'], $v['B'], $v['C'], $type_name, '未找到期权账户');
|
|
|
+ $table['body'][] = array($company_id, $mobile, $v['B'], $v['C'], $type_name, '期权类型不存在');
|
|
|
}
|
|
|
+
|
|
|
} else {
|
|
|
- $table['body'][] = array($v['A'], $v['B'], $v['C'], $v['D'], '交付金额为0');
|
|
|
+ $table['body'][] = array($company_id, $mobile, $v['B'], $v['C'], $v['D'], '交付金额为0');
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -330,44 +338,50 @@ class Import
|
|
|
|
|
|
if ($data) {
|
|
|
foreach ($data as $k => $v) {
|
|
|
- $state = preg_match(Dever::rule('mobile'), $v['A']);
|
|
|
+ $mobile = trim($v['A']);
|
|
|
+ $state = preg_match(Dever::rule('mobile'), $mobile);
|
|
|
if ($state) {
|
|
|
+ $company_id = (isset($v['F']) && $v['F']) ? trim($v['F']) : 1;
|
|
|
if ($v['C'] > 0) {
|
|
|
- $where['mobile'] = trim($v['A']);
|
|
|
+ $where['clear'] = true;
|
|
|
+ $where['mobile'] = $mobile;
|
|
|
+ $where['company_id'] = $company_id;
|
|
|
$type_name = trim($v['D']);
|
|
|
- if ($type_name == '期权') {
|
|
|
- $type = 2;
|
|
|
- } else {
|
|
|
- $type = 5;
|
|
|
- }
|
|
|
- $info = Dever::db('option/member')->find($where);
|
|
|
- if ($info) {
|
|
|
- $idcard = strtoupper(trim($v['B']));
|
|
|
- if ($info['idcard'] != $idcard) {
|
|
|
- $table['body'][] = array($info['mobile'], $info['idcard'], $idcard, $type_name, '手机号和身份证不对应');
|
|
|
- } else {
|
|
|
- $account = Dever::db('option/account')->find($info['aid']);
|
|
|
- if ($account && $account['status'] < 3) {
|
|
|
- if ($check == 1) {
|
|
|
- $state = true;
|
|
|
- } else {
|
|
|
- $state = Dever::load('option/lib/cash')->up($account['id'], $info['id'], $type, $v['C'], $v['E'], false);
|
|
|
- }
|
|
|
- if ($state) {
|
|
|
- $table_status['body'][0][0] += 1;
|
|
|
- $table_status['body'][0][1] += $v['C'];
|
|
|
+ $type_info = Dever::db('option/company_qiquan')->find(array('name' => $type_name, 'company_id' => $where['company_id']));
|
|
|
+ if ($type_info) {
|
|
|
+ $type = $type_info['id'];
|
|
|
+ $info = Dever::db('option/member')->find($where);
|
|
|
+ if ($info) {
|
|
|
+ $idcard = strtoupper(trim($v['B']));
|
|
|
+ if ($info['idcard'] != $idcard) {
|
|
|
+ $table['body'][] = array($company_id, $info['mobile'], $info['idcard'], $idcard, $type_name, '手机号和身份证不对应');
|
|
|
+ } else {
|
|
|
+ $account = Dever::db('option/account')->find($info['aid']);
|
|
|
+ if ($account && $account['status'] < 3) {
|
|
|
+ if ($check == 1) {
|
|
|
+ $state = true;
|
|
|
+ } else {
|
|
|
+ $state = Dever::load('option/lib/cash')->up($account['id'], $info['id'], $type, 'fafang', $v['C'], $v['E'], false);
|
|
|
+ }
|
|
|
+ if ($state) {
|
|
|
+ $table_status['body'][0][0] += 1;
|
|
|
+ $table_status['body'][0][1] += $v['C'];
|
|
|
+ } else {
|
|
|
+ $table['body'][] = array($company_id, $info['mobile'], $info['idcard'], $v['C'], $type_name, '交付价值不足');
|
|
|
+ }
|
|
|
} else {
|
|
|
- $table['body'][] = array($info['mobile'], $info['idcard'], $v['C'], $type_name, '交付价值不足');
|
|
|
+ $table['body'][] = array($company_id, $info['mobile'], $info['idcard'], $v['C'], $type_name, '未找到主账户');
|
|
|
}
|
|
|
- } else {
|
|
|
- $table['body'][] = array($info['mobile'], $info['idcard'], $v['C'], $type_name, '未找到主账户');
|
|
|
}
|
|
|
+ } else {
|
|
|
+ $table['body'][] = array($company_id, $mobile, $v['B'], $v['C'], $type_name, '未找到期权账户');
|
|
|
}
|
|
|
} else {
|
|
|
- $table['body'][] = array($where['mobile'], $v['B'], $v['C'], $type_name, '未找到期权账户');
|
|
|
+ $table['body'][] = array($company_id, $mobile, $v['B'], $v['C'], $type_name, '期权类型不存在');
|
|
|
}
|
|
|
+
|
|
|
} else {
|
|
|
- $table['body'][] = array($v['A'], $v['B'], $v['C'], $v['D'], '发放金额为0');
|
|
|
+ $table['body'][] = array($company_id, $mobile, $v['B'], $v['C'], $v['D'], '发放金额为0');
|
|
|
}
|
|
|
}
|
|
|
}
|