Active.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. namespace app\web\controller;
  3. use app\common\model\WorkerThird;
  4. use app\common\model\Comjobs as ComjobsModel;
  5. use app\common\model\Worker as WorkerModel;
  6. use echowx\WxProgram;
  7. class Active
  8. {
  9. public function aiRecruit()
  10. {
  11. $map = [];
  12. $map[] = ['createtime', '<=', time()];
  13. $map[] = ['status', 'in', '3,4'];
  14. $searchval = input('searchval/s', "");
  15. $whereor = [];
  16. if (!empty($searchval)) {
  17. $whereor[] = ['title', 'like', '%' . $searchval . '%'];
  18. $lmap = [];
  19. $lmap[] = ['title', 'like', '%' . $searchval . '%'];
  20. $worklike = WorkerModel::where($lmap)->select();
  21. $wkids = [];
  22. foreach ($worklike as $lk => $v) {
  23. $wkids[] = $v["id"];
  24. }
  25. $whereor[] = ['workerid', 'in', $wkids];
  26. }
  27. $cateid = input('cateid/s', "");
  28. if (!empty($cateid)) {
  29. $map[] = ['cateid', 'IN', $cateid];
  30. }
  31. $wtype = input('wtype/d', 0);
  32. if ($wtype != 0) {
  33. $map[] = ['wtype', '=', $wtype];
  34. }
  35. $rectype = input('rectype/d', 0);
  36. if ($rectype != 0) {
  37. $map[] = ['recruitment_cate', '=', $rectype];
  38. }
  39. $district = input('district/s', "");
  40. if (!empty($district)) {
  41. $map[] = ['district', '=', $district];
  42. }
  43. $orderby = ['status' => 'asc', 'updatetime' => 'desc', 'id' => 'desc'];
  44. $plist = ComjobsModel::with(['worker', 'comjobsCate'])->where($map)->where(function ($q) use ($whereor) {
  45. $q->whereOr($whereor);
  46. })->order($orderby)->select();
  47. //数据处理
  48. //第三方id
  49. $third_ids = [];
  50. $third_lists = [];
  51. foreach ($plist as $l) {
  52. if (!empty($l['third_id'])) {
  53. $third_ids[] = $l['third_id'];
  54. }
  55. }
  56. if (!empty($third_ids)) {
  57. $third_lists = WorkerThird::where('id', 'in', $third_ids)->column('*', 'id');
  58. }
  59. $plist = $plist->toArray();
  60. foreach ($plist as $k => $v) {
  61. if (!empty($v['third_id'])) {
  62. $plist[$k]['worker']['title'] = $third_lists[$v['third_id']]['name'];
  63. }
  64. }
  65. $res = $this->_split_arr($plist, 4);
  66. return view('active/ai_recruit', ['res' => $res]);
  67. }
  68. private function _split_arr($arr, $num)
  69. {
  70. $res = [];
  71. $item = [];
  72. foreach ($arr as $k => $v) {
  73. if ($k % $num == 0 && $k != 0) {
  74. $res[] = $item;
  75. $item = [];
  76. }
  77. $item[] = $v;
  78. }
  79. if (!empty($item)) {
  80. $res[] = $item;
  81. }
  82. return $res;
  83. }
  84. public function qrcode()
  85. {
  86. $id = input('id');
  87. $userid = 0;
  88. $info = ComjobsModel::where('id', $id)->find();
  89. if (empty($info)) {
  90. return '';
  91. }
  92. $filename = $id . "_" . $userid . ".jpg";
  93. $dst_comjobspic = root_path("public/attachment/comjobspic") . $filename;
  94. if (!file_exists($dst_comjobspic)) {
  95. $wxprogram = new WxProgram();
  96. $wxprogram->wxacode_get_unlimited($id . "&" . $userid, "pages/comjobs/detail", 430, "attachment/comjobspic/" . $id . "_" . $userid . ".jpg");
  97. }
  98. header("Content-type: image/jpeg");
  99. $im = @imagecreatefromjpeg($dst_comjobspic);
  100. imagejpeg($im);
  101. }
  102. }