Resume.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. $data['brokerid'] = $this->_broker['id'];
  80. $data['updatetime'] = time();
  81. if (empty($data['id'])) {
  82. $data['createtime'] = time();
  83. OutResume::create($data);
  84. } else {
  85. OutResume::update($data);
  86. }
  87. ajax_return();
  88. }
  89. /**
  90. * 跟进
  91. */
  92. public function follow()
  93. {
  94. $id = input('get.id');
  95. $resume = OutResume::where('id', $id)->append(['gender_text'])->find();
  96. if (empty($resume)) {
  97. jump('该简历不存在');
  98. }
  99. $follow = OutFollow::where('resume_id', $id)->append(['status_text'])->order('id', 'desc')->select();
  100. return view('resume/follow', [
  101. 'id' => $id,
  102. 'resume' => json_encode($resume),
  103. 'follow' => $follow,
  104. 'status_list' => json_encode(OutFollow::$status),
  105. ]);
  106. }
  107. /**
  108. * 跟进提交
  109. */
  110. public function followPost()
  111. {
  112. $data = input('post.');
  113. try {
  114. validate(FollowValidate::class)->check($data);
  115. } catch (ValidateException $e) {
  116. ajax_return(1, $e->getError());
  117. }
  118. OutResume::update(['updatetime' => time()], ['id' => $data['resume_id']]);
  119. $data['createtime'] = time();
  120. OutFollow::create($data);
  121. ajax_return();
  122. }
  123. }