RecuperateApplyController.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. <?php
  2. namespace App\Admin\Controllers\Content;
  3. use App\Http\Controllers\Controller;
  4. use App\Models\Recuperate;
  5. use App\Models\RecuperateApply;
  6. use App\Models\RecuperateLog;
  7. use App\Models\RecuperateTime;
  8. use Encore\Admin\Controllers\HasResourceActions;
  9. use Encore\Admin\Grid;
  10. use Encore\Admin\Layout\Content;
  11. use Illuminate\Http\Request;
  12. use Encore\Admin\Facades\Admin;
  13. class RecuperateApplyController extends Controller
  14. {
  15. use HasResourceActions;
  16. /**
  17. * Index interface.
  18. *
  19. * @param Content $content
  20. * @return Content
  21. */
  22. public function index(Content $content)
  23. {
  24. return $content
  25. ->header('报名列表')
  26. ->description(' ')
  27. ->body(view('admin.content.recuperate_apply')->with(['grid' => $this->grid()]));
  28. }
  29. /**
  30. * Make a grid builder.
  31. *
  32. * @return Grid
  33. */
  34. protected function grid()
  35. {
  36. $grid = new Grid(new RecuperateApply());
  37. $grid->model()->orderBy('created_at', 'DESC');
  38. $grid->recuperate_id('套餐id');
  39. $grid->column('套餐标题')->display(function () {
  40. //套餐被删除
  41. if (empty($this->recuperate)) {
  42. return '<span style="color:#A0A0A0;">已被删除</span>';
  43. }
  44. $style = "color:" . $this->recuperate->tit_color . ';';
  45. if ($this->recuperate->tit_b == '1') {
  46. $style .= 'font-weight:bold;';
  47. }
  48. return '<span style="' . $style . '">' . $this->recuperate->title . '</span>';
  49. })->width(200);
  50. $grid->small_img('缩略图')->display(function () {
  51. //套餐被删除
  52. if (empty($this->recuperate)) {
  53. return '';
  54. }
  55. if ($this->recuperate->small_img) {
  56. return '<span class="vtip" title="<img src=\'' . upload_asset($this->recuperate->small_img) . '\' height=120>">
  57. <img class="avatar small" src="' . upload_asset($this->recuperate->small_img) . '" align="absmiddle" style="width: 22px;height: 22px;">
  58. </span>';
  59. } else {
  60. return '';
  61. }
  62. });
  63. $grid->price('套餐金额');
  64. $grid->user_name('姓名');
  65. $grid->user_idcard('身份证');
  66. $grid->mobile('联系电话');
  67. $grid->wechat('微信号');
  68. $grid->company_name('工作单位');
  69. $grid->column('人才层次')->display(function () {
  70. $level_arr = [
  71. '',
  72. '第一层次',
  73. '第二层次',
  74. '第三层次',
  75. '第四层次',
  76. '第五层次',
  77. '第六层次',
  78. '第七层次',
  79. ];
  80. return $level_arr[$this->level];
  81. });
  82. /*$grid->condition("适用对象类型");
  83. $grid->column('个税社保')->display(function () {
  84. $level_arr = [
  85. '',
  86. '是',
  87. '否',
  88. ];
  89. return $level_arr[$this->tax];
  90. });
  91. $grid->column('年薪')->display(function () {
  92. $level_arr = [
  93. '',
  94. '是',
  95. '否',
  96. ];
  97. return $level_arr[$this->salary];
  98. });*/
  99. $grid->validate_time('人才有效期');
  100. $grid->created_at('报名时间');
  101. $grid->column('审核状态')->display(function () {
  102. $status_arr = [
  103. '待审核',
  104. '审核通过',
  105. '审核不通过',
  106. '取消活动',
  107. ];
  108. $reason = $this->reason ? '<a style="margin-left: 5px;" data-reason="' . $this->reason . '" class="audit_log"><i class="fa fa-eye"></i></a>' : '';
  109. return '<span style="color:#FF6600">' . $status_arr[$this->status] . $reason . '</span>';
  110. });
  111. //审核功能
  112. $grid->actions(function ($actions) {
  113. if ($actions->row['status'] == 0) {
  114. $actions->append("<button class='btn btn-primary btn-xs applyaudit' data-code=" . $actions->row['id'] . ">审核</button>");
  115. }
  116. /*取消活动*/
  117. if ($actions->row['status'] != 2 && $actions->row['status'] != 3) {
  118. $actions->append("<button class='btn btn-primary btn-xs applyaudits' data-code=" . $actions->row['id'] . ">取消</button>");
  119. }
  120. });
  121. $grid->filter(function ($filter) {
  122. $filter->disableIdFilter();
  123. $filter->equal('recuperate_id', '套餐id');
  124. /*$filter->where(function($query){
  125. $recuperate = Recuperate::where('title','like',"%{$this->input}%")->get();
  126. $ids = $recuperate->pluck('id')->all();
  127. if (empty($ids)) {
  128. $query->where('id','=',0);
  129. } else {
  130. $query->whereIn('recuperate_id',$ids);
  131. }
  132. }, '');*/
  133. $date3 = date('Y-m-d', strtotime("-3 day"));
  134. $date7 = date('Y-m-d', strtotime("-7 day"));
  135. $date30 = date("Y-m-d", strtotime("-1 month"));
  136. $date180 = date("Y-m-d", strtotime("-6 month"));
  137. $date360 = date("Y-m-d", strtotime("-1 year"));
  138. $date_option = [
  139. '' => '不限',
  140. $date3 => '三天内',
  141. $date7 => '一周内',
  142. $date30 => '一月内',
  143. $date180 => '半年内',
  144. $date360 => '一年内',
  145. ];
  146. $filter->where(function ($query) {
  147. $query->where('created_at', '>=', "{$this->input}");
  148. }, '添加时间', 'created_at')->radio($date_option);
  149. $status_option = [
  150. '' => '不限',
  151. 0 => '待审核',
  152. 1 => '审核通过',
  153. 2 => '审核不通过',
  154. ];
  155. $filter->where(function ($query) {
  156. if (isset($this->input)) {
  157. $query->where('status', '=', "{$this->input}");
  158. }
  159. }, '审核状态', 'status')->radio($status_option);
  160. });
  161. return $grid;
  162. }
  163. public function audit(Request $request)
  164. {
  165. $id = $request->id;
  166. $status = $request->status;
  167. $reason = $request->reason;
  168. $url = empty($request->url) ? '/ST3IXxKlOa4eGEv0eTw0CfORI9444Mgj/content/recuperate/apply' : $request->url;
  169. if (empty($id)) {
  170. admin_toastr('数据异常', 'error');
  171. return redirect('/ST3IXxKlOa4eGEv0eTw0CfORI9444Mgj/content/recuperate/apply');
  172. }
  173. $result = RecuperateApply::where('id', '=', $id)->update(['status' => $status, 'reason' => $reason]);
  174. if ($result) {
  175. admin_toastr('审核成功', 'success');
  176. } else {
  177. admin_toastr('该信息不存在或已审核', 'error');
  178. }
  179. return redirect($url);
  180. }
  181. public function audit_qx(Request $request)
  182. {
  183. $id = $request->id;
  184. // $status = $request->status;
  185. // $reason = $request->reason;
  186. $url = empty($request->url) ? '/ST3IXxKlOa4eGEv0eTw0CfORI9444Mgj/content/recuperate/apply' : $request->url;
  187. if (empty($id)) {
  188. admin_toastr('数据异常1', 'error');
  189. return redirect('/ST3IXxKlOa4eGEv0eTw0CfORI9444Mgj/content/recuperate/apply');
  190. }
  191. $result = RecuperateApply::where('id', '=', $id)->update(['status' => 3]);
  192. $recuperate_apply = RecuperateApply::where('id', '=', $id)->select('uid')->first();
  193. $auditData = [
  194. 'type' => 2,
  195. 'admin_id' => \Encore\Admin\Facades\Admin::user()->id,
  196. 'sid' => $recuperate_apply->uid,
  197. 'content' => "取消活动",
  198. ];
  199. RecuperateLog::create($auditData);
  200. if ($result) {
  201. admin_toastr('取消成功', 'success');
  202. } else {
  203. admin_toastr('该信息不存在或已审核', 'error');
  204. }
  205. return redirect($url);
  206. }
  207. /*个人列表*/
  208. public function appointinfo(Content $content, Request $request)
  209. {
  210. $uid = $request->uid;
  211. $recuperateApply = RecuperateApply::where('uid', $uid);
  212. $recuperateTime = RecuperateTime::where('uid', $uid)->select('id', 'year')->orderBy('id', 'desc')->get();
  213. if (empty($recuperateApply)) {
  214. return back();
  215. }
  216. $search_data = $request->all();
  217. $search_data['uid'] = isset($search_data['uid']) ? $search_data['uid'] : $uid;
  218. $search_data['status'] = isset($search_data['status']) ? $search_data['status'] : 1;
  219. $search_data['recuperate_time_id'] = isset($search_data['recuperate_time_id']) ? $search_data['recuperate_time_id'] : $recuperateTime[0]->id;
  220. $where = [];
  221. if (isset($search_data['perpage'])) {
  222. $perpage = $search_data['perpage'];
  223. } else {
  224. $session_data = session('search_data');
  225. if (isset($session_data['perpage'])) {
  226. $perpage = $session_data['perpage'];
  227. } else {
  228. $perpage = 20;
  229. }
  230. }
  231. if (isset($search_data['uid']) || session('manage_search_data')['uid']) {
  232. if (isset($search_data['page'])) {
  233. if (session('search_data')) {
  234. $where = session('managewhere');
  235. unset($search_data['page']);
  236. $search_data = session('manage_search_data');
  237. }
  238. }
  239. foreach ($search_data as $k => $v) {
  240. if ($k == 'status') {
  241. $where[] = ['recuperate_apply.status', 'like', "%$v%"];
  242. } elseif ($k == 'recuperate_time_id') {
  243. $where[] = ['recuperate_apply.recuperate_time_id', '=', $v];
  244. } elseif ($k == 'uid') {
  245. $where[] = ['recuperate_apply.uid', '=', $v];
  246. } elseif ($k != '_pjax' and $k != 'page' && $k != 'perpage') {
  247. $where[] = [$k, '=', $v];
  248. }
  249. }
  250. session(['managewhere' => $where]);
  251. session(['manage_search_data' => $search_data]);
  252. session()->save();
  253. }
  254. $list = RecuperateApply::where($where)
  255. ->join('recuperate', 'recuperate_apply.recuperate_id', '=', 'recuperate.id', 'left')
  256. ->join('recuperate_time', 'recuperate_apply.recuperate_time_id', '=', 'recuperate_time.id', 'left')
  257. ->select('recuperate_apply.*', 'recuperate.title', 'recuperate_time.year')
  258. ->orderBy('recuperate_apply.id', 'desc')
  259. ->paginate($perpage);
  260. return $content
  261. ->header('招考管理')
  262. ->description('招考人员信息列表')
  263. ->body(view('admin.content.recuperate_apply_personal')->with([
  264. 'list' => $list,
  265. 'search_data' => $search_data,
  266. 'recuperateTime' => $recuperateTime,
  267. ]));
  268. }
  269. }