...
|
...
|
@@ -147,43 +147,43 @@ class Cards extends Backend |
|
|
//加载文件
|
|
|
$insert = [];
|
|
|
// try {
|
|
|
if (!$PHPExcel = $reader->load($filePath)) {
|
|
|
$this->error(__('Unknown data format'));
|
|
|
}
|
|
|
$currentSheet = $PHPExcel->getSheet(0); //读取文件中的第一个工作表
|
|
|
$allColumn = $currentSheet->getHighestDataColumn(); //取得最大的列号
|
|
|
$allRow = $currentSheet->getHighestRow(); //取得一共有多少行
|
|
|
$maxColumnNumber = Coordinate::columnIndexFromString($allColumn);
|
|
|
$fields = [];
|
|
|
for ($currentRow = 1; $currentRow <= 1; $currentRow++) {
|
|
|
for ($currentColumn = 1; $currentColumn <= $maxColumnNumber; $currentColumn++) {
|
|
|
$val = $currentSheet->getCellByColumnAndRow($currentColumn, $currentRow)->getValue();
|
|
|
$fields[] = $val;
|
|
|
}
|
|
|
if (!$PHPExcel = $reader->load($filePath)) {
|
|
|
$this->error(__('Unknown data format'));
|
|
|
}
|
|
|
$currentSheet = $PHPExcel->getSheet(0); //读取文件中的第一个工作表
|
|
|
$allColumn = $currentSheet->getHighestDataColumn(); //取得最大的列号
|
|
|
$allRow = $currentSheet->getHighestRow(); //取得一共有多少行
|
|
|
$maxColumnNumber = Coordinate::columnIndexFromString($allColumn);
|
|
|
$fields = [];
|
|
|
for ($currentRow = 1; $currentRow <= 1; $currentRow++) {
|
|
|
for ($currentColumn = 1; $currentColumn <= $maxColumnNumber; $currentColumn++) {
|
|
|
$val = $currentSheet->getCellByColumnAndRow($currentColumn, $currentRow)->getValue();
|
|
|
$fields[] = $val;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
for ($currentRow = 2; $currentRow <= $allRow; $currentRow++) {
|
|
|
$values = [];
|
|
|
for ($currentColumn = 1; $currentColumn <= $maxColumnNumber; $currentColumn++) {
|
|
|
$val = $currentSheet->getCellByColumnAndRow($currentColumn, $currentRow)->getValue();
|
|
|
$values[] = is_null($val) ? '' : $val;
|
|
|
}
|
|
|
$row = [];
|
|
|
$temp = array_combine($fields, $values);
|
|
|
foreach ($temp as $k => $v) {
|
|
|
if (isset($fieldArr[$k]) && $k !== '') {
|
|
|
$row[$fieldArr[$k]] = $v;
|
|
|
}
|
|
|
}
|
|
|
if ($row) {
|
|
|
$insert[] = $row;
|
|
|
for ($currentRow = 2; $currentRow <= $allRow; $currentRow++) {
|
|
|
$values = [];
|
|
|
for ($currentColumn = 1; $currentColumn <= $maxColumnNumber; $currentColumn++) {
|
|
|
$val = $currentSheet->getCellByColumnAndRow($currentColumn, $currentRow)->getValue();
|
|
|
$values[] = is_null($val) ? '' : $val;
|
|
|
}
|
|
|
$row = [];
|
|
|
$temp = array_combine($fields, $values);
|
|
|
foreach ($temp as $k => $v) {
|
|
|
if (isset($fieldArr[$k]) && $k !== '') {
|
|
|
$row[$fieldArr[$k]] = $v;
|
|
|
}
|
|
|
}
|
|
|
$Bili = Db::name('bili')->where('id', 1)->value('bili');
|
|
|
if (empty($Bili)) {
|
|
|
$this->error('请先设置积分比例');
|
|
|
if ($row) {
|
|
|
$insert[] = $row;
|
|
|
}
|
|
|
$Api = new SetCode();
|
|
|
}
|
|
|
$Bili = Db::name('bili')->where('id', 1)->value('bili');
|
|
|
if (empty($Bili)) {
|
|
|
$this->error('请先设置积分比例');
|
|
|
}
|
|
|
$Api = new SetCode();
|
|
|
// foreach ($insert as $k => $v) {
|
|
|
// if (strlen($v['mobile']) != 11) {
|
|
|
// $this->error('手机号错误' . $v['mobile']);
|
...
|
...
|
@@ -194,41 +194,41 @@ class Cards extends Backend |
|
|
// die;
|
|
|
// }
|
|
|
// }
|
|
|
foreach ($insert as $k => $v) {
|
|
|
if (strlen($v['mobile']) != 11) {
|
|
|
$this->error('手机号错误');
|
|
|
die;
|
|
|
}
|
|
|
if (strlen($v['CardsNum']) != 18) {
|
|
|
$this->error(__('手机号错误' . $v['CardsNum']));
|
|
|
die;
|
|
|
}
|
|
|
foreach ($insert as $k => $v) {
|
|
|
if (strlen($v['mobile']) != 11) {
|
|
|
$this->error(__('手机号错误' . $v['mobile']));
|
|
|
die;
|
|
|
}
|
|
|
if (strlen($v['CardsNum']) != 18) {
|
|
|
$this->error(__('身份证号错误' . $v['CardsNum']));
|
|
|
die;
|
|
|
}
|
|
|
|
|
|
$insert[$k]['mobile'] = $Api->encrypt($v['mobile']);
|
|
|
$insert[$k]['CardsNum'] = $Api->encrypt(substr($v['CardsNum'], 7));
|
|
|
$insert[$k]['remark'] = $Api->encrypt($v['remark']);
|
|
|
$insert[$k]['money'] = $Api->encrypt($v['money']);
|
|
|
$insert[$k]['mobile'] = $Api->encrypt($v['mobile']);
|
|
|
$insert[$k]['CardsNum'] = $Api->encrypt(substr($v['CardsNum'], 7));
|
|
|
$insert[$k]['remark'] = $Api->encrypt($v['remark']);
|
|
|
$insert[$k]['money'] = $Api->encrypt($v['money']);
|
|
|
// $insert[$k]['money'] = $v['money'];
|
|
|
$insert[$k]['createtime'] = time();
|
|
|
$Arr = Db::name('cards')->where('mobile', $Api->encrypt($v['mobile']))->where('CardsNum', $Api->encrypt(substr($v['CardsNum'], 6)))->where('remark', $Api->encrypt($v['remark']))->order('id desc')->find();
|
|
|
if (empty($Arr)) {
|
|
|
$insert[$k]['num'] = $Api->encrypt($Bili * $v['money']);
|
|
|
$insert[$k]['createtime'] = time();
|
|
|
$Arr = Db::name('cards')->where('mobile', $Api->encrypt($v['mobile']))->where('CardsNum', $Api->encrypt(substr($v['CardsNum'], 6)))->where('remark', $Api->encrypt($v['remark']))->order('id desc')->find();
|
|
|
if (empty($Arr)) {
|
|
|
$insert[$k]['num'] = $Api->encrypt($Bili * $v['money']);
|
|
|
// $insert[$k]['num'] = $Bili * $v['money'];
|
|
|
$insert[$k]['type'] = 1;
|
|
|
} else {
|
|
|
$ArrMoney = $Api->decrypt($Arr['money']);
|
|
|
$ArrNum = $Api->decrypt($Arr['num']);
|
|
|
$insert[$k]['type'] = 1;
|
|
|
} else {
|
|
|
$ArrMoney = $Api->decrypt($Arr['money']);
|
|
|
$ArrNum = $Api->decrypt($Arr['num']);
|
|
|
// $ArrNum = $Arr['num'];
|
|
|
if ($v['money'] > $ArrMoney) {
|
|
|
$insert[$k]['num'] = $Api->encrypt((($v['money'] - $ArrMoney) * $Bili) + $ArrNum);
|
|
|
if ($v['money'] > $ArrMoney) {
|
|
|
$insert[$k]['num'] = $Api->encrypt((($v['money'] - $ArrMoney) * $Bili) + $ArrNum);
|
|
|
// $insert[$k]['num'] = (($v['money'] - $ArrMoney) * $Bili) + $ArrNum;
|
|
|
$insert[$k]['type'] = 1;
|
|
|
} else {
|
|
|
$insert[$k]['num'] = 0;
|
|
|
$insert[$k]['type'] = 0;
|
|
|
}
|
|
|
$insert[$k]['type'] = 1;
|
|
|
} else {
|
|
|
$insert[$k]['num'] = 0;
|
|
|
$insert[$k]['type'] = 0;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
// } catch (Exception $exception) {
|
|
|
// $this->error($exception->getMessage());
|
|
|
// }
|
...
|
...
|
|