Resume.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <?php
  2. namespace app\mobile\controller;
  3. use app\common\model\OutFollow;
  4. use app\common\model\OutResume as OutResumeModel;
  5. use app\common\model\OutResume;
  6. use app\mobile\MobileBaseController;
  7. use app\mobile\validate\FollowValidate;
  8. use app\mobile\validate\ResumeValidate;
  9. use think\App;
  10. use think\exception\ValidateException;
  11. use think\facade\View;
  12. class Resume extends MobileBaseController
  13. {
  14. private $_broker = null;
  15. public function __construct(App $app)
  16. {
  17. parent::__construct($app);
  18. $this->_broker = get_broker();
  19. View::assign('broker', $this->_broker);
  20. }
  21. /**
  22. * 简历列表
  23. */
  24. public function index()
  25. {
  26. return view('resume/index');
  27. }
  28. /**
  29. * 收益明细列表
  30. */
  31. public function listResume()
  32. {
  33. $map = $this->dealLikeInput(['searchKey' => 'name|mobile']);
  34. $map[] = ['brokerid', '=', $this->_broker['id']];
  35. $list = OutResumeModel::where($map)
  36. ->order(['updatetime' => 'desc'])
  37. ->limit(input('limit', 5))
  38. ->page(input('page', 1))
  39. ->append(['status_text'])
  40. ->select();
  41. foreach ($list as $v) {
  42. $log = OutFollow::where('resume_id', $v['id'])->order('id desc')->find();
  43. if (!empty($log)) {
  44. $v['last_msg'] = $log['remark'];
  45. $v['last_msg_time'] = $log['createtime'];
  46. } else {
  47. $v['last_msg'] = '未跟进';
  48. $v['last_msg_time'] = '';
  49. }
  50. }
  51. ajax_success($list);
  52. }
  53. /**
  54. * 表单
  55. */
  56. public function form()
  57. {
  58. $id = input('get.id');
  59. $data = ['form' => '{gender:1}'];
  60. if (!empty($id)) {
  61. $form = OutResume::where('id', $id)->find();
  62. if (!empty($form)) {
  63. $data['form'] = $form;
  64. }
  65. }
  66. return view('resume/form', $data);
  67. }
  68. /**
  69. * 表单提交
  70. */
  71. public function formPost()
  72. {
  73. $data = input('post.');
  74. try {
  75. validate(ResumeValidate::class)->check($data);
  76. } catch (ValidateException $e) {
  77. ajax_return(1, $e->getError());
  78. }
  79. $mobile_check = OutResumeModel::where('mobile', $data['mobile'])->find();
  80. $mobile_check && ajax_return(1, '该手机号已被登记!');
  81. $data['brokerid'] = $this->_broker['id'];
  82. $data['updatetime'] = time();
  83. if (empty($data['id'])) {
  84. $data['createtime'] = time();
  85. OutResume::create($data);
  86. } else {
  87. OutResume::update($data);
  88. }
  89. ajax_return();
  90. }
  91. /**
  92. * 跟进
  93. */
  94. public function follow()
  95. {
  96. $id = input('get.id');
  97. $resume = OutResume::where('id', $id)->append(['gender_text'])->find();
  98. if (empty($resume)) {
  99. jump('该简历不存在');
  100. }
  101. $follow = OutFollow::where('resume_id', $id)->append(['status_text'])->order('id', 'desc')->select();
  102. return view('resume/follow', [
  103. 'id' => $id,
  104. 'resume' => json_encode($resume),
  105. 'follow' => $follow,
  106. 'status_list' => json_encode(OutFollow::$status),
  107. ]);
  108. }
  109. /**
  110. * 跟进提交
  111. */
  112. public function followPost()
  113. {
  114. $data = input('post.');
  115. try {
  116. validate(FollowValidate::class)->check($data);
  117. } catch (ValidateException $e) {
  118. ajax_return(1, $e->getError());
  119. }
  120. OutResume::update(['updatetime' => time()], ['id' => $data['resume_id']]);
  121. $data['createtime'] = time();
  122. OutFollow::create($data);
  123. ajax_return();
  124. }
  125. }