BuyHouseRsController.php 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <?php
  2. namespace App\Admin\Controllers\Content;
  3. use App\Http\Controllers\Controller;
  4. use App\Models\TalentHouse;
  5. use App\Models\TalentHouseApply;
  6. use Encore\Admin\Controllers\HasResourceActions;
  7. use Encore\Admin\Facades\Admin;
  8. use Encore\Admin\Grid;
  9. use Encore\Admin\Layout\Content;
  10. use Illuminate\Http\Request;
  11. use Illuminate\Support\Facades\DB;
  12. class BuyHouseRsController extends Controller
  13. {
  14. use HasResourceActions;
  15. private $status = ['未知', '待审核', '审核通过', '审核不通过'];
  16. private $marry = ['未知', '未婚', '已婚', '离异', '丧偶'];
  17. /**
  18. * Index interface.
  19. *
  20. * @param Content $content
  21. * @return Content
  22. */
  23. public function index(Content $content)
  24. {
  25. return $content
  26. ->header('申报列表')
  27. ->description(' ')
  28. ->body(view('admin.content.buy_house_rs')->with(['grid' => $this->grid()]));
  29. }
  30. /**
  31. * Make a grid builder.
  32. *
  33. * @return Grid
  34. */
  35. protected function grid()
  36. {
  37. $grid = new Grid(new TalentHouseApply());
  38. $grid->model()->with('house')->where('type', 1)->where('is_back', 2)->where('is_draft', 2)->orderBy('rs_check_status', 'ASC');
  39. $status_text = $this->status;
  40. $grid->id('ID');
  41. $grid->name('姓名');
  42. $grid->mobile('联系电话');
  43. $grid->talent_level('人才层次');
  44. $grid->column('房源')->display(function () {
  45. return $this->house->name;
  46. });
  47. $grid->rs_check_status('状态')->display(function () use ($status_text) {
  48. return $status_text[$this->rs_check_status];
  49. });
  50. $grid->rs_check_comment('备注');
  51. $grid->actions(function ($actions) {
  52. if ($actions->row['rs_check_status'] == 1) {
  53. $actions->append("<button class='btn btn-primary btn-xs applyaudit' data-code=" . $actions->row['id'] . ">审核</button>");
  54. }
  55. $actions->append("&nbsp;<button class='btn btn-primary btn-xs detail' id=" . $actions->row['id'] . ">详情</button>");
  56. });
  57. $grid->filter(function ($filter) {
  58. $filter->disableIdFilter();
  59. $filter->equal('house_id', '房源')->select(TalentHouse::all()->pluck('name', 'id'));
  60. $status_option = ['全部', '待审核', '审核通过', '审核不通过'];
  61. $filter->where(function ($query) {
  62. if ($this->input > 0) {
  63. $query->where('status', '=', $this->input);
  64. }
  65. }, '状态', 'status')->radio($status_option);
  66. });
  67. return $grid;
  68. }
  69. /**
  70. * 审核
  71. */
  72. public function audit(Request $request)
  73. {
  74. $id = $request->id;
  75. $status = $request->status;
  76. $reason = $request->reason;
  77. $url = empty($request->url) ? admin_base_path('content/buy_house_rs') : $request->url;
  78. if (empty($id)) {
  79. admin_toastr('数据异常', 'error');
  80. return redirect(admin_base_path('content/buy_house_rs'));
  81. }
  82. $result = TalentHouseApply::where('id', '=', $id)
  83. ->update([
  84. 'rs_check_status' => $status,
  85. 'rs_check_comment' => $reason,
  86. 'rs_check_time' => date('Y-m-d H:i:s'),
  87. 'status' => $status == 2 ? 1 : 3,
  88. ]);
  89. //日志
  90. $apply = TalentHouseApply::find($id);
  91. $house = TalentHouse::find($apply['house_id']);
  92. $admin = Admin::user();
  93. $log = [
  94. 'house_name' => $house['name'],
  95. 'user_name' => $apply['name'],
  96. 'check_name' => $admin['name'],
  97. 'data' => json_encode($apply),
  98. 'created_at' => date('Y-m-d H:i:s'),
  99. 'check_status' => $apply['rs_check_status'],
  100. 'check_comment' => $apply['rs_check_comment'],
  101. ];
  102. DB::table('talent_house_check_log')->insert($log);
  103. if ($result) {
  104. admin_toastr('审核成功', 'success');
  105. } else {
  106. admin_toastr('该信息不存在或已审核', 'error');
  107. }
  108. return redirect($url);
  109. }
  110. /**
  111. * 详情
  112. */
  113. public function detail(Request $request)
  114. {
  115. $id = $request->id;
  116. $info = TalentHouseApply::find($id);;
  117. $info->family = json_decode($info->family);
  118. $info->marry_text = $this->marry[$info->marry];
  119. //layer相册层
  120. $photos = [
  121. 'certificates' => [],
  122. 'marry_prove' => [],
  123. 'household_register' => [],
  124. 'work_prove' => [],
  125. ];
  126. if (!empty(json_decode($info->certificates))) {
  127. $info->certificates = json_decode($info->certificates);
  128. $photo_data = [];
  129. foreach ($info->certificates as $k => $v) {
  130. $photo_data[] = [
  131. 'alt' => $v->name,
  132. 'pid' => $v->uid,
  133. 'src' => $v->response->path,
  134. ];
  135. }
  136. $photos['certificates'] = [
  137. 'title' => '证件信息',
  138. 'id' => 1,
  139. 'start' => 0,
  140. 'data' => $photo_data,
  141. ];
  142. } else {
  143. $info->certificates = [];
  144. }
  145. if (!empty(json_decode($info->marry_prove))) {
  146. $info->marry_prove = json_decode($info->marry_prove);
  147. $photo_data = [];
  148. foreach ($info->marry_prove as $k => $v) {
  149. $photo_data[] = [
  150. 'alt' => $v->name,
  151. 'pid' => $v->uid,
  152. 'src' => $v->response->path,
  153. ];
  154. }
  155. $photos['marry_prove'] = [
  156. 'title' => '婚姻证明',
  157. 'id' => 1,
  158. 'start' => 0,
  159. 'data' => $photo_data,
  160. ];
  161. } else {
  162. $info->marry_prove = [];
  163. }
  164. if (!empty(json_decode($info->household_register))) {
  165. $info->household_register = json_decode($info->household_register);
  166. $photo_data = [];
  167. foreach ($info->household_register as $k => $v) {
  168. $photo_data[] = [
  169. 'alt' => $v->name,
  170. 'pid' => $v->uid,
  171. 'src' => $v->response->path,
  172. ];
  173. }
  174. $photos['household_register'] = [
  175. 'title' => '户口本',
  176. 'id' => 1,
  177. 'start' => 0,
  178. 'data' => $photo_data,
  179. ];
  180. } else {
  181. $info->household_register = [];
  182. }
  183. if (!empty(json_decode($info->work_prove))) {
  184. $info->work_prove = json_decode($info->work_prove);
  185. $photo_data = [];
  186. foreach ($info->work_prove as $k => $v) {
  187. $photo_data[] = [
  188. 'alt' => $v->name,
  189. 'pid' => $v->uid,
  190. 'src' => $v->response->path,
  191. ];
  192. }
  193. $photos['work_prove'] = [
  194. 'title' => '在职证明',
  195. 'id' => 1,
  196. 'start' => 0,
  197. 'data' => $photo_data,
  198. ];
  199. } else {
  200. $info->work_prove = [];
  201. }
  202. $html = view('admin.ajax.buy_house_detail')->with(['info' => $info, 'photos' => $photos])->render();
  203. return response()->json(['code' => 1, 'data' => $html]);
  204. }
  205. }