diff --git a/application/admin/controller/Dashboard.php b/application/admin/controller/Dashboard.php index 1edc25b..9fb5437 100644 --- a/application/admin/controller/Dashboard.php +++ b/application/admin/controller/Dashboard.php @@ -77,7 +77,9 @@ class Dashboard extends Backend 'visittime'=>['<=',Date::unixtime('day', 0,'end')] ); $visit = Visit::where($visit_where)->where('status',0)->count(); - //var_dump(Visit::getlastsql()); + //今日生日 + $birthday_users = Db::query("select count(*) as num from car_user4s_user where MONTH(birthday) = MONTH(NOW()) and DAY(birthday) = DAY(NOW())"); + //var_dump(Db::getlastsql(), $birthday_users); $index_data = [ 'totaluser' => User::count(), 'totalvipuser' => User::where('level_id','>','1')->count(), @@ -96,6 +98,7 @@ class Dashboard extends Backend // return $item['Data_length'] + $item['Index_length']; // }, $dbTableList)), // 'totalworkingaddon' => $totalworkingaddon, + 'birthday_num' => isset($birthday_users[0]['num']) ? $birthday_users[0]['num'] : 0, 'ins_end' => $ins_end, 'visit' => $visit, 'all_visit' => Visit::count(), diff --git a/application/admin/controller/import/Log.php b/application/admin/controller/import/Log.php index 64e3fac..2387404 100644 --- a/application/admin/controller/import/Log.php +++ b/application/admin/controller/import/Log.php @@ -9,6 +9,7 @@ use PhpOffice\PhpSpreadsheet\Cell\Coordinate; use PhpOffice\PhpSpreadsheet\Reader\Xlsx; use PhpOffice\PhpSpreadsheet\Reader\Xls; use PhpOffice\PhpSpreadsheet\Reader\Csv; +use PhpOffice\PhpSpreadsheet\Shared\Date; use think\Exception; use think\exception\PDOException; use think\exception\ValidateException; @@ -81,7 +82,7 @@ class Log extends Backend * 添加 */ public function add() - { + { if ($this->request->isPost()) { $params = $this->request->post("row/a"); $step = $params['step']; @@ -99,18 +100,13 @@ class Log extends Backend $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate; $this->model->validateFailException(true)->validate($validate); } - //新建表导入处理 - if ($params['newtable']) { - $prefix = Config::get('database.prefix'); - $table = $prefix . $params['newtable']; - $check = db()->query("SHOW TABLES LIKE '%{$table}%';"); - if ($check) { - $this->error(__($params['newtable'] . '表已经存在')); - } - } else { - if (!$params['table']) $this->error('未选择目标表'); - } + $prefix = Config::get('database.prefix'); + //导入文件首行类型,默认是注释,如果需要使用字段名称请使用name + $importHeadType = 'comment';//name + $table = $prefix.'user4s_user'; + $params['newtable'] = false; + $params['table'] = $table; $fileData = $this->fileData($params); @@ -130,52 +126,41 @@ class Log extends Backend } } if ($has_admin_id) { - foreach ($insert as &$val) { + foreach ($insert as $key => &$val) { if (!isset($val['admin_id']) || empty($val['admin_id'])) { $val['admin_id'] = $this->auth->isLogin() ? $this->auth->id : 0; } } } + foreach ($insert as $key => &$val) { + //处理字段 + $cardinfo = $this->checkcardid($val['cardid']); + if ($cardinfo['iscard'] == false) { + unset($insert[$key]); + }else{ + $val['birthday'] = $cardinfo['birthday']; + $val['genderdata'] = $cardinfo['sex']; + } + if(empty($val['frameno'])){ + unset($insert[$key]); + }else{ + $check_frameno = $this->check_frameno($val['frameno']); + if($check_frameno == false){ + unset($insert[$key]); + } + } + } + var_dump($insert);exit(); $prefix = Config::get('database.prefix'); $count = 0; if ($params['update']) { foreach ($insert as &$val) { - $count += Db::name(str_replace($prefix, "", $params['table'])) + $count += Db::name('user4s_user') ->where($params['update'], $val['pid']) ->update($val); } } else { - if ($params['to']) { - $file = db('attachment')->where('url', $fileData['path'])->find(); - $this->fieldModel = new \app\admin\model\salary\Field; - $fields = $this->fieldModel->where('name', 'not in', ['pid', 'name', 'status', 'create_time', 'update_time', 'deletetime'])->select(); - $toData = []; - // dump($fields); - $insertData = []; - foreach ($insert as $key => $val) { - foreach ($fields as $ke => $field) { - if (isset($val[$field['name']])) { - $toData[$ke]['pid'] = $val['pid']; - $toData[$ke]['name'] = $val['name']; - $toData[$ke]['type'] = $field['name']; - $toData[$ke]['type_name'] = $field['desc']; - $toData[$ke]['field_type'] = $field['type']; - $toData[$ke]['je'] = $val[$field['name']]; - $toData[$ke]['filename'] = $file['filename']; - $toData[$ke]['sha1'] = $file['sha1']; - $toData[$ke]['createtime'] = time(); - } - } - if ($insertData) $insertData = array_merge($insertData, $toData); - else $insertData = $toData; - } - // dump($insertData); - // exit; - Db::name(str_replace($prefix, "", $params['to']))->where('sha1', $file['sha1'])->delete(); - $res = Db::name(str_replace($prefix, "", $params['to']))->insertAll($insertData); - } else { - $res = Db::name(str_replace($prefix, "", $params['table']))->insertAll($insert); - } + $res = Db::name('user4s_user')->insertAll($insert); $count = count($insert); } @@ -283,11 +268,23 @@ class Log extends Backend } } - + public function check_frameno($frameno) + { + if(empty($frameno)){ + return false; + } + $user = new \app\common\model\user4s\User; + $has_frameno = $user->where(['frameno' =>$frameno])->find(); + if (empty($has_frameno->id)) { + return true; + }else{ + return false; + } + } protected function fileData($params) { $file = $path = $params['path']; - $row = $params['row']; + $row = 2; $sheet = 0; if (!$file) { $this->error(__('Parameter %s can not be empty', 'file')); @@ -330,8 +327,9 @@ class Log extends Backend $prefix = Config::get('database.prefix'); //导入文件首行类型,默认是注释,如果需要使用字段名称请使用name - $importHeadType = $params['head_type']; - $table = $params['table']; + $importHeadType = 'comment';//name + $table = $prefix.'user4s_user'; + $params['newtable'] = false; $database = \think\Config::get('database.database'); $fieldArr = []; $notnull = []; @@ -342,6 +340,7 @@ class Log extends Backend "SELECT COLUMN_NAME,COLUMN_COMMENT,COLUMN_TYPE,IS_NULLABLE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = ? AND TABLE_SCHEMA = ?", [$table, $database] ); + //var_dump($list,$table, $database); foreach ($list as $k => $v) { if ($v['COLUMN_NAME'] !== $pk) { if ($importHeadType == 'comment') { @@ -373,10 +372,12 @@ class Log extends Backend } $currentSheet = $PHPExcel->getSheet($sheet); //读取文件中的第一个工作表 $allColumn = $currentSheet->getHighestDataColumn(); //取得最大的列号 + $allColumn = 'O'; //todo:取得最大的列号 + //var_dump($allColumn); $allRow = $currentSheet->getHighestRow(); //取得一共有多少行 $maxColumnNumber = Coordinate::columnIndexFromString($allColumn); $fields = []; - + //todo:处理表头第一行 for ($currentRow = 1; $currentRow <= 1; $currentRow++) { for ($currentColumn = 1; $currentColumn <= $maxColumnNumber; $currentColumn++) { $val = $currentSheet->getCellByColumnAndRow($currentColumn, $currentRow)->getValue(); @@ -388,6 +389,34 @@ class Log extends Backend 'field' => $val, 'fieldName' => isset($fieldArr[$val]) ? $fieldArr[$val]['COLUMN_NAME'] : '--' //Pinyin::get($val), ); + + //手动加入表头字段 + // if($val == '身份证' && $currentColumn == 3){ + // $val = '性别'; + // $fields[] = $val; + // $col[] = array( + // 'title' => $val, + // 'class' => isset($fieldArr[$val]) ? 'success' : '-', + // 'type' => isset($fieldArr[$val]) ? $fieldArr[$val]['COLUMN_TYPE'] : '--', + // 'field' => $val, + // 'fieldName' => isset($fieldArr[$val]) ? $fieldArr[$val]['COLUMN_NAME'] : '--' //Pinyin::get($val), + // ); + // $val = '生日'; + // $fields[] = $val; + // $col[] = array( + // 'title' => $val, + // 'class' => isset($fieldArr[$val]) ? 'success' : '-', + // 'type' => isset($fieldArr[$val]) ? $fieldArr[$val]['COLUMN_TYPE'] : '--', + // 'field' => $val, + // 'fieldName' => isset($fieldArr[$val]) ? $fieldArr[$val]['COLUMN_NAME'] : '--' //Pinyin::get($val), + // ); + // //var_dump($col);exit(); + // $count += 2; + // } + // if($currentColumn == $maxColumnNumber){ + // $fields[] = '身份证校验'; + // $fields[] = '车架号校验'; + // } if (isset($fieldArr[$val])) { $count += 1; } @@ -395,14 +424,35 @@ class Log extends Backend } for ($currentRow = $row; $currentRow <= $allRow; $currentRow++) { $values = []; + // $check_cardid = true; + // $check_frameno = true; for ($currentColumn = 1; $currentColumn <= $maxColumnNumber; $currentColumn++) { + //var_dump($currentSheet->getCellByColumnAndRow($currentColumn, $currentRow)); $val = $currentSheet->getCellByColumnAndRow($currentColumn, $currentRow)->getValue(); + //todo:处理日期格式 + if($currentColumn == 8 || $currentColumn == 15){ + $val = date('Y-m-d',Date::excelToTimestamp($val)); + } + $values[] = is_null($val) ? '' : $val; + //todo:手工处理自定义字段 + // if($currentColumn == 3){ + // $cardinfo = $this->checkcardid($val); + // $check_cardid = $cardinfo['iscard']; + // $values[] = $cardinfo['sex'] == 'female' ?'女':'男'; + // $values[] = $cardinfo['birthday']; + // } + // if($currentColumn == 10){ + // $check_frameno = $this->check_frameno($val); + // } + // if($currentColumn == $maxColumnNumber){ + // $values[] = $check_cardid?'成功':'失败'; + // $values[] = $check_frameno?'成功':'失败'; + // } } $rows = []; $all = []; $temp = array_combine($fields, $values); - foreach ($temp as $k => $v) { if (isset($fieldArr[$k]) && $k !== '') { $rows[$fieldArr[$k]['COLUMN_NAME']] = $v; @@ -415,6 +465,7 @@ class Log extends Backend } $allData[] = $all; } + return array( 'path' => $path, 'field' => $col, diff --git a/application/admin/controller/user4s/User.php b/application/admin/controller/user4s/User.php index e5cd421..00ae73d 100644 --- a/application/admin/controller/user4s/User.php +++ b/application/admin/controller/user4s/User.php @@ -12,6 +12,13 @@ use think\Db; use think\exception\PDOException; use think\exception\ValidateException; +use think\Config; +use PhpOffice\PhpSpreadsheet\Cell\Coordinate; +use PhpOffice\PhpSpreadsheet\Reader\Xlsx; +use PhpOffice\PhpSpreadsheet\Reader\Xls; +use PhpOffice\PhpSpreadsheet\Reader\Csv; +use fast\Pinyin; + /** * 用户档案 * @@ -99,7 +106,7 @@ class User extends Backend $this->request->filter(['strip_tags', 'trim']); if ($this->request->isAjax()) { $id = $this->request->param('id'); - if(empty($id)){ + if (empty($id)) { $result = array("code" => 1, "msg" => '用户ID为空'); return json($result); }; @@ -107,7 +114,7 @@ class User extends Backend if (!$row) { $result = array("code" => 1, "msg" => __('No Results were found')); return json($result); - }else{ + } else { //$row->getRelation('category')->visible(['name']); //$row->getRelation('level')->visible(['name']); $result = array("code" => 0, "msg" => 'success', "data" => $row); @@ -139,16 +146,29 @@ class User extends Backend $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate; $this->model->validateFailException(true)->validate($validate); } + $cardinfo = $this->checkcardid($params['cardid']); + if ($cardinfo['iscard'] == false) { + $this->model->rollback(); + $this->error('身份证号错误'); + } else { + $params['birthday'] = $cardinfo['birthday']; + $params['genderdata'] = $cardinfo['sex']; + } + $has_frameno = $this->model->get(['frameno', $params['frameno']]); + if (!empty($has_frameno->id)) { + $this->model->rollback(); + $this->error('车架号重复'); + } $result = $this->model->allowField(true)->save($params); //var_dump($params['need_visit']); //新加用户期初等级 - if($result && $this->model->id){ - if($params['need_visit'] == 1){ - $log_res = $this->model->afterlog($this->auth->id,$this->model,$this->model->id,'',true); - }else{ - $log_res = $this->model->afterlog($this->auth->id,$this->model,$this->model->id,'',false); + if ($result && $this->model->id) { + if ($params['need_visit'] == 1) { + $log_res = $this->model->afterlog($this->auth->id, $this->model, $this->model->id, '', true); + } else { + $log_res = $this->model->afterlog($this->auth->id, $this->model, $this->model->id, '', false); } - if(!$log_res){ + if (!$log_res) { $this->model->rollback(); $this->error('新增失败'); } @@ -197,8 +217,82 @@ class User extends Backend if ($this->request->isPost()) { $params = $this->request->post("row/a"); + if ($params) { + $params = $this->preExcludeFields($params); + $result = false; + $this->model->startTrans(); + try { + //是否采用模型验证 + if ($this->modelValidate) { + $name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate; + $row->validateFailException(true)->validate($validate); + } + $cardinfo = $this->checkcardid($params['cardid']); + if ($cardinfo['iscard'] == false) { + $this->model->rollback(); + $this->error('身份证号错误'); + } else { + $params['birthday'] = $cardinfo['birthday']; + $params['genderdata'] = $cardinfo['sex']; + } + $has_frameno = $this->model->get(['frameno', $params['frameno']]); + if (!empty($has_frameno->id)) { + $this->model->rollback(); + $this->error('车架号重复'); + } + $result = $this->model->allowField(true)->save($params); + $result = $row->allowField(true)->save($params); + $this->model->commit(); + } catch (ValidateException $e) { + $this->model->rollback(); + $this->error($e->getMessage()); + } catch (PDOException $e) { + $this->model->rollback(); + $this->error($e->getMessage()); + } catch (Exception $e) { + $this->model->rollback(); + $this->error($e->getMessage()); + } + if ($result !== false) { + $this->success(); + } else { + $this->error(__('No rows were updated')); + } + } + $this->error(__('Parameter %s can not be empty', '')); } - return parent::edit($ids); + $this->view->assign("row", $row); + return $this->view->fetch(); + } + public function check_cardid() + { + if ($this->request->isPost()) { + $params = $this->request->post("row/a"); + if ($params) { + $cardinfo = $this->checkcardid($params['cardid']); + if ($cardinfo['iscard']) { + $this->success('身份证号正确'); + } + } + $this->error('身份证号错误'); + } + $this->error('获取数据错误'); + } + public function check_frameno() + { + if ($this->request->isPost()) { + $params = $this->request->post("row/a"); + if ($params) { + $has_frameno = $this->model->where(['frameno' => $params['frameno']])->find(); + //var_dump($has_frameno); + if (empty($has_frameno->id)) { + $this->success('车架号正确'); + } + } + $this->error('车架号重复'); + } + $this->error('车架号重复'); } /** * 删除 @@ -274,7 +368,7 @@ class User extends Backend //记录用户充值、积分、等级记录 $log_data = array( 'user4s_id' => $row->id, - 'admin_id'=>$this->auth->id + 'admin_id' => $this->auth->id ); //余额充值 if ($params['balance'] > 0) { @@ -296,10 +390,10 @@ class User extends Backend $log_data['start'] = $row->integral; $log_data['end'] = $end; $log_data['state'] = 1; - if($now > 0){ - $log_data['description'] = $params['description'].' 赠送积分:'.$now; - }else{ - $log_data['description'] = $params['description'].' 系统后台扣除积分'.$now; + if ($now > 0) { + $log_data['description'] = $params['description'] . ' 赠送积分:' . $now; + } else { + $log_data['description'] = $params['description'] . ' 系统后台扣除积分' . $now; } $this->log_model = new \app\common\model\user4s\Log(); $this->log_model->isUpdate(false)->save($log_data); @@ -312,12 +406,12 @@ class User extends Backend $log_data['start'] = $row->level_id; $log_data['end'] = $end; - $log_data['description'] = '会员等级变动,由 '.$all_level[$row->level_id].' 更改为:'.$all_level[$end]; + $log_data['description'] = '会员等级变动,由 ' . $all_level[$row->level_id] . ' 更改为:' . $all_level[$end]; //var_dump($log_data); $this->levellog_model->isUpdate(false)->save($log_data); $user_data['level_id'] = $end; } - if(isset($user_data['balance']) || isset($user_data['integral']) || isset($user_data['level_id'])){ + if (isset($user_data['balance']) || isset($user_data['integral']) || isset($user_data['level_id'])) { //var_dump($user_data); //$this->model->get($row->id); $this->model->save($user_data, ['id' => $row->id]); @@ -338,17 +432,28 @@ class User extends Backend $this->relationSearch = true; //设置过滤方法 $this->request->filter(['strip_tags', 'trim']); + $start_date = strtotime("-1 year"); - $end_date = strtotime("+2 month",$start_date); + $end_date = strtotime("+2 month", $start_date); $ins_where = array( - 'insdate'=>['between',[date('Y-m-d',$start_date),date('Y-m-d',$end_date)]] + 'insdate' => ['between', [date('Y-m-d', $start_date), date('Y-m-d', $end_date)]] ); + if ($this->request->isAjax()) { list($where, $sort, $order, $offset, $limit) = $this->buildparams(); $list = $this->model ->with(['category', 'level']) ->where($where) - ->where($ins_where) + ->where(function ($query) { + for ($y=1; $y<=20; $y++) { + $start_date = strtotime("-".$y." year"); + $end_date = strtotime("+2 month", $start_date); + $ins_where = array( + 'insdate' => ['between', [date('Y-m-d', $start_date), date('Y-m-d', $end_date)]] + ); + $query->whereOr($ins_where); + } + }) ->order($sort, $order) ->paginate($limit); //var_dump($this->model->getLastSql()); @@ -357,7 +462,7 @@ class User extends Backend $row->getRelation('level')->visible(['name']); } - $result = array("total" => $list->total(), "rows" => $list->items(),"extend" => ['start_date' => date('Y-m-d',$start_date), 'end_date' => date('Y-m-d',$end_date)]); + $result = array("total" => $list->total(), "rows" => $list->items(), "extend" => ['start_date' => date('m-d', $start_date), 'end_date' => date('m-d', $end_date)]); return json($result); } @@ -390,31 +495,33 @@ class User extends Backend if (!empty($params['inscom']) && !empty($params['insdate'])) { $log_data = array( 'user4s_id' => $row->id, - 'admin_id'=>$this->auth->id, - 'inscom'=>$params['inscom'], - 'insdate'=>$params['insdate'], - 'star'=>$params['star'], - 'description'=>$params['description'] + 'admin_id' => $this->auth->id, + 'instype' => $params['instype'], + 'inscom' => $params['inscom'], + 'insdate' => $params['insdate'], + 'star' => $params['star'], + 'description' => $params['description'] ); $this->Inslog_model = new \app\common\model\user4s\Inslog(); $this->Inslog_model->isUpdate(false)->save($log_data); $user_data = array( - 'inscom'=>$params['inscom'], - 'insdate'=>$params['insdate'], + 'instype' => $params['instype'], + 'inscom' => $params['inscom'], + 'insdate' => $params['insdate'], ); $this->model->save($user_data, ['id' => $row->id]); - }else{ - $this->error('请填写续保信息',url('user4s/user/expireins',['user4s_id'=>$row->id])); + } else { + $this->error('请填写续保信息', url('user4s/user/expireins', ['user4s_id' => $row->id])); } - $this->success('续保成功!',url('user4s/user/expireins',['user4s_id'=>$row->id])); + $this->success('续保成功!', url('user4s/user/expireins', ['user4s_id' => $row->id])); } //var_dump($col); $all_star = array( - 1=>'★', - 2=>'★★', - 3=>'★★★', - 4=>'★★★★', - 5=>'★★★★★', + 1 => '★', + 2 => '★★', + 3 => '★★★', + 4 => '★★★★', + 5 => '★★★★★', ); $this->view->assign("now", date('Y-m-d')); $this->view->assign("all_star", $all_star); @@ -422,4 +529,177 @@ class User extends Backend return $this->view->fetch(); } + /** + * 过生日用户列表 + */ + public function birthday() + { + //当前是否为关联查询 + $this->relationSearch = true; + //设置过滤方法 + $this->request->filter(['strip_tags', 'trim']); + + if ($this->request->isAjax()) { + $birthday_users = Db::query("select id from car_user4s_user where MONTH(birthday) = MONTH(NOW()) and DAY(birthday) = DAY(NOW())"); + if(empty($birthday_users)){ + $result = array("total" => 0, "rows" => [], "extend" => ['start_date' => date('m-d')]); + return json($result); + }else{ + foreach ($birthday_users as $key => $value) { + $birthday_user_ids[] = $value['id']; + } + } + if(empty($birthday_user_ids)){ + $result = array("total" => 0, "rows" => [], "extend" => ['start_date' => date('m-d')]); + return json($result); + } + //var_dump($birthday_user_ids); + list($where, $sort, $order, $offset, $limit) = $this->buildparams(); + $list = $this->model + ->with(['category', 'level']) + ->where($where) + ->where('user.id', 'in', $birthday_user_ids) + ->order($sort, $order) + ->paginate($limit); + //var_dump($this->model->getLastSql()); + foreach ($list as $row) { + $row->getRelation('category')->visible(['name']); + $row->getRelation('level')->visible(['name']); + } + + $result = array("total" => $list->total(), "rows" => $list->items(), "extend" => ['start_date' => date('m-d')]); + return json($result); + } + return $this->view->fetch(); + } + /** + * 导入数据界面 + */ + public function excel() + { + if ($this->request->isPost()) { + $params = $this->request->post("row/a"); + $step = $params['step']; + if ($params) { + $params = $this->preExcludeFields($params); + if ($this->dataLimit && $this->dataLimitFieldAutoFill) { + $params[$this->dataLimitField] = $this->auth->id; + } + $result = false; + Db::startTrans(); + try { + //是否采用模型验证 + if ($this->modelValidate) { + $name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate; + $this->model->validateFailException(true)->validate($validate); + } + //新建表导入处理 + if ($params['newtable']) { + $prefix = Config::get('database.prefix'); + $table = $prefix . $params['newtable']; + $check = db()->query("SHOW TABLES LIKE '%{$table}%';"); + if ($check) { + $this->error(__($params['newtable'] . '表已经存在')); + } + } else { + if (!$params['table']) $this->error('未选择目标表'); + } + + $fileData = $this->fileData($params); + + + $fileData['params'] = http_build_query($params); + $fileData['newtable'] = $params['newtable']; + if (!$step) { + $this->success('匹配到' . $fileData['count'] . '列,开始预览', '', $fileData); + } + $insert = $fileData['insert']; + $fieldArr = $fileData['fieldArr']; + //是否包含admin_id字段 + $has_admin_id = false; + foreach ($fieldArr as $name => $key) { + if ($key == 'admin_id') { + $has_admin_id = true; + break; + } + } + if ($has_admin_id) { + foreach ($insert as &$val) { + if (!isset($val['admin_id']) || empty($val['admin_id'])) { + $val['admin_id'] = $this->auth->isLogin() ? $this->auth->id : 0; + } + } + } + $prefix = Config::get('database.prefix'); + $count = 0; + if ($params['update']) { + foreach ($insert as &$val) { + $count += Db::name(str_replace($prefix, "", $params['table'])) + ->where($params['update'], $val['pid']) + ->update($val); + } + } else { + if ($params['to']) { + $file = db('attachment')->where('url', $fileData['path'])->find(); + $this->fieldModel = new \app\admin\model\salary\Field; + $fields = $this->fieldModel->where('name', 'not in', ['pid', 'name', 'status', 'create_time', 'update_time', 'deletetime'])->select(); + $toData = []; + // dump($fields); + $insertData = []; + foreach ($insert as $key => $val) { + foreach ($fields as $ke => $field) { + if (isset($val[$field['name']])) { + $toData[$ke]['pid'] = $val['pid']; + $toData[$ke]['name'] = $val['name']; + $toData[$ke]['type'] = $field['name']; + $toData[$ke]['type_name'] = $field['desc']; + $toData[$ke]['field_type'] = $field['type']; + $toData[$ke]['je'] = $val[$field['name']]; + $toData[$ke]['filename'] = $file['filename']; + $toData[$ke]['sha1'] = $file['sha1']; + $toData[$ke]['createtime'] = time(); + } + } + if ($insertData) $insertData = array_merge($insertData, $toData); + else $insertData = $toData; + } + // dump($insertData); + // exit; + Db::name(str_replace($prefix, "", $params['to']))->where('sha1', $file['sha1'])->delete(); + $res = Db::name(str_replace($prefix, "", $params['to']))->insertAll($insertData); + } else { + $res = Db::name(str_replace($prefix, "", $params['table']))->insertAll($insert); + } + $count = count($insert); + } + + + Db::commit(); + } catch (ValidateException $e) { + Db::rollback(); + $this->error($e->getMessage()); + } catch (PDOException $e) { + Db::rollback(); + $this->error($e->getMessage()); + } catch (Exception $e) { + Db::rollback(); + $this->error($e->getMessage()); + } + if ($count !== false) { + $params['status'] = 'normal'; + $result = $this->model->allowField(true)->save($params); + $tip = $params['update'] ? '成功更新' : '成功新增'; + $this->success($tip . $count . '条记录', '', array('count' => $count)); + } else { + $this->error(__('No rows were inserted')); + } + } + + $this->error(__('Parameter %s can not be empty', '')); + } + $this->view->assign("update", $this->request->request('update')); + $this->view->assign("to", $this->request->request('to')); + return $this->view->fetch(); + } } diff --git a/application/admin/lang/zh-cn/user4s/inslog.php b/application/admin/lang/zh-cn/user4s/inslog.php index f170366..8ef1952 100644 --- a/application/admin/lang/zh-cn/user4s/inslog.php +++ b/application/admin/lang/zh-cn/user4s/inslog.php @@ -4,8 +4,9 @@ return [ 'Id' => 'ID', 'User4s_id' => '会员', 'Admin_id' => '操作员', - 'Inscom' => '保险类型', - 'Insdate' => '保险日期', + 'Instype' => '保险类型', + 'Inscom' => '保险公司', + 'Insdate' => '保险日期', 'Description' => '备注', 'Star' => '满意度', 'Createtime' => '创建时间', diff --git a/application/admin/lang/zh-cn/user4s/user.php b/application/admin/lang/zh-cn/user4s/user.php index f3b11fb..9b4b343 100644 --- a/application/admin/lang/zh-cn/user4s/user.php +++ b/application/admin/lang/zh-cn/user4s/user.php @@ -16,7 +16,10 @@ return [ 'Carno' => '车牌号码', 'Model' => '车型', 'Color' => '颜色', - 'Inscom' => '保险类型', + 'Cardid' => '身份证号', + 'Frameno' => '车架号', + 'Instype' => '保险类型', + 'Inscom' => '保险公司', 'Insdate' => '保险日期', 'Tags' => '标签', 'Description' => '备注', diff --git a/application/admin/view/dashboard/index.html b/application/admin/view/dashboard/index.html index e35f643..7a0df48 100644 --- a/application/admin/view/dashboard/index.html +++ b/application/admin/view/dashboard/index.html @@ -196,19 +196,19 @@