44 changed files with 2798 additions and 481 deletions
@ -0,0 +1,42 @@
@@ -0,0 +1,42 @@
|
||||
<?php |
||||
|
||||
|
||||
namespace App\Admin\Actions\Form; |
||||
use App\Imports\LoanDataExcel; |
||||
use Dcat\Admin\Widgets\Form; |
||||
use Symfony\Component\HttpFoundation\Response; |
||||
use App\Imports\DataExcel; |
||||
use Maatwebsite\Excel\Facades\Excel; |
||||
use Maatwebsite\Excel\Validators\ValidationException; |
||||
use Throwable; |
||||
|
||||
class ImportExcelLoanForm extends Form |
||||
{ |
||||
public function handle(array $input) |
||||
{ |
||||
$file = env('APP_URL').'/upload/'.$input['file']; |
||||
|
||||
try { |
||||
Excel::import(new LoanDataExcel(time()), $input['file'],'public'); |
||||
//dcat-2.0版本写法 |
||||
return $this->response() |
||||
->success('导入成功') |
||||
->redirect('/loan_students_list'); |
||||
|
||||
} catch (ValidationException $validationException) { |
||||
return Response::withException($validationException); |
||||
} catch (Throwable $throwable) { |
||||
//dcat 2.0写法 |
||||
$this->response()->error(false); |
||||
return $this->response()->error($throwable->getMessage())->refresh(); |
||||
} |
||||
} |
||||
|
||||
public function form() |
||||
{ |
||||
$this->file('file', '上传Excel')->rules('required', ['required' => '文件不能为空']); |
||||
|
||||
} |
||||
|
||||
} |
||||
|
@ -0,0 +1,41 @@
@@ -0,0 +1,41 @@
|
||||
<?php |
||||
|
||||
|
||||
namespace App\Admin\Actions\Form; |
||||
use App\Imports\OldStudentDataExcel; |
||||
use Dcat\Admin\Widgets\Form; |
||||
use Symfony\Component\HttpFoundation\Response; |
||||
use Maatwebsite\Excel\Facades\Excel; |
||||
use Maatwebsite\Excel\Validators\ValidationException; |
||||
use Throwable; |
||||
|
||||
class ImportExcelOldStudentForm extends Form |
||||
{ |
||||
public function handle(array $input) |
||||
{ |
||||
$file = env('APP_URL').'/upload/'.$input['file']; |
||||
|
||||
try { |
||||
Excel::import(new OldStudentDataExcel(time()), $input['file'],'public'); |
||||
//dcat-2.0版本写法 |
||||
return $this->response() |
||||
->success('导入成功') |
||||
->redirect('/admission_new_students'); |
||||
|
||||
} catch (ValidationException $validationException) { |
||||
return Response::withException($validationException); |
||||
} catch (Throwable $throwable) { |
||||
//dcat 2.0写法 |
||||
$this->response()->error(false); |
||||
return $this->response()->error($throwable->getMessage())->refresh(); |
||||
} |
||||
} |
||||
|
||||
public function form() |
||||
{ |
||||
$this->file('file', '上传Excel')->rules('required', ['required' => '文件不能为空']); |
||||
|
||||
} |
||||
|
||||
} |
||||
|
@ -0,0 +1,84 @@
@@ -0,0 +1,84 @@
|
||||
<?php |
||||
|
||||
|
||||
namespace App\Admin\Actions\Grid; |
||||
|
||||
|
||||
use App\Admin\Actions\Form\Import; |
||||
use App\Admin\Actions\Form\ImportExcelLoanForm; |
||||
use App\Admin\Actions\Form\ImportExcelStudentForm; |
||||
use Dcat\Admin\Admin; |
||||
use Dcat\Admin\Grid\Tools\AbstractTool; |
||||
use Dcat\Admin\Traits\HasPermissions; |
||||
use Illuminate\Contracts\Auth\Authenticatable; |
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
|
||||
class ImportExcelLoan extends AbstractTool |
||||
{ |
||||
/** |
||||
* @return string |
||||
*/ |
||||
protected $title = 'Title'; |
||||
public function render() |
||||
{ |
||||
$id = "reset-pwd-{$this->getKey()}"; |
||||
|
||||
// 模态窗 |
||||
$this->modal($id); |
||||
|
||||
return <<<HTML |
||||
<span class="grid-expand" data-toggle="modal" data-target="#{$id}"> |
||||
<a href="javascript:void(0)"><button class="btn btn-primary ">导入贷款名单</button></a> |
||||
</span> |
||||
HTML; |
||||
} |
||||
|
||||
protected function modal($id) |
||||
{ |
||||
$form = new ImportExcelLoanForm(); |
||||
|
||||
Admin::script('Dcat.onPjaxComplete(function () { |
||||
$(".modal-backdrop").remove(); |
||||
$("body").removeClass("modal-open"); |
||||
}, true)'); |
||||
|
||||
// 通过 Admin::html 方法设置模态窗HTML |
||||
Admin::html( |
||||
<<<HTML |
||||
<div class="modal fade" id="{$id}"> |
||||
<div class="modal-dialog modal-lg" role="document"> |
||||
<div class="modal-content"> |
||||
<div class="modal-header"> |
||||
<h4 class="modal-title">导入数据</h4> |
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> |
||||
</div> |
||||
<div class="modal-body"> |
||||
{$form->render()} |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
HTML |
||||
); |
||||
} |
||||
|
||||
/** |
||||
* @param Model|Authenticatable|HasPermissions|null $user |
||||
* |
||||
* @return bool |
||||
*/ |
||||
protected function authorize($user): bool |
||||
{ |
||||
return true; |
||||
} |
||||
|
||||
/** |
||||
* @return array |
||||
*/ |
||||
protected function parameters() |
||||
{ |
||||
return []; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,83 @@
@@ -0,0 +1,83 @@
|
||||
<?php |
||||
|
||||
|
||||
namespace App\Admin\Actions\Grid; |
||||
|
||||
|
||||
use App\Admin\Actions\Form\Import; |
||||
use App\Admin\Actions\Form\ImportExcelOldStudentForm; |
||||
use Dcat\Admin\Admin; |
||||
use Dcat\Admin\Grid\Tools\AbstractTool; |
||||
use Dcat\Admin\Traits\HasPermissions; |
||||
use Illuminate\Contracts\Auth\Authenticatable; |
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
|
||||
class ImportExcelOldStudent extends AbstractTool |
||||
{ |
||||
/** |
||||
* @return string |
||||
*/ |
||||
protected $title = 'Title'; |
||||
public function render() |
||||
{ |
||||
$id = "reset-pwd-{$this->getKey()}-old"; |
||||
|
||||
// 模态窗 |
||||
$this->modal($id); |
||||
|
||||
return <<<HTML |
||||
<span class="grid-expand" data-toggle="modal" data-target="#{$id}"> |
||||
<a href="javascript:void(0)"><button class="btn btn-primary ">导入老生名单</button></a> |
||||
</span> |
||||
HTML; |
||||
} |
||||
|
||||
protected function modal($id) |
||||
{ |
||||
$form = new ImportExcelOldStudentForm(); |
||||
|
||||
Admin::script('Dcat.onPjaxComplete(function () { |
||||
$(".modal-backdrop").remove(); |
||||
$("body").removeClass("modal-open"); |
||||
}, true)'); |
||||
|
||||
// 通过 Admin::html 方法设置模态窗HTML |
||||
Admin::html( |
||||
<<<HTML |
||||
<div class="modal fade" id="{$id}"> |
||||
<div class="modal-dialog modal-lg" role="document"> |
||||
<div class="modal-content"> |
||||
<div class="modal-header"> |
||||
<h4 class="modal-title">导入数据</h4> |
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> |
||||
</div> |
||||
<div class="modal-body"> |
||||
{$form->render()} |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
HTML |
||||
); |
||||
} |
||||
|
||||
/** |
||||
* @param Model|Authenticatable|HasPermissions|null $user |
||||
* |
||||
* @return bool |
||||
*/ |
||||
protected function authorize($user): bool |
||||
{ |
||||
return true; |
||||
} |
||||
|
||||
/** |
||||
* @return array |
||||
*/ |
||||
protected function parameters() |
||||
{ |
||||
return []; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,174 @@
@@ -0,0 +1,174 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Controllers; |
||||
|
||||
use App\Admin\Actions\Grid\ImportExcelLoan; |
||||
use App\Admin\Extensions\Exporter\ImportLoanExporter; |
||||
use App\Models\Config; |
||||
use App\Models\LoanStudentsList; |
||||
use Dcat\Admin\Actions\Action; |
||||
use Dcat\Admin\Form; |
||||
use Dcat\Admin\Grid; |
||||
use Dcat\Admin\Show; |
||||
use Dcat\Admin\Http\Controllers\AdminController; |
||||
|
||||
class LoanStudentsListController extends AdminController |
||||
{ |
||||
/** |
||||
* Make a grid builder. |
||||
* |
||||
* @return Grid |
||||
*/ |
||||
protected function grid() |
||||
{ |
||||
return Grid::make(new LoanStudentsList(), function (Grid $grid) { |
||||
//开启边框模式 |
||||
$grid->withBorder(); |
||||
// 开启字段选择器功能 |
||||
$grid->showColumnSelector(); |
||||
//开启导出功能 |
||||
$grid->export(new ImportLoanExporter()); |
||||
|
||||
$grid->column('id')->sortable(); |
||||
$grid->column('sfzh'); |
||||
$grid->column('xh'); |
||||
$grid->column('xm'); |
||||
$grid->column('annual_session'); |
||||
$grid->column('fylx')->display(function(){ |
||||
if($this->fylx == LoanStudentsList::FYLX_JH) return "贷款计划"; |
||||
if($this->fylx == LoanStudentsList::FYLX_DZ) return "贷款到账"; |
||||
}); |
||||
$grid->column('total'); |
||||
$grid->column('xfje')->help("程序计算出来的学费抵扣金额"); |
||||
$grid->column('zsje')->help("程序计算出来的住宿费抵扣金额"); |
||||
$grid->column('is_five_year')->display(function(){ |
||||
if($this->is_push == LoanStudentsList::IS_FIVE_YEAR_YES) return "是"; |
||||
if($this->is_push == LoanStudentsList::IS_FIVE_YEAR_NO) return "否"; |
||||
}); |
||||
$grid->column('is_push')->display(function(){ |
||||
if($this->is_push == LoanStudentsList::IS_PUSH_YES) return "已推送"; |
||||
if($this->is_push == LoanStudentsList::IS_PUSH_NO) return "未推送"; |
||||
}); |
||||
$grid->column('create_time')->display(function (){ |
||||
if(!empty($this->create_time)){ |
||||
return date("Y-m-d H:i:s", $this->create_time); |
||||
} |
||||
})->sortable(); |
||||
|
||||
$grid->filter(function (Grid\Filter $filter) { |
||||
$filter->equal('sfzh'); |
||||
$filter->equal('xh'); |
||||
$filter->equal('xm'); |
||||
$filter->equal('annual_session'); |
||||
$filter->equal('fylx')->select(function (){ |
||||
return [ |
||||
LoanStudentsList::FYLX_JH => "贷款计划", |
||||
LoanStudentsList::FYLX_DZ => "贷款到账" |
||||
]; |
||||
}); |
||||
}); |
||||
|
||||
//禁用批量操作按钮 |
||||
$grid->disableBatchDelete(); |
||||
// 禁用详情按钮 |
||||
$grid->disableViewButton(); |
||||
|
||||
$grid->tools(function (Grid\Tools $tools) { |
||||
// excle 导入 |
||||
$tools->append(new ImportExcelLoan()); |
||||
}); |
||||
|
||||
//下载模版 |
||||
$grid->tools('<a href="/storage/excelTemplate/loanTemplate.xlsx" download="loanTemplate.xlsx" target="_blank"><button class="btn btn-success ">下载贷款名单模版</button></a>'); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a show builder. |
||||
* |
||||
* @param mixed $id |
||||
* |
||||
* @return Show |
||||
*/ |
||||
protected function detail($id) |
||||
{ |
||||
return Show::make($id, new LoanStudentsList(), function (Show $show) { |
||||
$show->field('id'); |
||||
$show->field('sfzh'); |
||||
$show->field('xh'); |
||||
$show->field('xm'); |
||||
$show->field('annual_session'); |
||||
$show->field('fylx'); |
||||
$show->field('total'); |
||||
$show->field('xfje'); |
||||
$show->field('zsje'); |
||||
$show->field('is_push'); |
||||
$show->field('create_time'); |
||||
$show->field('update_time'); |
||||
$show->field('is_five_year'); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Make a form builder. |
||||
* |
||||
* @return Form |
||||
*/ |
||||
protected function form() |
||||
{ |
||||
return Form::make(new LoanStudentsList(), function (Form $form) { |
||||
$form->display('id'); |
||||
$form->text('sfzh')->required(); |
||||
$form->text('xh')->required(); |
||||
$form->text('xm')->required(); |
||||
$form->select('fylx')->options([ |
||||
LoanStudentsList::FYLX_JH => "贷款计划", |
||||
LoanStudentsList::FYLX_DZ => "贷款到账" |
||||
])->required(); |
||||
$form->select('is_five_year')->options([ |
||||
LoanStudentsList::IS_FIVE_YEAR_YES => "是", |
||||
LoanStudentsList::IS_FIVE_YEAR_NO => "否" |
||||
])->required(); |
||||
$form->number('total')->required(); |
||||
|
||||
$form->hidden("annual_session"); |
||||
$form->hidden("create_time"); |
||||
$form->hidden("update_time"); |
||||
|
||||
// 去除删除按钮 |
||||
$form->disableDeleteButton(); |
||||
// 去除跳转详情按钮 |
||||
$form->disableViewButton(); |
||||
|
||||
$form->footer(function ($footer) { |
||||
|
||||
// 去掉`查看`checkbox |
||||
$footer->disableViewCheck(); |
||||
|
||||
// 去掉`继续编辑`checkbox |
||||
$footer->disableEditingCheck(); |
||||
|
||||
// 去掉`继续创建`checkbox |
||||
$footer->disableCreatingCheck(); |
||||
|
||||
}); |
||||
|
||||
//保存前回调 |
||||
$form->saving(function (Form $form) { |
||||
|
||||
if ($form->isCreating()) { |
||||
$config = Config::query()->where([ |
||||
"unique_identification" => "annual_session" |
||||
])->first(); |
||||
$form->annual_session = $config->data; |
||||
$form->create_time =time(); |
||||
// 删除用户提交的数据 |
||||
$form->deleteInput('update_time'); |
||||
|
||||
}else{ |
||||
$form->update_time =time(); |
||||
} |
||||
}); |
||||
}); |
||||
} |
||||
} |
@ -0,0 +1,43 @@
@@ -0,0 +1,43 @@
|
||||
<?php |
||||
|
||||
|
||||
namespace App\Admin\CustomButton; |
||||
|
||||
|
||||
use Dcat\Admin\Grid\Tools\AbstractTool; |
||||
use Dcat\Admin\Traits\HasPermissions; |
||||
use Illuminate\Contracts\Auth\Authenticatable; |
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class CompletedOffLineStepButton extends AbstractTool |
||||
{ |
||||
public function render() |
||||
{ |
||||
$id = "reset-completed-off-line-{$this->getKey()}"; |
||||
// 返回自定义按钮的HTML代码 |
||||
return <<<HTML |
||||
<span class="grid-expand" data-toggle="modal" data-target="#{$id}"> |
||||
<a href="/api/import/completedOffLineStep" target="_blank"><button class="btn btn-info ">导出线下报到明细</button></a> |
||||
</span> |
||||
HTML; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* @param Model|Authenticatable|HasPermissions|null $user |
||||
* |
||||
* @return bool |
||||
*/ |
||||
protected function authorize($user): bool |
||||
{ |
||||
return true; |
||||
} |
||||
|
||||
/** |
||||
* @return array |
||||
*/ |
||||
protected function parameters() |
||||
{ |
||||
return []; |
||||
} |
||||
} |
@ -0,0 +1,44 @@
@@ -0,0 +1,44 @@
|
||||
<?php |
||||
|
||||
|
||||
namespace App\Admin\CustomButton; |
||||
|
||||
|
||||
use App\Admin\Extensions\Exporter\ImportCompletedOnLineStepView; |
||||
use Dcat\Admin\Grid\Tools\AbstractTool; |
||||
use Dcat\Admin\Traits\HasPermissions; |
||||
use Illuminate\Contracts\Auth\Authenticatable; |
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class CompletedOnLineStepButton extends AbstractTool |
||||
{ |
||||
public function render() |
||||
{ |
||||
$id = "reset-completed-on-line-{$this->getKey()}"; |
||||
// 返回自定义按钮的HTML代码 |
||||
return <<<HTML |
||||
<span class="grid-expand" data-toggle="modal" data-target="#{$id}"> |
||||
<a href="/api/import/completedOnLineStep" target="_blank"><button class="btn btn-warning ">导出已完成线上步骤名单</button></a> |
||||
</span> |
||||
HTML; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* @param Model|Authenticatable|HasPermissions|null $user |
||||
* |
||||
* @return bool |
||||
*/ |
||||
protected function authorize($user): bool |
||||
{ |
||||
return true; |
||||
} |
||||
|
||||
/** |
||||
* @return array |
||||
*/ |
||||
protected function parameters() |
||||
{ |
||||
return []; |
||||
} |
||||
} |
@ -0,0 +1,44 @@
@@ -0,0 +1,44 @@
|
||||
<?php |
||||
|
||||
|
||||
namespace App\Admin\CustomButton; |
||||
|
||||
|
||||
use App\Admin\Extensions\Exporter\ImportCompletedOnLineStepView; |
||||
use Dcat\Admin\Grid\Tools\AbstractTool; |
||||
use Dcat\Admin\Traits\HasPermissions; |
||||
use Illuminate\Contracts\Auth\Authenticatable; |
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class UserBaseInfoButton extends AbstractTool |
||||
{ |
||||
public function render() |
||||
{ |
||||
$id = "reset-user-base-info-{$this->getKey()}"; |
||||
// 返回自定义按钮的HTML代码 |
||||
return <<<HTML |
||||
<span class="grid-expand" data-toggle="modal" data-target="#{$id}"> |
||||
<a href="/api/import/userBaseInfoExcel" target="_blank"><button class="btn btn-danger ">导出学生基本信息</button></a> |
||||
</span> |
||||
HTML; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* @param Model|Authenticatable|HasPermissions|null $user |
||||
* |
||||
* @return bool |
||||
*/ |
||||
protected function authorize($user): bool |
||||
{ |
||||
return true; |
||||
} |
||||
|
||||
/** |
||||
* @return array |
||||
*/ |
||||
protected function parameters() |
||||
{ |
||||
return []; |
||||
} |
||||
} |
@ -0,0 +1,143 @@
@@ -0,0 +1,143 @@
|
||||
<?php |
||||
|
||||
|
||||
namespace App\Admin\Extensions\Exporter; |
||||
|
||||
|
||||
use App\Models\CompletedOfflineStep; |
||||
use App\Models\Config; |
||||
use App\Models\SecondaryCollege; |
||||
use App\Models\Speciality; |
||||
use App\Models\UsersMember; |
||||
use Dcat\Admin\Grid\Exporters\AbstractExporter; |
||||
use Maatwebsite\Excel\Concerns\Exportable; |
||||
use Maatwebsite\Excel\Concerns\FromCollection; |
||||
use Maatwebsite\Excel\Concerns\WithHeadings; |
||||
use Maatwebsite\Excel\Concerns\WithMapping; |
||||
|
||||
class ImportCompletedOfflineStep extends AbstractExporter implements WithMapping, WithHeadings, FromCollection |
||||
{ |
||||
use Exportable; |
||||
protected $fileName = '线下报到明细'; |
||||
protected $titles = []; |
||||
|
||||
public function __construct() |
||||
{ |
||||
$this->fileName = $this->fileName.'_'.time().'.xlsx';//拼接下载文件名称 |
||||
$this->titles = [ |
||||
"name" => '姓名', |
||||
"mobile" => '手机', |
||||
"idcard" => '身份证', |
||||
"sex" => '性别', |
||||
"zb" => '招办签到', |
||||
"xy" => '二级学院签到', |
||||
"sg" => '宿管办签到', |
||||
"speciality_name" => '专业', |
||||
"conllege_name" => '二级学院', |
||||
"annual_session" => '年份', |
||||
]; |
||||
parent::__construct(); |
||||
} |
||||
|
||||
public function export() |
||||
{ |
||||
// TODO: Implement export() method. |
||||
$this->download($this->fileName)->prepare(request())->send(); |
||||
exit; |
||||
} |
||||
|
||||
public function collection() |
||||
{ |
||||
// TODO: Implement collection() method. |
||||
// return collect($this->buildData()); |
||||
|
||||
//取出当前年份 |
||||
$config = Config::query()->where([ |
||||
"unique_identification" => "annual_session" |
||||
])->first(); |
||||
|
||||
$list = CompletedOfflineStep::query()->where([ |
||||
"annual_session" => $config->data, |
||||
])->get()->toArray(); |
||||
if(!empty($list)){ |
||||
//专业信息 |
||||
$specialityList = Speciality::query()->get()->toArray(); |
||||
$specialityList = array_column($specialityList, null,"id"); |
||||
|
||||
//二级学院 |
||||
$secondary_college = SecondaryCollege::query()->get()->toArray(); |
||||
$secondary_college = array_column($secondary_college, null,"id"); |
||||
|
||||
$numberList = array_unique(array_column($list, "unique_number")); |
||||
|
||||
$userList = UsersMember::query()->whereIn("unique_number", $numberList)->get()->toArray(); |
||||
$userList = array_column($userList, null, "unique_number"); |
||||
|
||||
$data = []; |
||||
|
||||
foreach($list as $item){ |
||||
if(array_key_exists($item["unique_number"], $data)){ |
||||
if(!in_array($item["step_id"], $data[$item["unique_number"]])){ |
||||
array_push($data[$item["unique_number"]], $item["step_id"]); |
||||
} |
||||
}else{ |
||||
$data[$item["unique_number"]][] = $item["step_id"]; |
||||
} |
||||
} |
||||
|
||||
$addList = []; |
||||
|
||||
foreach($data as $key => $item){ |
||||
|
||||
$zb = "否"; |
||||
$xy = "否"; |
||||
$sg = "否"; |
||||
|
||||
if(in_array(2, $item)) $zb = "是"; |
||||
if(in_array(3, $item)) $xy = "是"; |
||||
if(in_array(4, $item)) $sg = "是"; |
||||
|
||||
$add = [ |
||||
"name" => $userList[$key]["name"], |
||||
"mobile" => $userList[$key]["mobile"], |
||||
"idcard" => $userList[$key]["idcard"], |
||||
"sex" => $userList[$key]["sex"] == 1 ? "男" : "女", |
||||
"zb" => $zb, |
||||
"xy" => $xy, |
||||
"sg" => $sg, |
||||
"speciality_name" => $specialityList[$userList[$key]["speciality_id"]]["speciality_name"], |
||||
"conllege_name" => $secondary_college[$specialityList[$userList[$key]["speciality_id"]]['secondary_college_id']]['name'], |
||||
"annual_session" => $config->data, |
||||
]; |
||||
|
||||
array_push($addList, $add); |
||||
} |
||||
|
||||
return collect($addList); |
||||
} |
||||
|
||||
} |
||||
|
||||
public function headings(): array |
||||
{ |
||||
// TODO: Implement headings() method. |
||||
return $this->titles(); |
||||
} |
||||
|
||||
public function map($row): array |
||||
{ |
||||
// TODO: Implement map() method. |
||||
return [ |
||||
$row["name"], |
||||
$row["mobile"], |
||||
"'".$row['idcard'].'', |
||||
$row["sex"], |
||||
$row["zb"], |
||||
$row["xy"], |
||||
$row["sg"], |
||||
$row["speciality_name"], |
||||
$row["conllege_name"], |
||||
$row["annual_session"], |
||||
]; |
||||
} |
||||
} |
@ -0,0 +1,79 @@
@@ -0,0 +1,79 @@
|
||||
<?php |
||||
|
||||
|
||||
namespace App\Admin\Extensions\Exporter; |
||||
|
||||
|
||||
use App\Models\CompletedOnLineStepView; |
||||
use App\Models\Config; |
||||
use Dcat\Admin\Grid\Exporters\AbstractExporter; |
||||
use Maatwebsite\Excel\Concerns\Exportable; |
||||
use Maatwebsite\Excel\Concerns\FromCollection; |
||||
use Maatwebsite\Excel\Concerns\WithHeadings; |
||||
use Maatwebsite\Excel\Concerns\WithMapping; |
||||
|
||||
class ImportCompletedOnLineStepView extends AbstractExporter implements WithMapping, WithHeadings, FromCollection |
||||
{ |
||||
use Exportable; |
||||
protected $fileName = '已完成线上报到名单'; |
||||
protected $titles = []; |
||||
|
||||
public function __construct() |
||||
{ |
||||
$this->fileName = $this->fileName.'_'.time().'.xlsx';//拼接下载文件名称 |
||||
$this->titles = [ |
||||
'name'=> '姓名', |
||||
'mobile'=> '手机', |
||||
'idcard'=> '身份证', |
||||
'sex'=> '性别', |
||||
'speciality_name'=> '专业', |
||||
'conllege_name'=> '二级学院', |
||||
'annual_session'=> '年份', |
||||
]; |
||||
parent::__construct(); |
||||
} |
||||
|
||||
public function export() |
||||
{ |
||||
// TODO: Implement export() method. |
||||
$this->download($this->fileName)->prepare(request())->send(); |
||||
exit; |
||||
} |
||||
|
||||
public function collection() |
||||
{ |
||||
// TODO: Implement collection() method. |
||||
// return collect($this->buildData()); |
||||
|
||||
//取出当前年份 |
||||
$config = Config::query()->where([ |
||||
"unique_identification" => "annual_session" |
||||
])->first(); |
||||
|
||||
$list = CompletedOnLineStepView::query()->where([ |
||||
"annual_session" => $config->data, |
||||
])->get()->toArray(); |
||||
|
||||
return collect($list); |
||||
} |
||||
|
||||
public function headings(): array |
||||
{ |
||||
// TODO: Implement headings() method. |
||||
return $this->titles(); |
||||
} |
||||
|
||||
public function map($row): array |
||||
{ |
||||
// TODO: Implement map() method. |
||||
return [ |
||||
$row["name"], |
||||
$row["mobile"], |
||||
"'".$row['idcard'].'', |
||||
$row["sex"], |
||||
$row["speciality_name"], |
||||
$row["conllege_name"], |
||||
$row["annual_session"], |
||||
]; |
||||
} |
||||
} |
@ -0,0 +1,87 @@
@@ -0,0 +1,87 @@
|
||||
<?php |
||||
|
||||
|
||||
namespace App\Admin\Extensions\Exporter; |
||||
|
||||
|
||||
use App\Models\LoanStudentsList; |
||||
use Dcat\Admin\Grid\Exporters\AbstractExporter; |
||||
use Maatwebsite\Excel\Concerns\Exportable; |
||||
use Maatwebsite\Excel\Concerns\FromCollection; |
||||
use Maatwebsite\Excel\Concerns\WithHeadings; |
||||
use Maatwebsite\Excel\Concerns\WithMapping; |
||||
|
||||
class ImportLoanExporter extends AbstractExporter implements WithMapping, WithHeadings, FromCollection |
||||
{ |
||||
use Exportable; |
||||
protected $fileName = '已导入贷款名单'; |
||||
protected $titles = []; |
||||
|
||||
public function __construct() |
||||
{ |
||||
$this->fileName = $this->fileName.'_'.time().'.xlsx';//拼接下载文件名称 |
||||
$this->titles = [ |
||||
'sfzh'=>'身份证', |
||||
'xh'=>'学号', |
||||
'xm'=>'姓名', |
||||
'annual_session'=>'年份', |
||||
'fylx'=>'费用类型', |
||||
'total'=>'贷款总额', |
||||
'xfje'=>'抵扣学费金额', |
||||
'zsje'=>'抵扣住宿费金额', |
||||
'is_push'=>'是否已推送', |
||||
'is_five_year'=>'是否为五年制一贯制', |
||||
"create_time" => "导入时间", |
||||
]; |
||||
parent::__construct(); |
||||
} |
||||
|
||||
public function export() |
||||
{ |
||||
// TODO: Implement export() method. |
||||
$this->download($this->fileName)->prepare(request())->send(); |
||||
exit; |
||||
} |
||||
|
||||
public function collection() |
||||
{ |
||||
// TODO: Implement collection() method. |
||||
|
||||
return collect($this->buildData()); |
||||
} |
||||
|
||||
public function headings(): array |
||||
{ |
||||
// TODO: Implement headings() method. |
||||
return $this->titles(); |
||||
} |
||||
|
||||
public function map($row): array |
||||
{ |
||||
|
||||
$fylx = "贷款计划"; |
||||
if($row['fylx'] == LoanStudentsList::FYLX_DZ) $fylx = "贷款到账"; |
||||
|
||||
$is_push = "未推送"; |
||||
if($row['is_push'] == LoanStudentsList::IS_PUSH_YES) $is_push = "已推送"; |
||||
|
||||
$is_five_year = "否"; |
||||
if($row['is_five_year'] == LoanStudentsList::IS_FIVE_YEAR_YES) $is_five_year = "是"; |
||||
|
||||
// TODO: Implement map() method. |
||||
return [ |
||||
"'".$row['sfzh'].'', |
||||
$row["xh"], |
||||
$row["xm"], |
||||
$row["annual_session"], |
||||
$fylx, |
||||
$row["total"], |
||||
$row["xfje"], |
||||
$row["zsje"], |
||||
$is_push, |
||||
$is_five_year, |
||||
date("Y-m-d H:i:s", $row['create_time']), |
||||
]; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,153 @@
@@ -0,0 +1,153 @@
|
||||
<?php |
||||
|
||||
|
||||
namespace App\Admin\Extensions\Exporter; |
||||
|
||||
|
||||
use App\Models\LoanStudentsList; |
||||
use App\Models\Order; |
||||
use App\Models\PaymentList; |
||||
use App\Models\SecondaryCollege; |
||||
use App\Models\Speciality; |
||||
use App\Models\UsersMember; |
||||
use Dcat\Admin\Grid\Exporters\AbstractExporter; |
||||
use Illuminate\Support\Facades\DB; |
||||
use Maatwebsite\Excel\Concerns\Exportable; |
||||
use Maatwebsite\Excel\Concerns\FromCollection; |
||||
use Maatwebsite\Excel\Concerns\WithHeadings; |
||||
use Maatwebsite\Excel\Concerns\WithMapping; |
||||
|
||||
class ImportOrder extends AbstractExporter implements WithMapping, WithHeadings, FromCollection |
||||
{ |
||||
use Exportable; |
||||
protected $fileName = '订单明细'; |
||||
protected $titles = []; |
||||
|
||||
public function __construct() |
||||
{ |
||||
$this->fileName = $this->fileName.'_'.time().'.xlsx';//拼接下载文件名称 |
||||
$this->titles = [ |
||||
'id'=> '订单ID', |
||||
'orders_num'=> '订单号', |
||||
'price'=> '实付金额', |
||||
'transaction_id'=> '流水单号', |
||||
'pay_time'=> '支付时间', |
||||
'status'=> '状态', |
||||
'annual_session'=> '年份', |
||||
'is_new_student_order'=> '新老生订单', |
||||
'payment_data'=> '缴费项目', |
||||
'msg'=> '订单备注', |
||||
'name'=> '姓名', |
||||
'mobile'=> '手机', |
||||
'idcard'=> '身份证', |
||||
'sex'=> '性别', |
||||
'speciality_name'=> '专业', |
||||
'conllege_name'=> '二级学院', |
||||
]; |
||||
parent::__construct(); |
||||
} |
||||
|
||||
public function export() |
||||
{ |
||||
// TODO: Implement export() method. |
||||
$this->download($this->fileName)->prepare(request())->send(); |
||||
exit; |
||||
} |
||||
|
||||
public function collection() |
||||
{ |
||||
// TODO: Implement collection() method. |
||||
|
||||
$payMentList = DB::select('SELECT DISTINCT(project_code),project_name FROM payment_list'); |
||||
$payMentListInfo = []; |
||||
|
||||
foreach($payMentList as $item){ |
||||
$payMentListInfo[$item->project_code] = $item->project_name; |
||||
} |
||||
|
||||
$orderList = $this->buildData(); |
||||
|
||||
//专业信息 |
||||
$specialityList = Speciality::query()->get()->toArray(); |
||||
$specialityList = array_column($specialityList, null,"id"); |
||||
|
||||
//二级学院 |
||||
$secondary_college = SecondaryCollege::query()->get()->toArray(); |
||||
$secondary_college = array_column($secondary_college, null,"id"); |
||||
|
||||
$numberList = array_unique(array_column($orderList, "unique_number")); |
||||
|
||||
$userList = UsersMember::query()->whereIn("unique_number", $numberList)->get()->toArray(); |
||||
$userList = array_column($userList, null, "unique_number"); |
||||
|
||||
$addList = []; |
||||
foreach($orderList as $item){ |
||||
$status = "未支付"; |
||||
if($item["status"] == Order::STATUS_PAID) $status = "已支付"; |
||||
if($item["status"] == Order::STATUS_CANCEL) $status = "已取消"; |
||||
|
||||
$is_new_student_order = "新生订单"; |
||||
if($item['is_new_student_order'] == Order::IS_NEW_STUDENT_ORDER_NO) $is_new_student_order = "老生订单"; |
||||
|
||||
$sex = "男"; |
||||
if($userList[$item["unique_number"]]['sex'] == 2) $sex = "女"; |
||||
|
||||
$payment_data = ""; |
||||
foreach(json_decode($item["payment_data"]) as $k => $v){ |
||||
$payment_data .= $payMentListInfo[$k].":".$v."|"; |
||||
} |
||||
|
||||
$arr = [ |
||||
'id'=> $item['id'], |
||||
'orders_num'=> $item['orders_num'], |
||||
'price'=> $item['price'], |
||||
'transaction_id'=> $item['transaction_id'], |
||||
'pay_time'=> date("Y-m-d H:i:s", $item['pay_time']), |
||||
'status'=> $status, |
||||
'annual_session'=> $item['annual_session'], |
||||
'is_new_student_order'=> $is_new_student_order, |
||||
'payment_data' => rtrim($payment_data, "|"), |
||||
'msg'=> $item["msg"], |
||||
'name'=> $userList[$item["unique_number"]]['name'], |
||||
'mobile'=> $userList[$item["unique_number"]]['mobile'], |
||||
'idcard'=> $userList[$item["unique_number"]]['idcard'], |
||||
'sex'=> $sex, |
||||
'speciality_name'=> $specialityList[$userList[$item["unique_number"]]["speciality_id"]]["speciality_name"], |
||||
'conllege_name'=> $secondary_college[$specialityList[$userList[$item["unique_number"]]["speciality_id"]]['secondary_college_id']]['name'], |
||||
]; |
||||
array_push($addList, $arr); |
||||
} |
||||
|
||||
return collect($addList); |
||||
} |
||||
|
||||
public function headings(): array |
||||
{ |
||||
// TODO: Implement headings() method. |
||||
return $this->titles(); |
||||
} |
||||
|
||||
public function map($row): array |
||||
{ |
||||
// TODO: Implement map() method. |
||||
return [ |
||||
$row["id"], |
||||
$row["orders_num"], |
||||
$row["price"], |
||||
$row["transaction_id"], |
||||
$row["pay_time"], |
||||
$row["status"], |
||||
$row["annual_session"], |
||||
$row["is_new_student_order"], |
||||
$row["payment_data"], |
||||
$row["msg"], |
||||
$row["name"], |
||||
$row["mobile"], |
||||
"'".$row['idcard'].'', |
||||
$row["sex"], |
||||
$row["speciality_name"], |
||||
$row["conllege_name"], |
||||
]; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,156 @@
@@ -0,0 +1,156 @@
|
||||
<?php |
||||
|
||||
|
||||
namespace App\Admin\Extensions\Exporter; |
||||
|
||||
|
||||
use App\Models\AdmissionNewStudents; |
||||
use App\Models\BasicFamilyInformation; |
||||
use App\Models\Config; |
||||
use App\Models\Order; |
||||
use App\Models\SecondaryCollege; |
||||
use App\Models\Speciality; |
||||
use App\Models\UserBasicInfo; |
||||
use App\Models\UsersMember; |
||||
use Dcat\Admin\Grid\Exporters\AbstractExporter; |
||||
use Illuminate\Support\Facades\DB; |
||||
use Maatwebsite\Excel\Concerns\Exportable; |
||||
use Maatwebsite\Excel\Concerns\FromCollection; |
||||
use Maatwebsite\Excel\Concerns\WithHeadings; |
||||
use Maatwebsite\Excel\Concerns\WithMapping; |
||||
|
||||
class ImportUserBaseInfo extends AbstractExporter implements WithMapping, WithHeadings, FromCollection |
||||
{ |
||||
use Exportable; |
||||
protected $fileName = '用户基本信息'; |
||||
protected $titles = []; |
||||
|
||||
public function __construct() |
||||
{ |
||||
$this->fileName = $this->fileName.'_'.time().'.xlsx';//拼接下载文件名称 |
||||
$this->titles = [ |
||||
"family_name" => '联系人', |
||||
"family_mobile" => '联系号码', |
||||
"relationship" => '关系', |
||||
"address" => '家庭住址', |
||||
"postal_code" => '邮政编码', |
||||
"native" => '籍贯', |
||||
"email" => '邮箱', |
||||
"name" => '学生姓名', |
||||
"mobile" => '学生号码', |
||||
"idcard" => '学生身份证', |
||||
"sex" => '学生性别', |
||||
"speciality_name" => '专业', |
||||
"conllege_name" => '二级学院', |
||||
"annual_session" => '年份', |
||||
]; |
||||
parent::__construct(); |
||||
} |
||||
|
||||
public function export() |
||||
{ |
||||
// TODO: Implement export() method. |
||||
$this->download($this->fileName)->prepare(request())->send(); |
||||
exit; |
||||
} |
||||
|
||||
public function collection() |
||||
{ |
||||
// TODO: Implement collection() method. |
||||
//取出当前年份 |
||||
$config = Config::query()->where([ |
||||
"unique_identification" => "annual_session" |
||||
])->first(); |
||||
|
||||
//专业信息 |
||||
$specialityList = Speciality::query()->get()->toArray(); |
||||
$specialityList = array_column($specialityList, null,"id"); |
||||
|
||||
//二级学院 |
||||
$secondary_college = SecondaryCollege::query()->get()->toArray(); |
||||
$secondary_college = array_column($secondary_college, null,"id"); |
||||
|
||||
$studentsList = AdmissionNewStudents::query()->where([ |
||||
"annual_session" => $config->data, |
||||
"is_new_student" => AdmissionNewStudents::IS_NEW_STUDENT_YES |
||||
])->get()->toArray(); |
||||
|
||||
$userList = UsersMember::query()->whereIn("idcard", array_column($studentsList, "idCard"))->get()->toArray(); |
||||
$userList = array_column($userList, null, "unique_number"); |
||||
|
||||
$basicFamilyInfoList = BasicFamilyInformation::query()->whereIn("unique_number", array_column($userList, "unique_number"))->get()->toArray(); |
||||
if(empty($basicFamilyInfoList)){ |
||||
return collect([]); |
||||
} |
||||
|
||||
$userBasicInfoList = UserBasicInfo::query()->whereIn("unique_number", array_column($userList, "unique_number"))->get()->toArray(); |
||||
if(empty($userBasicInfoList)){ |
||||
return collect([]); |
||||
} |
||||
$userBasicInfoList = array_column($userBasicInfoList, null, "unique_number"); |
||||
|
||||
$addList = []; |
||||
foreach($basicFamilyInfoList as $item){ |
||||
$address = ""; |
||||
$postal_code = ""; |
||||
$native = ""; |
||||
$email = ""; |
||||
|
||||
if(array_key_exists($item["unique_number"], $userBasicInfoList)){ |
||||
$address = $userBasicInfoList[$item["unique_number"]]['province_city_area'].'--'.$userBasicInfoList[$item["unique_number"]]['address']; |
||||
$postal_code = $userBasicInfoList[$item["unique_number"]]['postal_code']; |
||||
$native = $userBasicInfoList[$item["unique_number"]]['native']; |
||||
$email = $userBasicInfoList[$item["unique_number"]]['email']; |
||||
} |
||||
|
||||
$arr = [ |
||||
"family_name" => $item["name"], |
||||
"family_mobile" => $item["mobile"], |
||||
"relationship" => $item["relationship"], |
||||
"address" => $address, |
||||
"postal_code" => $postal_code, |
||||
"native" => $native, |
||||
"email" => $email, |
||||
"name" => $userList[$item["unique_number"]]["name"], |
||||
"mobile" => $userList[$item["unique_number"]]["mobile"], |
||||
"idcard" => $userList[$item["unique_number"]]["idcard"], |
||||
"sex" => $userList[$item["unique_number"]]["sex"] == 1 ? "男" : "女", |
||||
"speciality_name" => $specialityList[$userList[$item["unique_number"]]["speciality_id"]]["speciality_name"], |
||||
"conllege_name" => $secondary_college[$specialityList[$userList[$item["unique_number"]]["speciality_id"]]['secondary_college_id']]['name'], |
||||
"annual_session" => $config->data, |
||||
]; |
||||
|
||||
array_push($addList, $arr); |
||||
} |
||||
|
||||
return collect($addList); |
||||
} |
||||
|
||||
public function headings(): array |
||||
{ |
||||
// TODO: Implement headings() method. |
||||
return $this->titles(); |
||||
} |
||||
|
||||
public function map($row): array |
||||
{ |
||||
// TODO: Implement map() method. |
||||
return [ |
||||
$row["family_name"], |
||||
$row["family_mobile"], |
||||
$row["relationship"], |
||||
$row["address"], |
||||
$row["postal_code"], |
||||
$row["native"], |
||||
$row["email"], |
||||
$row["name"], |
||||
$row["mobile"], |
||||
"'".$row['idcard'].'', |
||||
$row["sex"], |
||||
$row["speciality_name"], |
||||
$row["conllege_name"], |
||||
$row["annual_session"], |
||||
]; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,142 @@
@@ -0,0 +1,142 @@
|
||||
<?php |
||||
|
||||
namespace App\Admin\Metrics\Examples; |
||||
|
||||
use App\Models\CompletedStep; |
||||
use App\Models\Config; |
||||
use App\Models\Step; |
||||
use Dcat\Admin\Widgets\Metrics\Card; |
||||
use Illuminate\Contracts\Support\Renderable; |
||||
use Illuminate\Http\Request; |
||||
|
||||
class AdmissionOnLineUser extends Card |
||||
{ |
||||
/** |
||||
* 卡片底部内容. |
||||
* |
||||
* @var string|Renderable|\Closure |
||||
*/ |
||||
protected $footer; |
||||
|
||||
/** |
||||
* 初始化卡片. |
||||
*/ |
||||
protected function init() |
||||
{ |
||||
parent::init(); |
||||
|
||||
$this->title('线上报到人数'); |
||||
//取出线上步骤 |
||||
$stepList = Step::query()->pluck("title", "id"); |
||||
$downList = []; |
||||
foreach($stepList as $key => $item){ |
||||
$downList[$key] = $item; |
||||
} |
||||
|
||||
$this->dropdown($downList); |
||||
} |
||||
|
||||
/** |
||||
* 处理请求. |
||||
* |
||||
* @param Request $request |
||||
* |
||||
* @return void |
||||
*/ |
||||
public function handle(Request $request) |
||||
{ |
||||
$stepId = $request->get('option'); |
||||
|
||||
//取出当前年份 |
||||
$config = Config::query()->where([ |
||||
"unique_identification" => "annual_session" |
||||
])->first(); |
||||
|
||||
$where = [ |
||||
"annual_session" => $config->data, |
||||
]; |
||||
if(!empty($stepId)){ |
||||
$where["step_id"] = $stepId; |
||||
} |
||||
|
||||
//缴费总人数 |
||||
$allCount = CompletedStep::query() |
||||
->where($where)->distinct("unique_number")->count(); |
||||
|
||||
$this->content($allCount); |
||||
|
||||
if($allCount > 0){ |
||||
$this->up($allCount); |
||||
}else{ |
||||
$this->down($allCount); |
||||
} |
||||
|
||||
} |
||||
|
||||
/** |
||||
* @param int $percent |
||||
* |
||||
* @return $this |
||||
*/ |
||||
public function up($percent) |
||||
{ |
||||
return $this->footer( |
||||
"<i class=\"feather icon-trending-up text-success\"></i> {$percent}人 为当前年份线上报到人数" |
||||
); |
||||
} |
||||
|
||||
/** |
||||
* @param int $percent |
||||
* |
||||
* @return $this |
||||
*/ |
||||
public function down($percent) |
||||
{ |
||||
return $this->footer( |
||||
"<i class=\"feather icon-trending-down text-danger\"></i> {$percent}人 为当前年份线上报到人数" |
||||
); |
||||
} |
||||
|
||||
/** |
||||
* 设置卡片底部内容. |
||||
* |
||||
* @param string|Renderable|\Closure $footer |
||||
* |
||||
* @return $this |
||||
*/ |
||||
public function footer($footer) |
||||
{ |
||||
$this->footer = $footer; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* 渲染卡片内容. |
||||
* |
||||
* @return string |
||||
*/ |
||||
public function renderContent() |
||||
{ |
||||
$content = parent::renderContent(); |
||||
|
||||
return <<<HTML |
||||
<div class="d-flex justify-content-between align-items-center mt-1" style="margin-bottom: 2px"> |
||||
<h2 class="ml-1 font-lg-1">{$content}</h2> |
||||
</div> |
||||
<div class="ml-1 mt-1 font-weight-bold text-80"> |
||||
{$this->renderFooter()} |
||||
</div> |
||||
HTML; |
||||
} |
||||
|
||||
/** |
||||
* 渲染卡片底部内容. |
||||
* |
||||
* @return string |
||||
*/ |
||||
public function renderFooter() |
||||
{ |
||||
return $this->toString($this->footer); |
||||
} |
||||
} |
@ -0,0 +1,64 @@
@@ -0,0 +1,64 @@
|
||||
<?php |
||||
|
||||
|
||||
namespace App\Admin\Renderable; |
||||
|
||||
use App\Models\AdmissionNewStudents; |
||||
use Dcat\Admin\Grid; |
||||
use Dcat\Admin\Grid\LazyRenderable; |
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class StudentInfoTable extends LazyRenderable |
||||
{ |
||||
public function grid(): Grid |
||||
{ |
||||
|
||||
return Grid::make(new AdmissionNewStudents(), function (Grid $grid) { |
||||
|
||||
# 接收参数 |
||||
$id = $this->payload['id'] ?? null; |
||||
if (!empty($id)) { |
||||
$grid->model()->where('id', $id); |
||||
} |
||||
|
||||
$grid->column('nj', "年级"); |
||||
$grid->column('xydm', "学院代码"); |
||||
$grid->column('zydm',"专业代码"); |
||||
$grid->column('bjdm', "班级代码"); |
||||
$grid->column('xz', "学制代码"); |
||||
$grid->column('xslbdm', "学生类别代码"); |
||||
$grid->column('xjztdm', "学籍状态代码"); |
||||
$grid->column('sfzx', "是否在校代码")->display(function(){ |
||||
if($this->sfzx == 0) return "否"; |
||||
if($this->sfzx == 1) return "是"; |
||||
}); |
||||
$grid->column('is_five_year', "是否为五年制一贯制")->display(function(){ |
||||
if($this->is_five_year == 1) return "否"; |
||||
if($this->is_five_year == 2) return "是"; |
||||
}); |
||||
$grid->column('is_equivalent', "考生类型")->display(function(){ |
||||
if($this->is_equivalent == 1) return "统招生"; |
||||
if($this->is_equivalent == 2) return "单招生"; |
||||
}); |
||||
$grid->column('is_four_type', "考生分类")->display(function(){ |
||||
if($this->is_four_type == 1) return "高职本科3+2"; |
||||
if($this->is_four_type == 2) return "四类人员"; |
||||
if($this->is_four_type == 3) return "普通考生"; |
||||
if($this->is_four_type == 4) return "中职3+2"; |
||||
}); |
||||
$grid->column('province', "招生省份"); |
||||
$grid->column('old_student_bed_info', "床位信息(老生)"); |
||||
|
||||
//禁用批量操作按钮 |
||||
$grid->disableBatchDelete(); |
||||
//禁用创建按钮 |
||||
$grid->disableCreateButton(); |
||||
//禁用操作按钮 |
||||
$grid->disableActions(); |
||||
//禁用刷新按钮 |
||||
$grid->disableRefreshButton(); |
||||
|
||||
$grid->paginate(10); |
||||
}); |
||||
} |
||||
} |
@ -0,0 +1,25 @@
@@ -0,0 +1,25 @@
|
||||
<?php |
||||
|
||||
|
||||
namespace App\Imports; |
||||
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets; |
||||
|
||||
class LoanDataExcel implements WithMultipleSheets |
||||
{ |
||||
private $round; |
||||
|
||||
public function __construct(int $round) |
||||
{ |
||||
$this->round = $round; |
||||
} |
||||
|
||||
public function sheets(): array |
||||
{ |
||||
return [ |
||||
new LoanFirstSheetImport($this->round), |
||||
]; |
||||
|
||||
} |
||||
} |
@ -0,0 +1,120 @@
@@ -0,0 +1,120 @@
|
||||
<?php |
||||
|
||||
namespace App\Imports; |
||||
use App\Models\Config; |
||||
use App\Models\LoanStudentsList; |
||||
use Illuminate\Support\Collection; |
||||
use Illuminate\Database\Eloquent\Model; |
||||
use Maatwebsite\Excel\Concerns\ToModel; |
||||
use Maatwebsite\Excel\Concerns\ToCollection; |
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow; |
||||
use Maatwebsite\Excel\Concerns\WithBatchInserts; |
||||
use Maatwebsite\Excel\Concerns\WithChunkReading; |
||||
use Maatwebsite\Excel\Imports\HeadingRowFormatter; |
||||
use Illuminate\Support\Facades\DB; |
||||
|
||||
HeadingRowFormatter:: |
||||
default('none'); |
||||
|
||||
class LoanFirstSheetImport implements ToCollection, WithBatchInserts, WithChunkReading, WithHeadingRow, ToModel |
||||
{ |
||||
private $round; |
||||
|
||||
public function __construct(int $round) |
||||
{ |
||||
$this->round = $round; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* @param array $row |
||||
* |
||||
* @return Model|Model[]|null |
||||
*/ |
||||
public function model(array $row) |
||||
{ |
||||
|
||||
// // 数据库对应的字段 |
||||
return null; |
||||
} |
||||
|
||||
public function collection(Collection $rows) |
||||
{ |
||||
//导入的表格所有数据都在此处显示 |
||||
$list = $rows->toArray(); |
||||
if(empty($list)){ |
||||
throw new \Exception("请勿上传空文件"); |
||||
} |
||||
|
||||
//取出当前年份 |
||||
$config = Config::query()->where([ |
||||
"unique_identification" => "annual_session" |
||||
])->first(); |
||||
if(empty($config)){ |
||||
throw new \Exception("相关配置信息不能为空"); |
||||
} |
||||
|
||||
|
||||
//入库 |
||||
$insertData = []; |
||||
|
||||
foreach($list as $key => $item){ |
||||
|
||||
$arr = [ |
||||
"sfzh" => trim($item["身份证"]), |
||||
"xh" => trim($item["学号"]), |
||||
"xm" => trim($item["姓名"]), |
||||
"fylx" => trim($item["费用类型"]), |
||||
"total" => trim($item["贷款总金额"]), |
||||
"is_five_year" => trim($item["五年一贯制"]), |
||||
"create_time" => time(), |
||||
"annual_session" => $config->data |
||||
]; |
||||
array_push($insertData, $arr); |
||||
} |
||||
|
||||
DB::beginTransaction(); |
||||
try { |
||||
|
||||
$chunk_list = array_chunk($insertData, 1000); |
||||
|
||||
foreach ($chunk_list as $new_list) { |
||||
$add = LoanStudentsList::query()->insert($new_list); |
||||
if($add != count($new_list)){ |
||||
throw new \Exception("导入数据失败,请重试"); |
||||
} |
||||
} |
||||
|
||||
|
||||
DB::commit(); |
||||
}catch (\PDOException $e){ |
||||
DB::rollBack(); |
||||
if ($e->getCode() === '23000') { |
||||
// 唯一性约束错误处理逻辑 |
||||
$errorMessage = "导入表格中存在已入库学生贷款信息,请勿重复导入"; |
||||
// 可以根据需要进行相关处理 |
||||
throw new \Exception($errorMessage); |
||||
} else { |
||||
// 其他类型的错误处理逻辑 |
||||
throw new \Exception("导入数据失败,请重试"); |
||||
} |
||||
}catch (\Exception $e){ |
||||
DB::rollBack(); |
||||
throw new \Exception("导入数据失败,请重试"); |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
//批量导入1000条 |
||||
public function batchSize(): int |
||||
{ |
||||
return 1000; |
||||
} |
||||
|
||||
//以1000条数据基准切割数据 |
||||
public function chunkSize(): int |
||||
{ |
||||
return 1000; |
||||
} |
||||
} |
@ -0,0 +1,25 @@
@@ -0,0 +1,25 @@
|
||||
<?php |
||||
|
||||
|
||||
namespace App\Imports; |
||||
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets; |
||||
|
||||
class OldStudentDataExcel implements WithMultipleSheets |
||||
{ |
||||
private $round; |
||||
|
||||
public function __construct(int $round) |
||||
{ |
||||
$this->round = $round; |
||||
} |
||||
|
||||
public function sheets(): array |
||||
{ |
||||
return [ |
||||
new OldStudentFirstSheetImport($this->round), |
||||
]; |
||||
|
||||
} |
||||
} |
@ -0,0 +1,165 @@
@@ -0,0 +1,165 @@
|
||||
<?php |
||||
|
||||
namespace App\Imports; |
||||
use App\Models\AdmissionNewStudents; |
||||
use App\Models\Config; |
||||
use App\Models\SecondaryCollege; |
||||
use App\Models\Speciality; |
||||
use Illuminate\Support\Collection; |
||||
use Illuminate\Database\Eloquent\Model; |
||||
use Maatwebsite\Excel\Concerns\ToModel; |
||||
use Maatwebsite\Excel\Concerns\ToCollection; |
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow; |
||||
use Maatwebsite\Excel\Concerns\WithBatchInserts; |
||||
use Maatwebsite\Excel\Concerns\WithChunkReading; |
||||
use Maatwebsite\Excel\Imports\HeadingRowFormatter; |
||||
use Illuminate\Support\Facades\DB; |
||||
use Throwable; |
||||
HeadingRowFormatter:: |
||||
default('none'); |
||||
|
||||
class OldStudentFirstSheetImport implements ToCollection, WithBatchInserts, WithChunkReading, WithHeadingRow, ToModel |
||||
{ |
||||
private $round; |
||||
|
||||
public function __construct(int $round) |
||||
{ |
||||
$this->round = $round; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* @param array $row |
||||
* |
||||
* @return Model|Model[]|null |
||||
*/ |
||||
public function model(array $row) |
||||
{ |
||||
|
||||
//写导入的逻辑关系 |
||||
// $user = Orderuser::where('phone', '=', $row['电话'])->where('name', '=',$row['姓名'])->first(); |
||||
|
||||
// dd($row); |
||||
// // 数据库对应的字段 |
||||
return null; |
||||
} |
||||
|
||||
public function collection(Collection $rows) |
||||
{ |
||||
//导入的表格所有数据都在此处显示 |
||||
$list = $rows->toArray(); |
||||
if(empty($list)){ |
||||
throw new \Exception("请勿上传空文件"); |
||||
} |
||||
|
||||
//入库 |
||||
$insertData = []; |
||||
|
||||
foreach($list as $key => $item){ |
||||
$arr = [ |
||||
"mobile" => trim($item["手机号"]), |
||||
"name" => trim($item["姓名"]), |
||||
"idCard" => trim($item["身份证"]), |
||||
"admission_college" => trim($item["录取学院"]), |
||||
"admitted_major" => trim($item["录取专业"]), |
||||
"admission_code" => trim($item["学号"]), |
||||
"is_five_year" => trim($item["是否五年一贯制"]), |
||||
"create_time" => time(), |
||||
"annual_session" => trim($item["学年"]), |
||||
"is_new_student" => AdmissionNewStudents::IS_NEW_STUDENT_NO, |
||||
"old_student_bed_info" => trim($item["床位信息"]), |
||||
"is_push" => AdmissionNewStudents::IS_PUSH_YES, //老生标记已推送 |
||||
"is_register" => AdmissionNewStudents::REGISTER_YES, //老生标记已注册 |
||||
]; |
||||
|
||||
//检测必有字段是否为空 |
||||
if(empty($arr["annual_session"]) || empty($arr["old_student_bed_info"])){ |
||||
throw new \Exception("学年及床位信息字段不能为空"); |
||||
} |
||||
|
||||
//检测性别 |
||||
if(trim($item["性别"]) == "男"){ |
||||
$arr["sex"] = 1; |
||||
}else if(trim($item["性别"]) == "女"){ |
||||
$arr["sex"] = 2; |
||||
} |
||||
|
||||
//检测专业 |
||||
//取出所有二级学院 |
||||
$secondaryCollegeList = SecondaryCollege::query()->where([ |
||||
"status" => SecondaryCollege::STATUS_YES |
||||
])->get()->toArray(); |
||||
if(empty($secondaryCollegeList)){ |
||||
throw new \Exception("识别失败,二级学院信息为空"); |
||||
} |
||||
|
||||
//以学院名作为键 |
||||
$secondaryCollegeList = array_column($secondaryCollegeList, null, "name"); |
||||
|
||||
//初识化专业id |
||||
$speciality_id = 0; |
||||
|
||||
//取出指定学院下面的专业 |
||||
$specialityInfo = Speciality::query()->where([ |
||||
"secondary_college_id" => $secondaryCollegeList[trim($item["录取学院"])]["id"], |
||||
"speciality_name" => trim($item["录取专业"]), |
||||
"status" => Speciality::STATUS_YES |
||||
])->first(); |
||||
if(!empty($specialityInfo)){ |
||||
$speciality_id = $specialityInfo->id; |
||||
} |
||||
|
||||
//专业ID为空时提示 |
||||
if(empty($speciality_id)){ |
||||
throw new \Exception("识别失败,请检查二级学院或专业名称是否和后台录入的一致"); |
||||
} |
||||
|
||||
$arr["speciality_id"] = $speciality_id; |
||||
|
||||
array_push($insertData, $arr); |
||||
} |
||||
|
||||
DB::beginTransaction(); |
||||
try { |
||||
|
||||
$chunk_list = array_chunk($insertData, 1000); |
||||
|
||||
foreach ($chunk_list as $new_list) { |
||||
$add = AdmissionNewStudents::query()->insert($new_list); |
||||
if($add != count($new_list)){ |
||||
throw new \Exception("导入数据失败,请重试"); |
||||
} |
||||
} |
||||
|
||||
DB::commit(); |
||||
}catch (\PDOException $e){ |
||||
DB::rollBack(); |
||||
if ($e->getCode() === '23000') { |
||||
// 唯一性约束错误处理逻辑 |
||||
$errorMessage = "导入表格中存在已入库学生信息,请勿重复导入"; |
||||
// 可以根据需要进行相关处理 |
||||
throw new \Exception($errorMessage); |
||||
} else { |
||||
// 其他类型的错误处理逻辑 |
||||
throw new \Exception("导入数据失败,请重试"); |
||||
} |
||||
}catch (\Exception $e){ |
||||
DB::rollBack(); |
||||
throw new \Exception("导入数据失败,请重试"); |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
//批量导入1000条 |
||||
public function batchSize(): int |
||||
{ |
||||
return 1000; |
||||
} |
||||
|
||||
//以1000条数据基准切割数据 |
||||
public function chunkSize(): int |
||||
{ |
||||
return 1000; |
||||
} |
||||
} |
@ -0,0 +1,15 @@
@@ -0,0 +1,15 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Dcat\Admin\Traits\HasDateTimeFormatter; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class CompletedOnLineStepView extends Model |
||||
{ |
||||
use HasDateTimeFormatter; |
||||
protected $table = 'completed_on_line_step_view'; |
||||
public $timestamps = false; |
||||
|
||||
} |
@ -0,0 +1,23 @@
@@ -0,0 +1,23 @@
|
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Dcat\Admin\Traits\HasDateTimeFormatter; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class LoanStudentsList extends Model |
||||
{ |
||||
use HasDateTimeFormatter; |
||||
protected $table = 'loan_students_list'; |
||||
public $timestamps = false; |
||||
|
||||
const IS_PUSH_YES = 2; //已推送 |
||||
const IS_PUSH_NO = 1; //未推送 |
||||
|
||||
const IS_FIVE_YEAR_YES = 2; //五年制 |
||||
const IS_FIVE_YEAR_NO = 1; //非五年制 |
||||
|
||||
const FYLX_JH = 0; //费用类型:0贷款计划 1贷款到账 |
||||
const FYLX_DZ = 1; |
||||
} |
@ -0,0 +1,33 @@
@@ -0,0 +1,33 @@
|
||||
<?php |
||||
|
||||
/** |
||||
* 弄成单例模式 |
||||
*/ |
||||
namespace App\Services; |
||||
|
||||
|
||||
class BaseServices |
||||
{ |
||||
protected static $instance; |
||||
|
||||
/** |
||||
* @return static |
||||
*/ |
||||
public static function getInstance() |
||||
{ |
||||
if(static::$instance instanceof static){ |
||||
return static::$instance; |
||||
} |
||||
|
||||
static::$instance = new static(); |
||||
return static::$instance; |
||||
} |
||||
|
||||
private function __construct() |
||||
{ |
||||
} |
||||
|
||||
private function __clone() |
||||
{ |
||||
} |
||||
} |
@ -0,0 +1,32 @@
@@ -0,0 +1,32 @@
|
||||
<?php |
||||
|
||||
|
||||
namespace App\Services; |
||||
|
||||
|
||||
use App\Models\AdmissionNewStudents; |
||||
|
||||
class PublicServices extends BaseServices |
||||
{ |
||||
/** |
||||
* 返回指定身份证学生新老生身份 |
||||
* @param $idcard |
||||
* @return \Illuminate\Database\Eloquent\HigherOrderBuilderProxy|mixed |
||||
*/ |
||||
public function checkIsNewOldStudent($idcard) |
||||
{ |
||||
$count = AdmissionNewStudents::query()->where([ |
||||
"idCard" => $idcard |
||||
])->count(); |
||||
//出现两条数据以上时必为老生 |
||||
if($count > 1){ |
||||
return AdmissionNewStudents::IS_NEW_STUDENT_NO; |
||||
} |
||||
|
||||
//为一条数据时检测是否为老生 |
||||
$studentInfo = AdmissionNewStudents::query()->where([ |
||||
"idCard" => $idcard |
||||
])->first(); |
||||
return $studentInfo->is_new_student; |
||||
} |
||||
} |
@ -0,0 +1,23 @@
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
return [ |
||||
'labels' => [ |
||||
'LoanStudentsList' => '贷款名单', |
||||
'loan-students-list' => '贷款名单', |
||||
], |
||||
'fields' => [ |
||||
'sfzh' => '身份证号', |
||||
'xh' => '学号', |
||||
'xm' => '姓名', |
||||
'annual_session' => '年份', |
||||
'fylx' => '费用类型', |
||||
'total' => '贷款总额', |
||||
'xfje' => '抵扣学费金额', |
||||
'zsje' => '抵扣住宿费金额', |
||||
'is_push' => '是否已推送', |
||||
'create_time' => '创建时间', |
||||
'update_time' => '修改时间', |
||||
'is_five_year' => '是否为五年制一贯制', |
||||
], |
||||
'options' => [ |
||||
], |
||||
]; |
Loading…
Reference in new issue