BuyHouseJcController.php 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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 App\Services\Common\SmsService;
  7. use Encore\Admin\Controllers\HasResourceActions;
  8. use Encore\Admin\Grid;
  9. use Encore\Admin\Layout\Content;
  10. use Illuminate\Http\Request;
  11. class BuyHouseJcController extends Controller
  12. {
  13. use HasResourceActions;
  14. private $status = ['未知', '待审核', '审核通过', '审核不通过'];
  15. private $marry = ['未知', '未婚', '已婚', '离异', '丧偶'];
  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.buy_house_jc')->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 TalentHouseApply());
  37. $grid->model()->with('house')->where('type', 2)->where('is_back', 2)->where('is_draft', 2)->orderBy('rs_check_status', 'ASC');
  38. $status_text = $this->status;
  39. $grid->id('ID');
  40. $grid->name('姓名');
  41. $grid->mobile('联系电话');
  42. $grid->talent_level('人才层次');
  43. $grid->column('房源')->display(function () {
  44. return $this->house->name;
  45. });
  46. $grid->rs_check_status('状态')->display(function () use ($status_text) {
  47. return $status_text[$this->rs_check_status];
  48. });
  49. $grid->rs_check_comment('备注');
  50. $grid->actions(function ($actions) {
  51. if ($actions->row['rs_check_status'] == 1) {
  52. $actions->append("<button class='btn btn-primary btn-xs applyaudit' data-code=" . $actions->row['id'] . ">审核</button>");
  53. }
  54. $actions->append("&nbsp;<button class='btn btn-primary btn-xs detail' id=" . $actions->row['id'] . ">详情</button>");
  55. });
  56. $grid->filter(function ($filter) {
  57. $filter->disableIdFilter();
  58. $filter->equal('house_id', '房源')->select(TalentHouse::all()->pluck('name', 'id'));
  59. $status_option = ['全部', '待审核', '审核通过', '审核不通过'];
  60. $filter->where(function ($query) {
  61. if ($this->input > 0) {
  62. $query->where('status', '=', $this->input);
  63. }
  64. }, '状态', 'status')->radio($status_option);
  65. });
  66. return $grid;
  67. }
  68. /**
  69. * 审核
  70. */
  71. public function audit(Request $request, SmsService $smsService)
  72. {
  73. $id = $request->id;
  74. $status = $request->status;
  75. $reason = $request->reason;
  76. $url = empty($request->url) ? admin_base_path('content/buy_house_jc') : $request->url;
  77. if (empty($id)) {
  78. admin_toastr('数据异常', 'error');
  79. return redirect(admin_base_path('content/buy_house_jc'));
  80. }
  81. $result = TalentHouseApply::where('id', '=', $id)
  82. ->update([
  83. 'rs_check_status' => $status,
  84. 'rs_check_comment' => $reason,
  85. 'rs_check_time' => date('Y-m-d H:i:s'),
  86. 'status' => $status == 2 ? 1 : 3,
  87. ]);
  88. //审核不通过发送短信
  89. if ($status == 3) {
  90. $apply = TalentHouseApply::find($id);
  91. $house = TalentHouse::find($apply['house_id']);
  92. $time = strtotime($house['supply_time']);
  93. $smsService->sendSms($apply['mobile'], 'sms_buyhouse_supply', ['name' => $apply['name'], 'month' => date('m', $time), 'day' => date('d', $time)]);
  94. }
  95. if ($result) {
  96. admin_toastr('审核成功', 'success');
  97. } else {
  98. admin_toastr('该信息不存在或已审核', 'error');
  99. }
  100. return redirect($url);
  101. }
  102. /**
  103. * 详情
  104. */
  105. public function detail(Request $request)
  106. {
  107. $id = $request->id;
  108. $info = TalentHouseApply::with('idcard')->where('id', $id)->first();
  109. $info->family = json_decode($info->family);
  110. $info->marry_text = $this->marry[$info->marry];
  111. //layer相册层
  112. $photos = [
  113. 'certificates' => [],
  114. 'marry_prove' => [],
  115. 'household_register' => [],
  116. 'work_prove' => [],
  117. ];
  118. if (!empty(json_decode($info->certificates))) {
  119. $info->certificates = json_decode($info->certificates);
  120. $photo_data = [];
  121. foreach ($info->certificates as $k => $v) {
  122. $photo_data[] = [
  123. 'alt' => $v->name,
  124. 'pid' => $v->uid,
  125. 'src' => $v->response->path,
  126. ];
  127. }
  128. $photos['certificates'] = [
  129. 'title' => '证件信息',
  130. 'id' => 1,
  131. 'start' => 0,
  132. 'data' => $photo_data,
  133. ];
  134. } else {
  135. $info->certificates = [];
  136. }
  137. if (!empty(json_decode($info->marry_prove))) {
  138. $info->marry_prove = json_decode($info->marry_prove);
  139. $photo_data = [];
  140. foreach ($info->marry_prove as $k => $v) {
  141. $photo_data[] = [
  142. 'alt' => $v->name,
  143. 'pid' => $v->uid,
  144. 'src' => $v->response->path,
  145. ];
  146. }
  147. $photos['marry_prove'] = [
  148. 'title' => '婚姻证明',
  149. 'id' => 1,
  150. 'start' => 0,
  151. 'data' => $photo_data,
  152. ];
  153. } else {
  154. $info->marry_prove = [];
  155. }
  156. if (!empty(json_decode($info->household_register))) {
  157. $info->household_register = json_decode($info->household_register);
  158. $photo_data = [];
  159. foreach ($info->household_register as $k => $v) {
  160. $photo_data[] = [
  161. 'alt' => $v->name,
  162. 'pid' => $v->uid,
  163. 'src' => $v->response->path,
  164. ];
  165. }
  166. $photos['household_register'] = [
  167. 'title' => '户口本',
  168. 'id' => 1,
  169. 'start' => 0,
  170. 'data' => $photo_data,
  171. ];
  172. } else {
  173. $info->household_register = [];
  174. }
  175. if (!empty(json_decode($info->work_prove))) {
  176. $info->work_prove = json_decode($info->work_prove);
  177. $photo_data = [];
  178. foreach ($info->work_prove as $k => $v) {
  179. $photo_data[] = [
  180. 'alt' => $v->name,
  181. 'pid' => $v->uid,
  182. 'src' => $v->response->path,
  183. ];
  184. }
  185. $photos['work_prove'] = [
  186. 'title' => '在职证明',
  187. 'id' => 1,
  188. 'start' => 0,
  189. 'data' => $photo_data,
  190. ];
  191. } else {
  192. $info->work_prove = [];
  193. }
  194. $html = view('admin.ajax.buy_house_detail')->with(['info' => $info, 'photos' => $photos])->render();
  195. return response()->json(['code' => 1, 'data' => $html]);
  196. }
  197. }