Wdemand.php 10 KB

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