Outjob.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <?php
  2. namespace app\worker\controller;
  3. use app\worker\BaseController;
  4. use app\common\model\AgentMarket as AgentMarketModel;
  5. use app\common\model\OutRecruit as OutRecruitModel;
  6. use app\common\model\OutRecruitReport as OutRecruitReportModel;
  7. use app\common\model\OutCode as OutCodeModel;
  8. use think\facade\Request;
  9. class Outjob extends BaseController
  10. {
  11. /**
  12. * 招聘信息
  13. */
  14. public function index()
  15. {
  16. $workerid = $this->access_worker['id'];
  17. if (Request::isAjax()) {
  18. $limit = input('limit/d', 20);
  19. $page = input('page/d', 1);
  20. $map = [];
  21. $map[] = ['worker_id', '=', $workerid];
  22. $keywords = input('keywords/s', "");
  23. if (!empty($keywords)) {
  24. $map[] = ['title', 'like', '%' . $keywords . '%'];
  25. }
  26. $status = input('status/d');
  27. if (!empty($status)) {
  28. $map[] = ['status', '=', $status];
  29. }
  30. $list = OutRecruitModel::where($map)
  31. ->order(['priority' => 'desc', 'id' => 'desc'])
  32. ->limit($limit)
  33. ->page($page)
  34. ->append(['status_text'])
  35. ->select();
  36. $count = OutRecruitModel::where($map)->count();
  37. if ($count == 0) {
  38. exit(json_encode([
  39. 'code' => 1,
  40. 'msg' => "未查询到数据",
  41. ]));
  42. }
  43. exit(json_encode([
  44. 'code' => 0,
  45. 'msg' => "",
  46. 'count' => $count,
  47. 'data' => $list,
  48. ]));
  49. } else {
  50. return view('outjob/index');
  51. }
  52. }
  53. public function editrecruit()
  54. {
  55. $id = input('id/d', 0);
  56. $data = [
  57. 'title' => input('title/s', ""),
  58. 'company_name' => input('company_name/s', ""),
  59. 'num' => input('num/d', 1),
  60. 'province' => input('province/s', ""),
  61. 'city' => input('city/s', ""),
  62. 'district' => input('district/s', ""),
  63. 'address' => input('address/s', ""),
  64. 'agegroup' => input('agegroup/s', ""),
  65. 'tags' => input('tags/a', []),
  66. 'requirement' => input('requirement/s', ""),
  67. 'comdetails' => input('comdetails/s', ""),
  68. 'picall' => input('picall/a', []),
  69. 'salary' => input('salary/s', ""),
  70. 'telephone' => input('telephone/s', ""),
  71. 'remark' => input('remark/s', ""),
  72. 'priority' => input('priority/d', 255),
  73. 'volume' => input('volume/d', 0),
  74. 'market_content' => input('market_content/s', ""),
  75. 'is_bargain' => input('is_bargain/d', 1),
  76. 'updatetime' => time(),
  77. ];
  78. $data['status'] = 2;
  79. if (empty($id)) {
  80. $data['worker_id'] = $this->access_worker['id'];
  81. $data['createtime'] = time();
  82. OutRecruitModel::create($data);
  83. } else {
  84. OutRecruitModel::update($data, ['id' => $id]);
  85. }
  86. exit(json_encode([
  87. 'code' => 0,
  88. ]));
  89. }
  90. public function delrecruit()
  91. {
  92. $id = input('id/d');
  93. $res = OutRecruitReportModel::where('recruit_id', $id)->find();
  94. if (!empty($res)) {
  95. exit(json_encode([
  96. 'code' => 1,
  97. 'msg' => "已有报备记录,无法删除",
  98. ]));
  99. }
  100. OutRecruitModel::destroy($id);
  101. exit(json_encode([
  102. 'code' => 0,
  103. ]));
  104. }
  105. public function recruitform()
  106. {
  107. $id = input('id/d, 0');
  108. $recruit = OutRecruitModel::findOrEmpty($id);
  109. return view('outjob/recruitform', [
  110. 'recruit' => $recruit,
  111. ]);
  112. }
  113. public function market()
  114. {
  115. if (Request::isAjax()) {
  116. $limit = input('limit/d', 20);
  117. $page = input('page/d', 1);
  118. $list = AgentMarketModel::limit($limit)
  119. ->page($page)
  120. ->append(['is_bargain_text'])
  121. ->select();
  122. $count = AgentMarketModel::count();
  123. if ($count == 0) {
  124. exit(json_encode([
  125. 'code' => 1,
  126. 'msg' => "未查询到数据",
  127. ]));
  128. }
  129. exit(json_encode([
  130. 'code' => 0,
  131. 'msg' => "",
  132. 'count' => $count,
  133. 'data' => $list,
  134. ]));
  135. } else {
  136. return view('outjob/market');
  137. }
  138. }
  139. public function print()
  140. {
  141. return view('outjob/print');
  142. }
  143. /**
  144. * 推广码
  145. */
  146. public function qrcode()
  147. {
  148. error_reporting(E_ERROR);
  149. $code = uniqid();
  150. $url = 'https://linggong.jinjianghc.com/applet/outactivity/index?code=' . $code;
  151. OutCodeModel::create([
  152. 'code' => $code,
  153. 'create_time' => time(),
  154. 'workerid' => $this->access_worker['id'],
  155. ]);
  156. header('Content-Type: image/png');
  157. ob_clean();
  158. $errorCorrectionLevel = "L"; // 纠错级别:L、M、Q、H
  159. $matrixPointSize = "4"; //生成图片大小 :1到10
  160. \phpqrcode\QRcode::png($url, false, $errorCorrectionLevel, $matrixPointSize);
  161. exit();
  162. }
  163. }