RecuperateApplyController.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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->created_at('报名时间');
  100. $grid->column('审核状态')->display(function () {
  101. $status_arr = [
  102. '待审核',
  103. '审核通过',
  104. '审核不通过',
  105. '取消活动',
  106. ];
  107. $reason = $this->reason ? '<a style="margin-left: 5px;" data-reason="' . $this->reason . '" class="audit_log"><i class="fa fa-eye"></i></a>' : '';
  108. return '<span style="color:#FF6600">' . $status_arr[$this->status] . $reason . '</span>';
  109. });
  110. //审核功能
  111. $grid->actions(function ($actions) {
  112. if ($actions->row['status'] == 0) {
  113. $actions->append("<button class='btn btn-primary btn-xs applyaudit' data-code=" . $actions->row['id'] . ">审核</button>");
  114. }
  115. /*取消活动*/
  116. if ($actions->row['status'] != 2 && $actions->row['status'] != 3) {
  117. $actions->append("<button class='btn btn-primary btn-xs applyaudits' data-code=" . $actions->row['id'] . ">取消</button>");
  118. }
  119. });
  120. $grid->filter(function ($filter) {
  121. $filter->disableIdFilter();
  122. $filter->equal('recuperate_id', '套餐id');
  123. /*$filter->where(function($query){
  124. $recuperate = Recuperate::where('title','like',"%{$this->input}%")->get();
  125. $ids = $recuperate->pluck('id')->all();
  126. if (empty($ids)) {
  127. $query->where('id','=',0);
  128. } else {
  129. $query->whereIn('recuperate_id',$ids);
  130. }
  131. }, '');*/
  132. $date3 = date('Y-m-d', strtotime("-3 day"));
  133. $date7 = date('Y-m-d', strtotime("-7 day"));
  134. $date30 = date("Y-m-d", strtotime("-1 month"));
  135. $date180 = date("Y-m-d", strtotime("-6 month"));
  136. $date360 = date("Y-m-d", strtotime("-1 year"));
  137. $date_option = [
  138. '' => '不限',
  139. $date3 => '三天内',
  140. $date7 => '一周内',
  141. $date30 => '一月内',
  142. $date180 => '半年内',
  143. $date360 => '一年内',
  144. ];
  145. $filter->where(function ($query) {
  146. $query->where('created_at', '>=', "{$this->input}");
  147. }, '添加时间', 'created_at')->radio($date_option);
  148. $status_option = [
  149. '' => '不限',
  150. 0 => '待审核',
  151. 1 => '审核通过',
  152. 2 => '审核不通过',
  153. ];
  154. $filter->where(function ($query) {
  155. if (isset($this->input)) {
  156. $query->where('status', '=', "{$this->input}");
  157. }
  158. }, '审核状态', 'status')->radio($status_option);
  159. });
  160. return $grid;
  161. }
  162. public function audit(Request $request)
  163. {
  164. $id = $request->id;
  165. $status = $request->status;
  166. $reason = $request->reason;
  167. $url = empty($request->url) ? '/ST3IXxKlOa4eGEv0eTw0CfORI9444Mgj/content/recuperate/apply' : $request->url;
  168. if (empty($id)) {
  169. admin_toastr('数据异常', 'error');
  170. return redirect('/ST3IXxKlOa4eGEv0eTw0CfORI9444Mgj/content/recuperate/apply');
  171. }
  172. $result = RecuperateApply::where('id', '=', $id)->update(['status' => $status, 'reason' => $reason]);
  173. if ($result) {
  174. admin_toastr('审核成功', 'success');
  175. } else {
  176. admin_toastr('该信息不存在或已审核', 'error');
  177. }
  178. return redirect($url);
  179. }
  180. public function audit_qx(Request $request)
  181. {
  182. $id = $request->id;
  183. // $status = $request->status;
  184. // $reason = $request->reason;
  185. $url = empty($request->url) ? '/ST3IXxKlOa4eGEv0eTw0CfORI9444Mgj/content/recuperate/apply' : $request->url;
  186. if (empty($id)) {
  187. admin_toastr('数据异常1', 'error');
  188. return redirect('/ST3IXxKlOa4eGEv0eTw0CfORI9444Mgj/content/recuperate/apply');
  189. }
  190. $result = RecuperateApply::where('id', '=', $id)->update(['status' => 3]);
  191. $recuperate_apply = RecuperateApply::where('id', '=', $id)->select('uid')->first();
  192. $auditData = [
  193. 'type' => 2,
  194. 'admin_id' => \Encore\Admin\Facades\Admin::user()->id,
  195. 'sid' => $recuperate_apply->uid,
  196. 'content' => "取消活动",
  197. ];
  198. RecuperateLog::create($auditData);
  199. if ($result) {
  200. admin_toastr('取消成功', 'success');
  201. } else {
  202. admin_toastr('该信息不存在或已审核', 'error');
  203. }
  204. return redirect($url);
  205. }
  206. /*个人列表*/
  207. public function appointinfo(Content $content, Request $request)
  208. {
  209. $uid = $request->uid;
  210. $recuperateApply = RecuperateApply::where('uid', $uid);
  211. $recuperateTime = RecuperateTime::where('uid', $uid)->select('id', 'year')->orderBy('id', 'desc')->get();
  212. if (empty($recuperateApply)) {
  213. return back();
  214. }
  215. $search_data = $request->all();
  216. $search_data['uid'] = isset($search_data['uid']) ? $search_data['uid'] : $uid;
  217. $search_data['status'] = isset($search_data['status']) ? $search_data['status'] : 1;
  218. $search_data['recuperate_time_id'] = isset($search_data['recuperate_time_id']) ? $search_data['recuperate_time_id'] : $recuperateTime[0]->id;
  219. $where = [];
  220. if (isset($search_data['perpage'])) {
  221. $perpage = $search_data['perpage'];
  222. } else {
  223. $session_data = session('search_data');
  224. if (isset($session_data['perpage'])) {
  225. $perpage = $session_data['perpage'];
  226. } else {
  227. $perpage = 20;
  228. }
  229. }
  230. if (isset($search_data['uid']) || session('manage_search_data')['uid']) {
  231. if (isset($search_data['page'])) {
  232. if (session('search_data')) {
  233. $where = session('managewhere');
  234. unset($search_data['page']);
  235. $search_data = session('manage_search_data');
  236. }
  237. }
  238. foreach ($search_data as $k => $v) {
  239. if ($k == 'status') {
  240. $where[] = ['recuperate_apply.status', 'like', "%$v%"];
  241. } elseif ($k == 'recuperate_time_id') {
  242. $where[] = ['recuperate_apply.recuperate_time_id', '=', $v];
  243. } elseif ($k == 'uid') {
  244. $where[] = ['recuperate_apply.uid', '=', $v];
  245. } elseif ($k != '_pjax' and $k != 'page' && $k != 'perpage') {
  246. $where[] = [$k, '=', $v];
  247. }
  248. }
  249. session(['managewhere' => $where]);
  250. session(['manage_search_data' => $search_data]);
  251. session()->save();
  252. }
  253. $list = RecuperateApply::where($where)
  254. ->join('recuperate', 'recuperate_apply.recuperate_id', '=', 'recuperate.id', 'left')
  255. ->join('recuperate_time', 'recuperate_apply.recuperate_time_id', '=', 'recuperate_time.id', 'left')
  256. ->select('recuperate_apply.*', 'recuperate.title', 'recuperate_time.year')
  257. ->orderBy('recuperate_apply.id', 'desc')
  258. ->paginate($perpage);
  259. return $content
  260. ->header('招考管理')
  261. ->description('招考人员信息列表')
  262. ->body(view('admin.content.recuperate_apply_personal')->with([
  263. 'list' => $list,
  264. 'search_data' => $search_data,
  265. 'recuperateTime' => $recuperateTime,
  266. ]));
  267. }
  268. }