Demand.php 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067
  1. <?php
  2. namespace app\worker\controller;
  3. use app\worker\BaseController;
  4. use app\common\model\Param as ParamModel;
  5. use app\common\model\Demand as DemandModel;
  6. use app\common\model\DemandOther as DemandOtherModel;
  7. use app\common\model\DemandCate as DemandCateModel;
  8. use app\common\model\DemandLog as DemandLogModel;
  9. use app\common\model\User as UserModel;
  10. use app\common\model\UserIntegral as UserIntegralModel;
  11. use app\common\model\DemandSnatch as DemandSnatchModel;
  12. use app\common\model\DemandReport as DemandReportModel;
  13. use app\common\validate\Demand as DemandValidate;
  14. use think\exception\ValidateException;
  15. use think\facade\Session;
  16. use think\facade\Db;
  17. use think\facade\Request;
  18. class Demand extends BaseController
  19. {
  20. // 我的报名记录
  21. public function logList()
  22. {
  23. $workerid = $this->access_worker['id'];
  24. $workerid = 89;
  25. $data = Db::name("demand_log")
  26. ->alias('a')
  27. ->field('c.ftitle,b.title,a.id,a.gworkerid,a.demandid')
  28. ->where('a.workerid', $workerid)
  29. ->join('demand b', 'a.demandid = b.id', 'LEFT')
  30. ->join('worker c', 'a.gworkerid = c.id', 'LEFT')
  31. ->select()
  32. ->toArray();
  33. $gworker_data = assoc_unique($data, 'gworkerid');
  34. $demand_data = assoc_unique($data, 'demandid');
  35. return view('demand/loglist', [
  36. 'gworker_data' => $gworker_data,
  37. 'demand_data' => $demand_data,
  38. ]);
  39. }
  40. public function delLog()
  41. {
  42. $idarr = input('idarr/a');
  43. $workerid = $this->access_worker['id'];
  44. $workerid = 89;
  45. $res = Db::name('demand_log')
  46. ->where('workerid', $workerid)
  47. ->whereIn('id', $idarr)
  48. ->update(['del_status' => (int)2]);
  49. if ($res) {
  50. exit(json_encode([
  51. 'code' => 0,
  52. 'msg' => "",
  53. ]));
  54. }
  55. exit(json_encode([
  56. 'code' => 1,
  57. 'msg' => "删除失败,请稍后重试",
  58. ]));
  59. }
  60. public function fieldLog()
  61. {
  62. $id = input('id/d', 0);
  63. $log = DemandLogModel::findOrEmpty($id);
  64. if ($log->isEmpty()) {
  65. exit(json_encode([
  66. 'code' => 1,
  67. 'msg' => "信息不存在",
  68. ]));
  69. } else {
  70. $log->save([
  71. input('field/s') => input('value'),
  72. ]);
  73. }
  74. exit(json_encode([
  75. 'code' => 0,
  76. ]));
  77. }
  78. public function listLog()
  79. {
  80. $limit = input('limit/d', 20);
  81. $page = input('page/d', 1);
  82. $map = [];
  83. $gworkerid = input('gworkerid/d');
  84. $demandid = input('demandid/d');
  85. $workerid = $this->access_worker['id'];
  86. $workerid = 89;
  87. $map[] = ['workerid', '=', $workerid];
  88. $map[] = ['del_status', '=', 1];
  89. if (!empty($gworkerid)) {
  90. $map[] = ['gworkerid', '=', $gworkerid];
  91. }
  92. if (!empty($demandid)) {
  93. $map[] = ['demandid', '=', $demandid];
  94. }
  95. $list = DemandLogModel::with(['gworker', 'worker', 'demand'])->where($map)->order('id', 'DESC')->limit($limit)->page($page)->select();
  96. $count = DemandLogModel::where($map)->count();
  97. if ($count == 0) {
  98. exit(json_encode([
  99. 'code' => 1,
  100. 'msg' => "未查询到数据",
  101. ]));
  102. }
  103. exit(json_encode([
  104. 'code' => 0,
  105. 'msg' => "",
  106. 'count' => $count,
  107. 'data' => $list,
  108. ]));
  109. }
  110. public function exportLog()
  111. {
  112. $map = [];
  113. $workerdemandarr = explode(",", input('workerdemand/s'));
  114. $workerid = isset($workerdemandarr[0]) ? $workerdemandarr[0] : 0;
  115. $demandid = isset($workerdemandarr[1]) ? $workerdemandarr[1] : 0;
  116. if (!empty($workerid)) {
  117. $map[] = ['workerid', '=', $workerid];
  118. }
  119. if (!empty($demandid)) {
  120. $map[] = ['demandid', '=', $demandid];
  121. }
  122. $xlsData = DemandLogModel::with(['gworker', 'worker', 'demand'])->where($map)->order('id', 'DESC')->select()->toArray();
  123. $xlsCell = [
  124. ['id', '表ID'],
  125. ['gworker.title', '接单公司名称'],
  126. ['gworker.realname', '接单公司联系人姓名'],
  127. ['gworker.mobile', '接单公司联系人手机号'],
  128. ['worker.title', '发单公司'],
  129. ['demand.title', '订单标题'],
  130. ['createtime', '接单时间'],
  131. ];
  132. export_excel("接单报名记录", $xlsCell, $xlsData);
  133. }
  134. // 企业招聘
  135. public function demandList()
  136. {
  137. if (Request::isAjax()) {
  138. $limit = input('limit/d', 20);
  139. $page = input('page/d', 1);
  140. $map = [];
  141. $workerid = $this->access_worker['id'];
  142. $map[] = ['workerid', '=', $workerid];
  143. $keywords = input('keywords/s', "");
  144. if (!empty($keywords)) {
  145. $map[] = ['title', 'like', '%' . $keywords . '%'];
  146. }
  147. $cateid = input('cateid/d', 0);
  148. if (!empty($cateid)) {
  149. $map[] = ['cateid', '=', $cateid];
  150. }
  151. $wtype = input('wtype/d');
  152. if (!empty($wtype)) {
  153. $map[] = ['wtype', '=', $wtype];
  154. }
  155. $ftype = input('ftype/d');
  156. if (!empty($ftype)) {
  157. $map[] = ['ftype', '=', $ftype];
  158. }
  159. $status = input('status/d');
  160. if (!empty($status)) {
  161. $map[] = ['status', '=', $status];
  162. } else {
  163. $map[] = ['status', '<', 6];
  164. }
  165. $isfree = input('isfree/d', 0);
  166. if (!empty($isfree)) {
  167. $map[] = ['isfree', '=', $isfree];
  168. }
  169. $list = DemandModel::with(['worker', 'demandCate'])
  170. ->withCount(['demandLog'])
  171. ->where($map)
  172. ->order(['priority' => 'desc', 'id' => 'desc',])
  173. ->limit($limit)
  174. ->page($page)
  175. ->append(['wtype_text', 'ftype_text', 'status_text', 'isfree_text'])
  176. ->select();
  177. $count = DemandModel::where($map)->count();
  178. if ($count == 0) {
  179. exit(json_encode([
  180. 'code' => 1,
  181. 'msg' => "未查询到数据",
  182. ]));
  183. }
  184. exit(json_encode([
  185. 'code' => 0,
  186. 'msg' => "",
  187. 'count' => $count,
  188. 'data' => $list,
  189. ]));
  190. } else {
  191. $catelist = DemandCateModel::order(['priority' => 'desc', 'id' => 'desc'])->select();
  192. $param = ParamModel::where(1)->findOrEmpty();
  193. $access_worker = Session::get('access_worker');
  194. $is_released = 1;
  195. if ($access_worker['status'] == 1) {
  196. $is_released = is_released($access_worker['id']);
  197. }
  198. return view('demand/demandlist', [
  199. 'param' => $param,
  200. 'catelist' => $catelist,
  201. 'wtype' => $access_worker['wtype'],
  202. 'is_released' => $is_released['code'],
  203. ]);
  204. }
  205. }
  206. public function demandForm()
  207. {
  208. $worker_data = Session::get('access_worker');
  209. $catelist = DemandCateModel::order(['priority' => 'desc', 'id' => 'desc'])->select();
  210. return view('demand/demandform', [
  211. 'catelist' => $catelist,
  212. 'title' => $worker_data['title'],
  213. ]);
  214. }
  215. public function demandFormWyd()
  216. {
  217. $worker_data = Session::get('access_worker');
  218. $catelist = DemandCateModel::order(['priority' => 'desc', 'id' => 'desc'])->select();
  219. return view('demand/demandformwyd', [
  220. 'catelist' => $catelist,
  221. 'title' => $worker_data['title'],
  222. ]);
  223. }
  224. //修改订单状态
  225. public function editDemandStatus()
  226. {
  227. $id = input('id/d', 0);
  228. $workerid = $this->access_worker['id'];
  229. if (Request::isAjax()) {
  230. $status = input('status/d', 0);
  231. $res = Db::name("demand")
  232. ->where('workerid', $workerid)
  233. ->where('id', $id)
  234. ->update(['status' => $status]);
  235. if ($res) {
  236. exit(json_encode([
  237. 'code' => 0,
  238. ]));
  239. }
  240. } else {
  241. $data = Db::name('demand')
  242. ->field('id,workerid,title,status')
  243. ->where('workerid', $workerid)
  244. ->where('id', $id)
  245. ->find();
  246. if ($data['status'] == 1) {
  247. $data['status_text'] = '待修改';
  248. } elseif ($data['status'] == 2) {
  249. $data['status_text'] = '待审核';
  250. } elseif ($data['status'] == 3) {
  251. $data['status_text'] = '已上架';
  252. } elseif ($data['status'] == 4) {
  253. $data['status_text'] = '已停招';
  254. } elseif ($data['status'] == 5) {
  255. $data['status_text'] = '已下架';
  256. } elseif ($data['status'] == 6) {
  257. $data['status_text'] = '已删除';
  258. }
  259. return view('demand/editdemandstatus', [
  260. 'data' => $data,
  261. ]);
  262. }
  263. }
  264. public function editDemand()
  265. {
  266. $id = input('id/d', 0);
  267. $workerid = $this->access_worker['id'];
  268. $user = UserModel::findOrEmpty($this->access_worker['userid']);
  269. $param = ParamModel::where(1)->findOrEmpty();
  270. if ($user->isEmpty()) {
  271. exit(json_encode([
  272. 'code' => 1,
  273. 'msg' => "用户信息不存在",
  274. ]));
  275. }
  276. $wtype = input('wtype/d', 1);
  277. $type = input('type/d', 1);
  278. $zwagall = $wtype == 1 ? input('zwagall/s', "") : '';
  279. $data = [
  280. 'workerid' => $workerid,
  281. 'title' => input('title/s', ""),
  282. 'num' => input('num/d', 1),
  283. 'cateid' => input('cateid/d', 0),
  284. 'province' => input('province/s', ""),
  285. 'city' => input('city/s', ""),
  286. 'district' => input('district/s', ""),
  287. 'agegroup' => input('agegroup/s', ""),
  288. 'tags' => input('tags/a', []),
  289. 'enddate' => input('enddate/s', ""),
  290. 'requirement' => input('requirement/s', ""),
  291. 'comdetails' => input('comdetails/s', ""),
  292. 'picall' => input('picall/a', []),
  293. 'wtype' => $wtype,
  294. 'type' => $type,
  295. 'bwagall' => input('bwagall/s', ""),
  296. 'zwagall' => $zwagall,
  297. 'ftype' => input('ftype/d', 1),
  298. 'fwagall' => input('fwagall/s', ""),
  299. 'telephone' => input('telephone/s', ""),
  300. 'remark' => input('remark/s', ""),
  301. 'isfree' => 1,
  302. ];
  303. try {
  304. validate(DemandValidate::class)->check($data);
  305. } catch (ValidateException $e) {
  306. exit(json_encode([
  307. 'code' => 1,
  308. 'msg' => $e->getError(),
  309. ]));
  310. }
  311. if (empty($id)) {
  312. if ($this->access_worker['status'] == 1) {
  313. $is_released = is_released($workerid);
  314. if ($is_released['code'] == 1001) {
  315. return $is_released;
  316. }
  317. } else {
  318. if ($user->integral < $param->adddemand) {
  319. page_result1(1, "每次发布订单信息需要扣除" . $param->adddemand . "积分,你当前积分不足。");
  320. }
  321. }
  322. $data['video'] = input('new_video/s', "");
  323. $data['updatetime'] = time();
  324. $data['createtime'] = time();
  325. $data['status'] = (int)2;
  326. $data['volume'] = 0;
  327. $data['telearr'] = [];
  328. $demand = DemandModel::create($data);
  329. $intdata = [
  330. 'userid' => $user->id,
  331. 'title' => "发布订单信息扣除",
  332. 'intvalue' => 0 - $param->adddemand,
  333. 'intmoney' => 0.00,
  334. 'onlycontent' => "",
  335. 'remark' => input('title/s', ""),
  336. 'itype' => 4,
  337. 'createtime' => date("Y-m-d H:i:s"),
  338. 'yeartime' => date("Y"),
  339. 'monthtime' => date("Ym"),
  340. ];
  341. UserIntegralModel::create($intdata);
  342. $integral = intval($user->integral) - intval($param->adddemand);
  343. $user->save([
  344. 'integral' => $integral,
  345. ]);
  346. } else {
  347. $old_video = input('old_video/s', '');
  348. $new_video = input('new_video/s', '');
  349. if (!empty($new_video)) {
  350. $data['video'] = $new_video;
  351. } else {
  352. if (!empty($old_video)) {
  353. $data['video'] = $old_video;
  354. }
  355. }
  356. $data['createtime'] = time();
  357. $data['status'] = input('status/d', 0);
  358. $demand = DemandModel::find($id);
  359. DemandLogModel::update(['workerid' => input('workerid/d', 0)], ['demandid' => $demand->id]);
  360. $demand->save($data);
  361. }
  362. exit(json_encode([
  363. 'code' => 0,
  364. ]));
  365. }
  366. public function editdemandformWyd()
  367. {
  368. $id = input('id/d', 0);
  369. $workerid = $this->access_worker['id'];
  370. $user = UserModel::findOrEmpty($this->access_worker['userid']);
  371. $param = ParamModel::where(1)->findOrEmpty();
  372. if ($user->isEmpty()) {
  373. exit(json_encode([
  374. 'code' => 1,
  375. 'msg' => "用户信息不存在",
  376. ]));
  377. }
  378. $wtype = input('wtype/d', 1);
  379. $zwagall = $wtype == 1 ? input('zwagall/s', "") : '';
  380. $data = [
  381. 'workerid' => $workerid,
  382. 'title' => input('title/s', ""),
  383. 'cateid' => input('cateid/d', 0),
  384. 'province' => input('province/s', ""),
  385. 'city' => input('city/s', ""),
  386. 'district' => input('district/s', ""),
  387. 'agegroup' => input('agegroup/s', ""),
  388. 'tags' => input('tags/a', []),
  389. 'enddate' => input('enddate/s', ""),
  390. 'requirement' => input('requirement/s', ""),
  391. 'comdetails' => input('comdetails/s', ""),
  392. 'wtype' => $wtype,
  393. 'bwagall' => input('bwagall/s', ""),
  394. 'zwagall' => $zwagall,
  395. 'ftype' => input('ftype/d', 1),
  396. 'fwagall' => input('fwagall/s', ""),
  397. 'telephone' => input('telephone/s', ""),
  398. 'remark' => input('remark/s', ""),
  399. 'isfree' => 2,
  400. ];
  401. try {
  402. validate(DemandValidate::class)->check($data);
  403. } catch (ValidateException $e) {
  404. exit(json_encode([
  405. 'code' => 1,
  406. 'msg' => $e->getError(),
  407. ]));
  408. }
  409. if (empty($id)) {
  410. if ($this->access_worker['status'] == 1) {
  411. $is_released = is_released($workerid);
  412. if ($is_released['code'] == 1001) {
  413. return $is_released;
  414. }
  415. } else {
  416. if ($user->integral < $param->adddemandwyd) {
  417. page_result1(1, "每次发布悬赏单需要扣除" . $param->adddemandwyd . "积分,你当前积分不足。");
  418. }
  419. }
  420. $data['video'] = input('new_video/s', "");
  421. $data['updatetime'] = time();
  422. $data['createtime'] = time();
  423. $data['status'] = (int)2;
  424. $data['volume'] = 0;
  425. $data['telearr'] = [];
  426. $demand = DemandModel::create($data);
  427. $intdata = [
  428. 'userid' => $user->id,
  429. 'title' => "发布悬赏单扣除",
  430. 'intvalue' => 0 - $param->adddemandwyd,
  431. 'intmoney' => 0.00,
  432. 'onlycontent' => "",
  433. 'remark' => input('title/s', ""),
  434. 'itype' => 4,
  435. 'createtime' => date("Y-m-d H:i:s"),
  436. 'yeartime' => date("Y"),
  437. 'monthtime' => date("Ym"),
  438. ];
  439. UserIntegralModel::create($intdata);
  440. $integral = intval($user->integral) - intval($param->adddemandwyd);
  441. $user->save([
  442. 'integral' => $integral,
  443. ]);
  444. } else {
  445. $data['updatetime'] = time();
  446. $data['status'] = input('status/d', 0);
  447. $old_video = input('old_video/s', '');
  448. $new_video = input('new_video/s', '');
  449. if (!empty($new_video)) {
  450. $data['video'] = $new_video;
  451. } else {
  452. if (!empty($old_video)) {
  453. $data['video'] = $old_video;
  454. }
  455. }
  456. $demand = DemandModel::find($id);
  457. DemandLogModel::update(['workerid' => input('workerid/d', 0)], ['demandid' => $demand->id]);
  458. $demand->save($data);
  459. }
  460. exit(json_encode([
  461. 'code' => 0,
  462. ]));
  463. }
  464. public function fieldDemand()
  465. {
  466. $id = input('id/d', 0);
  467. $demand = DemandModel::findOrEmpty($id);
  468. if ($demand->isEmpty()) {
  469. exit(json_encode([
  470. 'code' => 1,
  471. 'msg' => "信息不存在",
  472. ]));
  473. } else {
  474. $demand->save([
  475. 'telephone' => input('value'),
  476. ]);
  477. }
  478. exit(json_encode([
  479. 'code' => 0,
  480. ]));
  481. }
  482. public function delDemand()
  483. {
  484. $workerid = $this->access_worker['id'];
  485. $idarr = input('idarr/a');
  486. $res = Db::name('demand')
  487. ->where(['workerid' => $workerid])
  488. ->whereIn('id', $idarr)
  489. ->update(['status' => 6]);
  490. if ($res) {
  491. exit(json_encode([
  492. 'code' => 0,
  493. 'msg' => "",
  494. ]));
  495. }
  496. exit(json_encode([
  497. 'code' => 1,
  498. 'msg' => "删除失败,请稍后重试",
  499. ]));
  500. }
  501. public function listDemand()
  502. {
  503. $limit = input('limit/d', 20);
  504. $page = input('page/d', 1);
  505. $map = [];
  506. $keywords = input('keywords/s', "");
  507. if (!empty($keywords)) {
  508. $map[] = ['title', 'like', '%' . $keywords . '%'];
  509. }
  510. $workerid = input('workerid/d', 0);
  511. if (!empty($workerid)) {
  512. $map[] = ['workerid', '=', $workerid];
  513. }
  514. $cateid = input('cateid/d', 0);
  515. if (!empty($cateid)) {
  516. $map[] = ['cateid', '=', $cateid];
  517. }
  518. $wtype = input('wtype/d');
  519. if (!empty($wtype)) {
  520. $map[] = ['wtype', '=', $wtype];
  521. }
  522. $ftype = input('ftype/d');
  523. if (!empty($ftype)) {
  524. $map[] = ['ftype', '=', $ftype];
  525. }
  526. $status = input('status/d');
  527. if (!empty($status)) {
  528. $map[] = ['status', '=', $status];
  529. }
  530. $isfree = input('isfree/d', 0);
  531. if (!empty($isfree)) {
  532. $map[] = ['isfree', '=', $isfree];
  533. }
  534. $list = DemandModel::with(['worker', 'demandCate'])
  535. ->withCount(['demandLog'])
  536. ->where($map)
  537. ->order(['priority' => 'desc', 'id' => 'desc',])
  538. ->limit($limit)
  539. ->page($page)
  540. ->append(['wtype_text', 'ftype_text', 'status_text', 'isfree_text'])
  541. ->select();
  542. $count = DemandModel::where($map)->count();
  543. if ($count == 0) {
  544. exit(json_encode([
  545. 'code' => 1,
  546. 'msg' => "未查询到数据",
  547. ]));
  548. }
  549. exit(json_encode([
  550. 'code' => 0,
  551. 'msg' => "",
  552. 'count' => $count,
  553. 'data' => $list,
  554. ]));
  555. }
  556. // 企业招聘
  557. public function otherList()
  558. {
  559. if (Request::isAjax()) {
  560. $limit = input('limit/d', 20);
  561. $page = input('page/d', 1);
  562. $map = [];
  563. $workerid = $this->access_worker['id'];
  564. $map[] = ['workerid', '=', $workerid];
  565. $title = input('title/s', "");
  566. if (!empty($title)) {
  567. $map[] = ['title', 'like', '%' . $title . '%'];
  568. }
  569. $keywords = input('keywords/s', "");
  570. if (!empty($keywords)) {
  571. $map[] = ['company_name|company_contact|company_mobile', 'like', '%' . $keywords . '%'];
  572. }
  573. $cateid = input('cateid/d', 0);
  574. if (!empty($cateid)) {
  575. $map[] = ['cateid', '=', $cateid];
  576. }
  577. $wtype = input('wtype/d');
  578. if (!empty($wtype)) {
  579. $map[] = ['wtype', '=', $wtype];
  580. }
  581. $ftype = input('ftype/d');
  582. if (!empty($ftype)) {
  583. $map[] = ['ftype', '=', $ftype];
  584. }
  585. $status = input('status/d');
  586. if (!empty($status)) {
  587. $map[] = ['status', '=', $status];
  588. } else {
  589. $map[] = ['status', '<', 6];
  590. }
  591. $isfree = input('isfree/d', 0);
  592. if (!empty($isfree)) {
  593. $map[] = ['isfree', '=', $isfree];
  594. }
  595. $list = DemandOtherModel::with(['worker', 'demandCate'])
  596. ->where($map)
  597. ->order(['priority' => 'desc', 'id' => 'desc',])
  598. ->limit($limit)
  599. ->page($page)
  600. ->append(['wtype_text', 'ftype_text', 'status_text', 'isfree_text'])
  601. ->select();
  602. $count = DemandOtherModel::where($map)->count();
  603. if ($count == 0) {
  604. exit(json_encode([
  605. 'code' => 1,
  606. 'msg' => "未查询到数据",
  607. ]));
  608. }
  609. exit(json_encode([
  610. 'code' => 0,
  611. 'msg' => "",
  612. 'count' => $count,
  613. 'data' => $list,
  614. ]));
  615. } else {
  616. $catelist = DemandCateModel::order(['priority' => 'desc', 'id' => 'desc'])->select();
  617. $param = ParamModel::where(1)->findOrEmpty();
  618. $access_worker = Session::get('access_worker');
  619. return view('demand/otherlist', [
  620. 'param' => $param,
  621. 'catelist' => $catelist,
  622. 'wtype' => $access_worker['wtype'],
  623. ]);
  624. }
  625. }
  626. public function otherForm()
  627. {
  628. $worker_data = Session::get('access_worker');
  629. $id = input('id/d, 0');
  630. $demand = DemandOtherModel::where('workerid', $worker_data['id'])->findOrEmpty($id);
  631. $catelist = DemandCateModel::order(['priority' => 'desc', 'id' => 'desc'])->select();
  632. return view('demand/otherform', [
  633. 'catelist' => $catelist,
  634. 'demand' => $demand,
  635. 'title' => $worker_data['title'],
  636. ]);
  637. }
  638. public function editOther()
  639. {
  640. $worker_data = Session::get('access_worker');
  641. $id = input('id/d', 0);
  642. $wtype = input('wtype/d', 1);
  643. $type = input('type/d', 1);
  644. $zwagall = $wtype == 1 ? input('zwagall/s', "") : '';
  645. $data = [
  646. 'workerid' => input('workerid/d', 0),
  647. 'title' => input('title/s', ""),
  648. 'cateid' => input('cateid/d', 0),
  649. 'province' => input('province/s', ""),
  650. 'city' => input('city/s', ""),
  651. 'district' => input('district/s', ""),
  652. 'agegroup' => input('agegroup/s', ""),
  653. 'tags' => input('tags/a', []),
  654. 'enddate' => input('enddate/s', ""),
  655. 'requirement' => input('requirement/s', ""),
  656. 'comdetails' => input('comdetails/s', ""),
  657. 'type' => $type,
  658. 'wtype' => $wtype,
  659. 'bwagall' => input('bwagall/s', ""),
  660. 'zwagall' => $zwagall,
  661. 'ftype' => input('ftype/d', 1),
  662. 'fwagall' => input('fwagall/s', ""),
  663. 'telephone' => input('telephone/s', ""),
  664. 'remark' => input('remark/s', ""),
  665. 'status' => input('status/d', 1),
  666. 'isfree' => input('isfree/d', 1),
  667. 'priority' => input('priority/d', 0),
  668. 'updatetime' => input('updatetime/s', ""),
  669. 'createtime' => input('createtime/s', ""),
  670. 'volume' => input('volume/d', 0),
  671. 'company_name' => input('remark/s', ""),
  672. 'company_contact' => input('remark/s', ""),
  673. 'company_mobile' => input('remark/s', ""),
  674. ];
  675. try {
  676. validate(DemandValidate::class)->check($data);
  677. } catch (ValidateException $e) {
  678. exit(json_encode([
  679. 'code' => 1,
  680. 'msg' => $e->getError(),
  681. ]));
  682. }
  683. if (empty($id)) {
  684. $data['workerid'] = $worker_data['id'];
  685. $data['telearr'] = [];
  686. $data['video'] = input('new_video/s', "");
  687. DemandOtherModel::create($data);
  688. } else {
  689. $old_video = input('old_video/s', '');
  690. $new_video = input('new_video/s', '');
  691. if (!empty($new_video)) {
  692. $data['video'] = $new_video;
  693. } else {
  694. if (!empty($old_video)) {
  695. $data['video'] = $old_video;
  696. }
  697. }
  698. $demand = DemandOtherModel::find($id);
  699. $demand->save($data);
  700. }
  701. exit(json_encode([
  702. 'code' => 0,
  703. ]));
  704. }
  705. // 企业招聘
  706. public function allhall()
  707. {
  708. if (Request::isAjax()) {
  709. $limit = input('limit/d', 20);
  710. $page = input('page/d', 1);
  711. $map = [];
  712. $map[] = ['status', '=', 3];
  713. $keywords = input('keywords/s', "");
  714. if (!empty($keywords)) {
  715. $map[] = ['title', 'like', '%' . $keywords . '%'];
  716. }
  717. $cateid = input('cateid/d', 0);
  718. if (!empty($cateid)) {
  719. $map[] = ['cateid', '=', $cateid];
  720. }
  721. $wtype = input('wtype/d');
  722. if (!empty($wtype)) {
  723. $map[] = ['wtype', '=', $wtype];
  724. }
  725. $ftype = input('ftype/d');
  726. if (!empty($ftype)) {
  727. $map[] = ['ftype', '=', $ftype];
  728. }
  729. $isfree = input('isfree/d', 0);
  730. if (!empty($isfree)) {
  731. $map[] = ['isfree', '=', $isfree];
  732. }
  733. $list = DemandModel::with(['worker', 'demandCate'])
  734. ->withCount(['demandLog'])
  735. ->where($map)
  736. ->order(['priority' => 'desc', 'id' => 'desc',])
  737. ->limit($limit)
  738. ->page($page)
  739. ->append(['wtype_text', 'ftype_text', 'status_text', 'isfree_text'])
  740. ->select();
  741. $count = DemandModel::where($map)->count();
  742. if ($count == 0) {
  743. exit(json_encode([
  744. 'code' => 1,
  745. 'msg' => "未查询到数据",
  746. ]));
  747. }
  748. exit(json_encode([
  749. 'code' => 0,
  750. 'msg' => "",
  751. 'count' => $count,
  752. 'data' => $list,
  753. ]));
  754. } else {
  755. $catelist = DemandCateModel::order(['priority' => 'desc', 'id' => 'desc'])->select();
  756. $param = ParamModel::where(1)->findOrEmpty();
  757. return view('demand/allhall', [
  758. 'param' => $param,
  759. 'catelist' => $catelist,
  760. ]);
  761. }
  762. }
  763. public function snatchDemand()
  764. {
  765. $id = input('id/d', 0);
  766. if (empty($id)) {
  767. exit(json_encode([
  768. 'code' => 1,
  769. 'msg' => "未查询到数据",
  770. ]));
  771. }
  772. if (Request::isAjax()) {
  773. //数据校验
  774. $num = input('num/d', 0);
  775. if ($num <= 0) {
  776. exit(json_encode([
  777. 'code' => 1,
  778. 'msg' => "抢单人数必须大于等于0",
  779. ]));
  780. }
  781. $demand = DemandModel::findOrEmpty($id);
  782. if (empty($demand)) {
  783. exit(json_encode([
  784. 'code' => 1,
  785. 'msg' => "订单不存在 ",
  786. ]));
  787. }
  788. $total = DemandSnatchModel::where('status', '>', 1)->where('demand_id', $id)->sum('num');
  789. $remain = $demand['num'] - $total;
  790. if ($demand['num'] - $total < $num) {
  791. exit(json_encode([
  792. 'code' => 1,
  793. 'msg' => "订单剩余{$remain}人,请输入该人数以下的值",
  794. ]));
  795. }
  796. //抢单
  797. $worker_data = Session::get('access_worker');
  798. DemandSnatchModel::create([
  799. 'demand_id' => $id,
  800. 'worker_id' => $worker_data['id'],
  801. 'num' => $num,
  802. 'status' => 1,
  803. 'createtime' => date("Y-m-d H:i:s"),
  804. ]);
  805. exit(json_encode(['code' => 0]));
  806. } else {
  807. return view('demand/snatchDemand', [
  808. 'id' => $id,
  809. ]);
  810. }
  811. }
  812. public function roblist()
  813. {
  814. if (Request::isAjax()) {
  815. $limit = input('limit/d', 20);
  816. $page = input('page/d', 1);
  817. $worker_data = Session::get('access_worker');
  818. $map = [['worker_id', '=', $worker_data['id']]];
  819. $status = input('status/d', 0);
  820. if (!empty($status)) {
  821. $map[] = ['status', '=', $status];
  822. }
  823. $list = DemandSnatchModel::with(['demand', 'demand.worker'])
  824. ->where($map)
  825. ->order(['id' => 'desc'])
  826. ->limit($limit)
  827. ->page($page)
  828. ->append(['status_text'])
  829. ->select();
  830. $count = DemandSnatchModel::where($map)->count();
  831. if ($count == 0) {
  832. exit(json_encode([
  833. 'code' => 1,
  834. 'msg' => "未查询到数据",
  835. ]));
  836. }
  837. exit(json_encode([
  838. 'code' => 0,
  839. 'msg' => "",
  840. 'count' => $count,
  841. 'data' => $list,
  842. ]));
  843. } else {
  844. return view('demand/roblist');
  845. }
  846. }
  847. public function demandDetail()
  848. {
  849. $id = input('id/d, 0');
  850. if (empty($id)) {
  851. return '未查询到数据';
  852. }
  853. $demand = DemandModel::with(['worker', 'demand_cate'])->findOrEmpty($id);
  854. if ($demand->isEmpty()) {
  855. return '未查询到数据';
  856. }
  857. $typelist = [1 => '代招', 2 => '劳务派遣'];
  858. $wtypelist = [1 => '按月', 2 => '按时', 3 => '按件', 4 => '按项目', 5 => '其他'];
  859. $ftypelist = [1 => '一次性', 2 => '小时工', 3 => '管理费', 4 => '其他'];
  860. $statuslist = [1 => '待修改', 2 => '待审核', 3 => '已上架', 4 => '已停招', 5 => '已下架'];
  861. return view('demand/demanddetail', [
  862. 'demand' => $demand,
  863. 'typelist' => $typelist,
  864. 'wtypelist' => $wtypelist,
  865. 'ftypelist' => $ftypelist,
  866. 'statuslist' => $statuslist,
  867. ]);
  868. }
  869. public function report()
  870. {
  871. $id = input('id/d', 0);
  872. if (empty($id)) {
  873. return '未查询到数据';
  874. }
  875. if (Request::isAjax()) {
  876. //订单信息
  877. $snatch = DemandSnatchModel::with('demand')->find($id);
  878. if (empty($snatch)) {
  879. exit(json_encode([
  880. 'code' => 1,
  881. 'msg' => "订单不存在",
  882. ]));
  883. }
  884. $snatch_num = DemandReportModel::where('snatchid', $id)->count();
  885. if ($snatch_num >= $snatch['num']) {
  886. exit(json_encode([
  887. 'code' => 1,
  888. 'msg' => "人数已满",
  889. ]));
  890. }
  891. $mobile = input('mobile/s', '');
  892. $idcard = input('idcard/s', '');
  893. $check = DemandReportModel::where('snatchid',$id)->where('mobile',$mobile)->whereOr('idcard',$idcard)->find();
  894. if (!empty($check)) {
  895. exit(json_encode([
  896. 'code' => 1,
  897. 'msg' => "该手机号或身份证号已报备,请勿重复",
  898. ]));
  899. }
  900. DemandReportModel::create([
  901. 'demandid' => $snatch['demand_id'],
  902. 'snatchid' => $id,
  903. 'workerid' => $snatch['demand']['workerid'],
  904. 'realname' => input('realname/s', ''),
  905. 'mobile' => $mobile,
  906. 'idcard' => $idcard,
  907. 'arrivetime' => input('arrivetime/s', ''),
  908. 'remark' => input('remark/s', ''),
  909. 'createtime' => time(),
  910. ]);
  911. exit(json_encode(['code' => 0]));
  912. } else {
  913. return view('demand/report', [
  914. 'id' => $id,
  915. ]);
  916. }
  917. }
  918. public function reportLog()
  919. {
  920. $id = input('id/d', 0);
  921. if (empty($id)) {
  922. return '未查询到数据';
  923. }
  924. if (Request::isAjax()) {
  925. //订单信息
  926. $snatch = DemandSnatchModel::with('demand')->find($id);
  927. if (empty($snatch)) {
  928. exit(json_encode([
  929. 'code' => 1,
  930. 'msg' => "订单不存在",
  931. ]));
  932. }
  933. $snatch_num = DemandReportModel::where('snatchid', $id)->count();
  934. if ($snatch_num >= $snatch['num']) {
  935. exit(json_encode([
  936. 'code' => 1,
  937. 'msg' => "人数已满",
  938. ]));
  939. }
  940. $mobile = input('mobile/s', '');
  941. $idcard = input('idcard/s', '');
  942. $check = DemandReportModel::where('snatchid',$id)->where('mobile',$mobile)->whereOr('idcard',$idcard)->find();
  943. if (!empty($check)) {
  944. exit(json_encode([
  945. 'code' => 1,
  946. 'msg' => "该手机号或身份证号已报备,请勿重复",
  947. ]));
  948. }
  949. DemandReportModel::create([
  950. 'demandid' => $snatch['demand_id'],
  951. 'snatchid' => $id,
  952. 'workerid' => $snatch['demand']['workerid'],
  953. 'realname' => input('realname/s', ''),
  954. 'mobile' => $mobile,
  955. 'idcard' => $idcard,
  956. 'arrivetime' => input('arrivetime/s', ''),
  957. 'remark' => input('remark/s', ''),
  958. 'createtime' => time(),
  959. ]);
  960. exit(json_encode(['code' => 0]));
  961. } else {
  962. return view('demand/reportlog', [
  963. 'id' => $id,
  964. ]);
  965. }
  966. }
  967. }