Wdemand.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. <?php
  2. namespace app\mainapp\controller;
  3. use app\mainapp\BaseController;
  4. use app\common\model\Demand as DemandModel;
  5. use app\common\model\DemandCate as DemandCateModel;
  6. use app\common\model\DemandLog as DemandLogModel;
  7. use app\common\model\Param as ParamModel;
  8. use app\common\model\User as UserModel;
  9. use app\common\model\Worker as WorkerModel;
  10. use app\common\model\UserIntegral as UserIntegralModel;
  11. use app\common\model\DemandSnatch as DemandSnatchModel;
  12. use app\common\validate\Demand as DemandValidate;
  13. use think\exception\ValidateException;
  14. class Wdemand extends BaseController
  15. {
  16. public function pageWdemandLog()
  17. {
  18. $demandid = input('demandid/d', 0);
  19. $workerid = input('workerid/d', 0);
  20. $demand = DemandModel::where(['workerid' => $workerid])->append(['ftype_text', 'wtype_text'])->findOrEmpty($demandid);
  21. if ($demand->isEmpty()) {
  22. page_result(1, "招聘订单信息不存在。");
  23. }
  24. $logcount = DemandSnatchModel::where(['demand_id' => $demandid])->where('status','>=',2)->count();
  25. page_result(0, "", [
  26. 'demand' => $demand,
  27. 'logcount' => $logcount,
  28. ]);
  29. }
  30. /*public function wdemandLogList()
  31. {
  32. $ppage = input('ppage/d', 1);
  33. $psize = input('psize/d', 20);
  34. $map = array();
  35. $workerid = input('workerid/d', 0);
  36. $map[] = ['workerid','=',$workerid];
  37. $demandid = input('demandid/d', 0);
  38. $map[] = ['demandid','=',$demandid];
  39. $plist = DemandLogModel::with(['gworker'])->where($map)->order(['createtime'=>'desc', 'id'=>'desc'])->page($ppage)->limit($psize)->select();
  40. page_result(0, "", array(
  41. 'plist' => $plist,
  42. 'pstatus' => $psize > count($plist) ? 'noMore' : 'more'
  43. ));
  44. }*/
  45. public function wdemandLogList()
  46. {
  47. $ppage = input('ppage/d', 1);
  48. $psize = input('psize/d', 20);
  49. $map = [];
  50. $demandid = input('demandid/d', 0);
  51. $map[] = ['demand_id', '=', $demandid];
  52. $map[] = ['status', '>=', 2];
  53. $plist = DemandSnatchModel::with(['worker'])->where($map)->order(['createtime' => 'desc', 'id' => 'desc'])->page($ppage)->limit($psize)->select();
  54. page_result(0, "", [
  55. 'plist' => $plist,
  56. 'pstatus' => $psize > count($plist) ? 'noMore' : 'more',
  57. ]);
  58. }
  59. public function pageComlog()
  60. {
  61. $workerid = input('workerid/d', 0);
  62. $demandlist = DemandModel::where(['workerid' => $workerid])->order(['updatetime' => 'desc', 'createtime' => 'desc', 'id' => 'desc'])->field('id as value,title')->select()->toArray();
  63. array_unshift($demandlist, ['id' => 0, 'value' => '全部']);
  64. page_result(0, "", [
  65. 'demandlist' => $demandlist,
  66. 'statuslist' => [['value' => 0, 'title' => "全部"], ['value' => 1, 'title' => "未跟进"], ['value' => 2, 'title' => "未面试"], ['value' => 3, 'title' => "面试通过"], ['value' => 4, 'title' => "面试未通过"], ['value' => 5, 'title' => "用户放弃"], ['value' => 6, 'title' => "已入职"], ['value' => 7, 'title' => "已离职"]],
  67. ]);
  68. }
  69. public function listComlog()
  70. {
  71. $ppage = input('ppage/d', 1);
  72. $psize = input('psize/d', 20);
  73. $map = [];
  74. $workerid = input('workerid/d', 0);
  75. $map[] = ['workerid', '=', $workerid];
  76. $status = input('status/d', 0);
  77. if (!empty($status)) {
  78. $map[] = ['status', '=', $status];
  79. }
  80. $demandid = input('demandid/d', 0);
  81. if (!empty($demandid)) {
  82. $map[] = ['demandid', '=', $demandid];
  83. }
  84. $plist = DemandLogModel::with(['demand', 'user'])->where($map)->order(['createtime' => 'desc', 'id' => 'desc'])->page($ppage)->limit($psize)->append(['status_text'])->select();
  85. page_result(0, "", [
  86. 'plist' => $plist,
  87. 'pstatus' => $psize > count($plist) ? 'noMore' : 'more',
  88. ]);
  89. }
  90. public function delLog()
  91. {
  92. $userid = input('userid/d', 0);
  93. $workerid = input('workerid/d', 0);
  94. $user = UserModel::where(1)->findOrEmpty($userid);
  95. $worker = WorkerModel::where(['userid' => $userid])->findOrEmpty($workerid);
  96. if ($user->isEmpty() || $worker->isEmpty()) {
  97. page_result(1, "用户或公司信息不存在。");
  98. }
  99. $logid = input('logid/d', 0);
  100. $demandlog = DemandLogModel::where(['workerid' => $workerid])->findOrEmpty($logid);
  101. if ($demandlog->isEmpty()) {
  102. page_result(1, "报名记录信息不存在。");
  103. }
  104. $demandlog->delete();
  105. page_result(0, "", []);
  106. }
  107. public function statusLog()
  108. {
  109. $userid = input('userid/d', 0);
  110. $workerid = input('workerid/d', 0);
  111. $user = UserModel::where(1)->findOrEmpty($userid);
  112. $worker = WorkerModel::where(['userid' => $userid])->findOrEmpty($workerid);
  113. if ($user->isEmpty() || $worker->isEmpty()) {
  114. page_result(1, "用户或公司信息不存在。");
  115. }
  116. $logid = input('logid/d', 0);
  117. $demandlog = DemandLogModel::with(['demand', 'user'])->where(['workerid' => $workerid])->append(['status_text'])->findOrEmpty($logid);
  118. if ($demandlog->isEmpty()) {
  119. page_result(1, "报名记录信息不存在。");
  120. }
  121. $status = input('status/d', 1);
  122. $demandlog->save([
  123. 'status' => $status,
  124. ]);
  125. page_result(0, "", [
  126. 'demandlog' => $demandlog,
  127. ]);
  128. }
  129. public function statusDemand()
  130. {
  131. $userid = input('userid/d', 0);
  132. $workerid = input('workerid/d', 0);
  133. $user = UserModel::where(1)->findOrEmpty($userid);
  134. $worker = WorkerModel::where(['userid' => $userid])->findOrEmpty($workerid);
  135. if ($user->isEmpty() || $worker->isEmpty()) {
  136. page_result(1, "用户或公司信息不存在。");
  137. }
  138. $demandid = input('demandid/d', 0);
  139. $demand = DemandModel::where(1)->findOrEmpty($demandid);
  140. if ($demand->isEmpty()) {
  141. page_result(1, "招聘订单信息不存在。");
  142. }
  143. $status = input('status/d', 3);
  144. if ($status == 3 && time() > strtotime($demand->enddate) + 86400) {
  145. page_result(1, "招聘时间已截止,请先编辑招聘订单截止日期。");
  146. }
  147. $demand->save([
  148. 'status' => $status,
  149. ]);
  150. page_result(0, "", []);
  151. }
  152. public function updateDemand()
  153. {
  154. $userid = input('userid/d', 0);
  155. $workerid = input('workerid/d', 0);
  156. $user = UserModel::where(1)->findOrEmpty($userid);
  157. $worker = WorkerModel::where(['userid' => $userid])->findOrEmpty($workerid);
  158. if ($user->isEmpty() || $worker->isEmpty()) {
  159. page_result(1, "用户或公司信息不存在。");
  160. }
  161. $param = ParamModel::where(1)->findOrEmpty();
  162. if ($user->integral < $param->topdemand) {
  163. page_result(1, "每次置顶招聘订单信息需要扣除" . $param->topdemand . "积分,你当前积分不足。");
  164. }
  165. $demandid = input('demandid/d', 0);
  166. $demand = DemandModel::where(1)->findOrEmpty($demandid);
  167. if ($demand->isEmpty()) {
  168. page_result(1, "招聘信息不存在。");
  169. }
  170. $demand->save(['updatetime' => time()]);
  171. $intdata = [
  172. 'userid' => $userid,
  173. 'title' => "置顶招聘订单信息扣除",
  174. 'intvalue' => 0 - $param->topdemand,
  175. 'intmoney' => 0.00,
  176. 'onlycontent' => "",
  177. 'remark' => input('title/s', ""),
  178. 'itype' => 5,
  179. 'status' => 2,
  180. 'createtime' => date("Y-m-d H:i:s"),
  181. 'yeartime' => date("Y"),
  182. 'monthtime' => date("Ym"),
  183. ];
  184. UserIntegralModel::create($intdata);
  185. $integral = intval($user->integral) - intval($param->topdemand);
  186. $user->save([
  187. 'integral' => $integral,
  188. ]);
  189. page_result(0, "", []);
  190. }
  191. public function listDemand()
  192. {
  193. $status = input('status/d', 1);
  194. $workerid = input('workerid/d', 0);
  195. $ppage = input('ppage/d', 1);
  196. $psize = input('psize/d', 20);
  197. $map = [];
  198. $map[] = ['workerid', '=', $workerid];
  199. if (!empty($status)) {
  200. $map[] = ['status', '=', $status];
  201. }
  202. $orderby = ['updatetime' => 'desc', 'createtime' => 'desc', 'id' => 'desc'];
  203. $plist = DemandModel::with(['demandCate'])->where($map)->order($orderby)->page($ppage)->limit($psize)->append(['ftype_text'])->select();
  204. $param = ParamModel::where(1)->findOrEmpty();
  205. page_result(0, "", [
  206. 'param' => $param,
  207. 'plist' => $plist,
  208. 'pstatus' => $psize > count($plist) ? 'noMore' : 'more',
  209. ]);
  210. }
  211. public function getDemand()
  212. {
  213. $workerid = input('workerid/d', 0);
  214. $demandid = input('demandid/d', 0);
  215. $demand = DemandModel::where('workerid', '=', $workerid)->where('id', '=', $demandid)->findOrEmpty();
  216. if ($demand->isEmpty()) {
  217. $demand = "NULL";
  218. } else {
  219. $demand->tags = implode(" ", $demand->tags);
  220. }
  221. $catelist = DemandCateModel::order(['priority' => 'desc', 'id' => 'desc'])->select()->toArray();
  222. page_result(0, "", [
  223. 'demand' => $demand,
  224. 'catelist' => $catelist,
  225. ]);
  226. }
  227. public function editDemand()
  228. {
  229. $userid = input('userid/d', 0);
  230. $workerid = input('workerid/d', 0);
  231. $user = UserModel::where(1)->findOrEmpty($userid);
  232. $worker = WorkerModel::where(['userid' => $userid])->findOrEmpty($workerid);
  233. if ($user->isEmpty() || $worker->isEmpty()) {
  234. page_result(1, "用户或公司信息不存在。");
  235. }
  236. $param = ParamModel::where(1)->findOrEmpty();
  237. $id = input('id/d', 0);
  238. $wtype = input('wtype/d', 1);
  239. $picall = input('picall/s', "");
  240. $zwagall = $wtype == 1 ? input('zwagall/s', "") : '';
  241. $data = [
  242. 'workerid' => input('workerid/d', 0),
  243. 'title' => input('title/s', ""),
  244. 'num' => input('num/d', ""),
  245. 'cateid' => input('cateid/d', 0),
  246. 'province' => input('province/s', ""),
  247. 'city' => input('city/s', ""),
  248. 'district' => input('district/s', ""),
  249. 'agegroup' => input('agegroup/s', ""),
  250. 'tags' => explode(" ", input('tags/s', "")),
  251. 'enddate' => input('enddate/s', ""),
  252. 'requirement' => input('requirement/s', ""),
  253. 'comdetails' => input('comdetails/s', ""),
  254. 'picall' => empty($picall) ? [] : explode(",", $picall),
  255. 'video' => input('video/s', ""),
  256. 'wtype' => $wtype,
  257. 'bwagall' => input('bwagall/s', ""),
  258. 'zwagall' => $zwagall,
  259. 'ftype' => input('ftype/d', 1),
  260. 'fwagall' => input('fwagall/s', ""),
  261. 'telephone' => input('telephone/s', ""),
  262. 'remark' => input('remark/s', ""),
  263. ];
  264. try {
  265. validate(DemandValidate::class)->check($data);
  266. } catch (ValidateException $e) {
  267. page_result(1, $e->getError());
  268. }
  269. if ($id == 0) {
  270. $data = array_merge($data, [
  271. 'status' => 1,
  272. 'priority' => 0,
  273. 'updatetime' => date("Y-m-d H:i:s"),
  274. 'createtime' => date("Y-m-d H:i:s"),
  275. 'volume' => 0,
  276. 'telearr' => [],
  277. ]);
  278. if ($user->integral < $param->adddemand) {
  279. page_result(1, "每次发布招聘订单信息需要扣除" . $param->adddemand . "积分,你当前积分不足。");
  280. }
  281. $demand = DemandModel::create($data);
  282. $intdata = [
  283. 'userid' => $userid,
  284. 'title' => "发布招聘订单信息扣除",
  285. 'intvalue' => 0 - $param->adddemand,
  286. 'intmoney' => 0.00,
  287. 'onlycontent' => "",
  288. 'remark' => input('title/s', ""),
  289. 'itype' => 5,
  290. 'status' => 2,
  291. 'createtime' => date("Y-m-d H:i:s"),
  292. 'yeartime' => date("Y"),
  293. 'monthtime' => date("Ym"),
  294. ];
  295. UserIntegralModel::create($intdata);
  296. $integral = intval($user->integral) - intval($param->adddemand);
  297. $user->save([
  298. 'integral' => $integral,
  299. ]);
  300. } else {
  301. $demand = DemandModel::where('id', '=', $id)->findOrEmpty();
  302. $demand->save($data);
  303. }
  304. page_result(0, "", [
  305. 'demand' => $demand,
  306. ]);
  307. }
  308. }