JobsService.php 148 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: michaelwu
  5. * Date: 2018/10/30
  6. * Time: 11:22
  7. */
  8. namespace App\Services\Company;
  9. use App\Exceptions\ResponseException;
  10. use App\Models\Company;
  11. use App\Models\Jobs;
  12. use App\Models\Payment;
  13. use App\Models\SubsiteJob;
  14. use App\Repositories\AuditReasonsRepository;
  15. use App\Repositories\CompanyRepository;
  16. use App\Repositories\CompanyStatisticsRepository;
  17. use App\Repositories\Jobfair\JobfairJobRepository;
  18. use App\Repositories\Jobfair\JobfairJobsContactRepository;
  19. use App\Repositories\JobsContactRepository;
  20. use App\Repositories\JobsRepository;
  21. use App\Repositories\MemberHandselRepository;
  22. use App\Repositories\MemberLogRepository;
  23. use App\Repositories\MemberPointRepository;
  24. use App\Repositories\MemberSetmealRepository;
  25. use App\Repositories\MembersSetmealLogRepository;
  26. use App\Repositories\OrderRepository;
  27. use App\Repositories\PersonalJobsApplyRepository;
  28. use App\Repositories\QueueAutoRefreshRepository;
  29. use App\Repositories\RefreshLogRepository;
  30. use App\Repositories\SetmealRepository;
  31. use App\Repositories\SubsiteJobRepository;
  32. use Exception;
  33. use Illuminate\Http\JsonResponse;
  34. use Illuminate\Support\Facades\DB;
  35. use Illuminate\Support\Facades\Cache;
  36. use App\Repositories\CategoryRepository;
  37. use App\Repositories\CategoryJobsRepository;
  38. use App\Repositories\CategoryDistrictRepository;
  39. use App\Repositories\ResumeRepository;
  40. use App\Repositories\ViewJobRepository;
  41. use App\Repositories\PersonFavoriteRepository;
  42. use App\Services\Common\PaymentService;
  43. use App\Services\Common\OrderService;
  44. use App\Services\Common\PayService;
  45. use App\Services\Company\ServiceService;
  46. use Aix\Pay\Data\PayOrder;
  47. use App\Repositories\ResumePrivacyRepository;
  48. use Illuminate\Support\MessageBag;
  49. class JobsService
  50. {
  51. protected $jobsRepository;
  52. protected $jobsContactRepository;
  53. protected $companyRepository;
  54. protected $membersSetmealRepository;
  55. protected $personalJobsApplyRepository;
  56. protected $auditReasonsRepository;
  57. protected $refreshLogRepository;
  58. protected $memberPointRepository;
  59. protected $setmealRepository;
  60. protected $jobsSearchRepository;
  61. protected $memberHandselRepository;
  62. protected $membersSetmealLogRepository;
  63. protected $app_spell = true;
  64. protected $categoryRepository;
  65. protected $categoryJobsRepository;
  66. protected $categoryDistrictRepository;
  67. protected $resumeRepository;
  68. protected $viewJobRepository;
  69. protected $personFavoriteRepository;
  70. protected $queueAutoRefreshRepository;
  71. protected $orderRepository;
  72. protected $companyStatisticsRepository;
  73. protected $jobfairJobRepository;
  74. protected $jobfairJobsContactRepository;
  75. protected $subsiteJobRepository;
  76. protected $paymentService;
  77. protected $orderService;
  78. protected $payService;
  79. protected $serviceService;
  80. protected $ResumePrivacyRepository;
  81. protected $memberLogRepository;
  82. /**
  83. * JobsService constructor.
  84. * @param $jobsRepository
  85. * @param $jobsContactRepository
  86. * @param $companyRepository
  87. * @param $memberSetmealRepository
  88. * @param $personalJobsApplyRepository
  89. * @param $auditReasonsRepository
  90. * @param $refreshLogRepository
  91. * @param $memberPointRepository
  92. * @param $setmealRepository
  93. * @param $memberHandselRepository
  94. * @param $membersSetmealLogRepository
  95. * @param $queueAutoRefreshRepository
  96. * @param $orderRepository
  97. * @param $companyStatisticsRepository
  98. * @param $subsiteJobRepository
  99. * @param $jobfairJobRepository
  100. * @param $jobfairJobsContactRepository
  101. * @param $ResumePrivacyRepository
  102. */
  103. public function __construct(
  104. JobsRepository $jobsRepository,
  105. ServiceService $serviceService,
  106. PayService $payService,
  107. SubsiteJobRepository $subsiteJobRepository,
  108. JobfairJobsContactRepository $jobfairJobsContactRepository,
  109. JobfairJobRepository $jobfairJobRepository,
  110. CompanyStatisticsRepository $companyStatisticsRepository,
  111. OrderRepository $orderRepository,
  112. QueueAutoRefreshRepository $queueAutoRefreshRepository,
  113. SetmealRepository $setmealRepository,
  114. MemberPointRepository $memberPointRepository,
  115. JobsContactRepository $jobsContactRepository,
  116. CompanyRepository $companyRepository,
  117. MemberSetmealRepository $memberSetmealRepository,
  118. PersonalJobsApplyRepository $personalJobsApplyRepository,
  119. AuditReasonsRepository $auditReasonsRepository,
  120. RefreshLogRepository $refreshLogRepository,
  121. CategoryRepository $categoryRepository,
  122. CategoryJobsRepository $categoryJobsRepository,
  123. CategoryDistrictRepository $categoryDistrictRepository,
  124. ResumeRepository $resumeRepository,
  125. ViewJobRepository $viewJobRepository,
  126. PersonFavoriteRepository $personFavoriteRepository,
  127. MembersSetmealLogRepository $membersSetmealLogRepository,
  128. MemberHandselRepository $memberHandselRepository,
  129. PaymentService $paymentService,
  130. OrderService $orderService,
  131. ResumePrivacyRepository $ResumePrivacyRepository,
  132. MemberLogRepository $memberLogRepository
  133. ) {
  134. $this->jobsRepository = $jobsRepository;
  135. $this->jobsContactRepository = $jobsContactRepository;
  136. $this->companyRepository = $companyRepository;
  137. $this->membersSetmealRepository = $memberSetmealRepository;
  138. $this->personalJobsApplyRepository = $personalJobsApplyRepository;
  139. $this->auditReasonsRepository = $auditReasonsRepository;
  140. $this->refreshLogRepository = $refreshLogRepository;
  141. $this->memberPointRepository = $memberPointRepository;
  142. $this->setmealRepository = $setmealRepository;
  143. $this->memberHandselRepository = $memberHandselRepository;
  144. $this->membersSetmealLogRepository = $membersSetmealLogRepository;
  145. $this->categoryRepository = $categoryRepository;
  146. $this->categoryJobsRepository = $categoryJobsRepository;
  147. $this->categoryDistrictRepository = $categoryDistrictRepository;
  148. $this->resumeRepository = $resumeRepository;
  149. $this->viewJobRepository = $viewJobRepository;
  150. $this->personFavoriteRepository = $personFavoriteRepository;
  151. $this->queueAutoRefreshRepository = $queueAutoRefreshRepository;
  152. $this->orderRepository = $orderRepository;
  153. $this->companyStatisticsRepository = $companyStatisticsRepository;
  154. $this->jobfairJobRepository = $jobfairJobRepository;
  155. $this->jobfairJobsContactRepository = $jobfairJobsContactRepository;
  156. $this->subsiteJobRepository = $subsiteJobRepository;
  157. $this->paymentService = $paymentService;
  158. $this->orderService = $orderService;
  159. $this->payService = $payService;
  160. $this->serviceService = $serviceService;
  161. $this->ResumePrivacyRepository = $ResumePrivacyRepository;
  162. $this->memberLogRepository=$memberLogRepository;
  163. }
  164. /**
  165. * 职位管理
  166. * @param $type
  167. * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
  168. */
  169. public function list($type, $user)
  170. {
  171. $where = [];
  172. $orwhere = [];
  173. $where['company_id'] =$user->id;
  174. if ($type == 1) {
  175. $where['display'] = 1;
  176. if (config('aix.companyset.comset.show_set.jobs_display') == 2) {
  177. $where[] = ['audit', '<>', 3];
  178. } else {
  179. $where['audit'] = 1;
  180. }
  181. $where['valid'] = 1;
  182. } elseif ($type == 2) {
  183. $orwhere[] = 2; //显示状态
  184. $orwhere[] = 0; //是否有效
  185. $orwhere[] = 1; //审核状态
  186. if (config('aix.companyset.comset.show_set.jobs_display') == 2) {
  187. $orwhere[] = 2;
  188. }
  189. }
  190. $page = 5;
  191. $jobs_list = $this->jobsRepository->list($page, $where, $orwhere);
  192. //获取职位分类信息
  193. $job_cates = $this->categoryJobsRepository->getJobCategories();
  194. foreach ($jobs_list as $key => $val) {
  195. $jobs_list[$key]->jobcategory = '';
  196. if ($job_cates) {
  197. if ($val->subclass) {
  198. if (array_has($job_cates, $val->category) && array_has($job_cates[$val->category], $val->subclass)) {
  199. $jobs_list[$key]->jobcategory = $job_cates[$val->category][$val->subclass]['spell'];
  200. } elseif (array_has($job_cates, $val->category)) {
  201. $jobs_list[$key]->jobcategory = $job_cates[$val->topclass][$val->category]['spell'];
  202. } else {
  203. $jobs_list[$key]->jobcategory = '';
  204. }
  205. } else {
  206. if ($val->category && array_has($job_cates, $val->category)) {
  207. $jobs_list[$key]->jobcategory = $job_cates[$val->topclass][$val->category]['spell'];
  208. } else {
  209. $jobs_list[$key]->jobcategory = '';
  210. }
  211. }
  212. }
  213. if (!empty($val->promotion)) {
  214. foreach ($val->promotion as $k => $v) {
  215. if ($v->ptype == 1) {
  216. $jobs_list[$key]->stickDays = 0;
  217. if($v->endtime > time()){
  218. $jobs_list[$key]->stickDays = ceil(($v->endtime-time())/86400);
  219. }
  220. $jobs_list[$key]->stickarr = $v;
  221. }
  222. if ($v->ptype == 2) {
  223. $jobs_list[$key]->emergencyDays = 0;
  224. if($v->endtime > time()){
  225. $jobs_list[$key]->emergencyDays = ceil(($v->endtime-time())/86400);
  226. }
  227. $jobs_list[$key]->emergencyarr = $v;
  228. }
  229. }
  230. }
  231. $val->auto_refresh = 0;
  232. $auto_refresh = $this->queueAutoRefreshRepository->findData(['type'=>1, 'pid'=>$val->id]);
  233. if ($auto_refresh) {
  234. $order_list = $this->orderRepository->findByField(['uid'=>$val->company_id,'order_type'=>12]);
  235. foreach ($order_list as $k => $v) {
  236. $order_params = unserialize($v->params);
  237. if ($order_params['jobs_id']==$val->id) {
  238. $val->auto_refresh = 1;
  239. $val->auto_refresh_starttime = date('Y-m-d', $order_params['starttime']);
  240. $val->auto_refresh_endtime = date('Y-m-d', $order_params['endtime']);
  241. break;
  242. }
  243. }
  244. }
  245. if ($val->audit == 2) {
  246. $val->_audit = config('aix.companyset.comset.show_set.jobs_display') == 2 ? 1 : $val->audit;
  247. } else {
  248. $val->_audit = $val->audit;
  249. }
  250. if ($val->_audit == 2) {
  251. $val->status_cn = '审核中';
  252. } elseif ($val->_audit == 3) {
  253. $val->status_cn = '审核未通过';
  254. $val->reason = $this->auditReasonsRepository->getAuditReasons($val->id, 3);
  255. } elseif ($val->_audit == 1 && $val->audit == 2) {
  256. $val->status_cn = '审核中';
  257. }
  258. if ($val->display == 2 || ($val->deadline > 0 && $val->deadline < time())) {
  259. $val->status_cn = '已关闭';
  260. }
  261. $val->resumeCount = $this->personalJobsApplyRepository->getApplyResume($val->id);
  262. }
  263. return $jobs_list;
  264. }
  265. /**发布职位总数
  266. * @return mixed
  267. */
  268. public function jobsTotal($id)
  269. {
  270. $where['company_id'] = $id;
  271. $where['display'] = 1;
  272. $where['valid'] = 1;
  273. $where[] = ['audit','<>',3];
  274. return $this->jobsRepository->jobsTotal($where);
  275. }
  276. /**
  277. * 根据jobsid获取职位信息
  278. * @param $id
  279. * @return mixed
  280. */
  281. public function jobsInfo($id)
  282. {
  283. return $this->jobsRepository->getJobsById($id);
  284. }
  285. /**
  286. * 职位保存
  287. * @param $request
  288. * @return JsonResponse
  289. * @throws \Prettus\Validator\Exceptions\ValidatorException
  290. */
  291. public function jobsSave($data, $user)
  292. {
  293. $jid = 0;
  294. $iscustomize = $data['iscustomize'];
  295. unset($data['iscustomize']);
  296. //分站关系
  297. if (isset($data['subsite_id'])) {
  298. $subsite_id = $data['subsite_id'];
  299. } else {
  300. $subsite_id = [];
  301. }
  302. $jobsExist=$this->jobsRepository->jobsTotal(['company_id'=>$user->id,'id'=>$data['id']]);
  303. if (empty($jobsExist) && !empty($data['id'])){
  304. return response()->json(['status'=>0, 'msg'=>"没有这个职位"]);
  305. }
  306. unset($data['subsite_id']);
  307. if (isset($data['id']) && $data['id']) {
  308. $jid = $data['id'];
  309. $job_info = $this->jobsRepository->find($jid);
  310. unset($data['id']);
  311. } else {
  312. //查询企业已发布多少职位数
  313. $condition['company_id'] = $user->id;
  314. $condition['display'] = 1;
  315. $condition['valid'] = 1;
  316. $condition[] = ['audit','<>',3];//加入把审核失败的去除
  317. $jobsCount = $this->jobsRepository->jobsTotal($condition);
  318. //查询企业套餐内可发布职位数
  319. $mySetmeal = $this->membersSetmealRepository->getSetmealByUid($user->id, $user->utype);
  320. if (isExpire($mySetmeal)){
  321. return response()->json(['status'=>0, 'msg'=>"提醒:您的套餐已到期,请及时到我的套餐处升级套餐"]);
  322. }
  323. if ($mySetmeal->jobs_meanwhile <= $jobsCount) {
  324. return response()->json(['status'=>0, 'msg'=>"当前显示的职位已经达到最大限制,请升级服务套餐!"]);
  325. }
  326. }
  327. $basis_contact = $data['basis_contact'];
  328. unset($data['basis_contact']);
  329. $jobData = [];
  330. $contactData = [];
  331. foreach ($data as $key => $val) {
  332. if ($key == 'contact') {
  333. $contactData['contact'] = $val;
  334. } elseif ($key == 'telephone') {
  335. $contactData['telephone'] = $val;
  336. } elseif ($key == 'landline_tel') {
  337. if ($jid) {
  338. $contactData['landline_tel'] = $val;
  339. } else {
  340. $list1 = explode('-', $val);
  341. foreach ($list1 as $ke => $vo) {
  342. if ($vo) {
  343. $contactData['landline_tel'][$ke] = $vo;
  344. } else {
  345. $contactData['landline_tel'][$ke] = '';
  346. }
  347. }
  348. }
  349. } elseif ($key == 'email') {
  350. $contactData['email'] = $val;
  351. } elseif ($key == 'address') {
  352. $contactData['address'] = $val;
  353. } elseif ($key == 'telephone_show') {
  354. $contactData['telephone_show'] = $val;
  355. } elseif ($key == 'contact_show') {
  356. $contactData['contact_show'] = $val;
  357. } elseif ($key == 'landline_tel_show') {
  358. $contactData['landline_tel_show'] = $val;
  359. } elseif ($key == 'email_show') {
  360. $contactData['email_show'] = $val;
  361. } elseif ($key == 'notify_mobile') {
  362. $contactData['notify_mobile'] = $val;
  363. } elseif ($key == 'notify') {
  364. $contactData['notify'] = $val;
  365. } else {
  366. if ($key == 'jobcategory') {
  367. $category = explode('.', $val);
  368. $jobData['topclass'] = $category[0];
  369. $jobData['category'] = $category[1];
  370. $jobData['subclass'] = $category[2];
  371. } elseif ($key == 'deadline') {
  372. if ($val) {
  373. $jobData[$key] = time() + ($val * 86400);
  374. } else {
  375. //职位有效期多少天
  376. $job_expire=config('aix.companyset.comset.com_set.job_expire');
  377. $jobData[$key] = time() + $job_expire* 86400;
  378. if($job_expire==0){
  379. $jobData[$key]=0;
  380. }
  381. }
  382. } elseif ($key == 'tag') {
  383. $jobData[$key] = explode(',', $val);
  384. } elseif ($key == 'district') {
  385. $district = getCityInfo($val);
  386. $jobData[$key] = $district['district'];
  387. } else {
  388. $jobData[$key] = $val;
  389. }
  390. }
  391. }
  392. $com_info = $this->companyRepository->getCompanyColumn($user->id, ['*']);
  393. $setmeal = $this->membersSetmealRepository->getSetmealByUid($user->id, $user->utype);
  394. if (!$jid) {
  395. $jobData['audit']= 2;
  396. } else {
  397. if ($com_info['audit']==1) {
  398. $jobData['audit'] = config('aix.companyset.audit.audit_type.audit_verifycom_editjob') == 1?$job_info->audit:2;
  399. } else {
  400. $jobData['audit'] = config('aix.companyset.audit.audit_type.audit_unexaminedcom_editjob')==1?$job_info->audit:2;
  401. }
  402. }
  403. $jobArr = ['map_zoom', 'scale', 'companyname', 'created_at', 'audit','trade','subsite_id'];
  404. foreach ($jobArr as $key => $val) {
  405. if ($val == 'companyname') {
  406. $jobData['company_name'] = $com_info['companyname'];
  407. } elseif ($val == 'created_at') {
  408. $jobData['company_addtime'] = strtotime($com_info['created_at']);
  409. } elseif ($val == 'audit') {
  410. $jobData['company_audit'] = $com_info['audit'];
  411. } else {
  412. $jobData[$val] = $com_info[$val];
  413. }
  414. }
  415. if ($data['wage']==-1) {
  416. $jobData['wage'] = -1;
  417. $jobData['wage_min']=0;
  418. $jobData['wage_max']=0;
  419. } else {
  420. if (intval($data['wage'])==0) {
  421. $jobData['wage'] = 0;
  422. $jobData['wage_min']=$data['wage_min'];
  423. $jobData['wage_max']=$data['wage_max'];
  424. } else {
  425. $wage = explode('~', format_wage(get_category($jobData['wage'])));
  426. $jobData['wage_max'] =0;
  427. if (isset($wage[1])) {
  428. $jobData['wage_max'] =intval($wage[1]);
  429. }
  430. $jobData['wage_min'] =intval($wage[0]);
  431. }
  432. }
  433. // $jobData['syq']=$data['syq'];
  434. // $jobData['syqxz_min']=$data['syqxz_min'];
  435. $jobData['company_id'] = $user->id;
  436. $jobData['robot'] = 0;
  437. $jobData['valid'] = 1;
  438. $jobData['refresh_time'] = time();
  439. $jobData['setmeal_deadline'] = $setmeal->endtime ? strtotime($setmeal->endtime) : 0;
  440. $jobData['setmeal_id'] = $setmeal->setmeal_id;
  441. $jobData['setmeal_name'] = $setmeal->setmeal_name;
  442. if ($basis_contact=='1') {
  443. $contactArr = ['contact', 'telephone', 'landline_tel', 'email', 'address', 'contact_show', 'telephone_show', 'email_show', 'landline_tel_show'];
  444. foreach ($contactArr as $key => $val) {
  445. if ($val == 'telephone') {
  446. $conData[$val] = $com_info['mobile'];
  447. } elseif ($val == 'landline_tel') {
  448. if ($com_info[$val]) {
  449. if ($jid) {
  450. $conData[$val] = $com_info[$val];
  451. } else {
  452. $list = explode('-', $com_info[$val]);
  453. foreach ($list as $ke => $vo) {
  454. if ($vo) {
  455. $conData[$val][$ke] = $vo;
  456. } else {
  457. $conData[$val][$ke] = '';
  458. }
  459. }
  460. }
  461. } else {
  462. $conData[$val] = '';
  463. }
  464. } else {
  465. $conData[$val] = $com_info[$val];
  466. }
  467. }
  468. $jobContactData = $conData;
  469. } else {
  470. $jobContactData = $contactData;
  471. }
  472. $subsite_id[] = $com_info['subsite_id'];
  473. DB::beginTransaction();
  474. try {
  475. if ($jid) {
  476. if (!$this->jobsRepository->update($jobData, $jid)) {
  477. throw new Exception('修改职位失败');
  478. }
  479. //修改分站关系
  480. if ($subsite_id) {
  481. if ($this->subsiteJobRepository->findSubsite($jid)->isNotEmpty()) {
  482. if (!$this->subsiteJobRepository->deleteWhere(['jobs_id'=>$jid])) {
  483. throw new Exception('修改分站关系失败');
  484. }
  485. }
  486. foreach ($subsite_id as $key => $val) {
  487. $sub_data[] = [
  488. 'subsite_id'=>$val,
  489. 'jobs_id'=>$jid,
  490. 'created_at'=>date('Y-m-d H:i:s', time()),
  491. 'updated_at'=>date('Y-m-d H:i:s', time()),
  492. ];
  493. }
  494. if (false == $this->subsiteJobRepository->createData($sub_data)) {
  495. throw new Exception('修改分站关系失败');
  496. }
  497. }
  498. if (false == $this->jobsContactRepository->update($jobContactData, $jid)) {
  499. throw new Exception('修改联系方式失败');
  500. }
  501. event_search_update(Jobs::class, (string)$jid, 'update');
  502. event_search_update(Company::class, (string)$user->id, 'update');
  503. } else {
  504. if (!$job = $this->jobsRepository->store($jobData)) {
  505. throw new Exception('添加职位失败');
  506. }
  507. $jobContactData['job_id'] = $job->id;
  508. if (false == $this->jobsContactRepository->store($jobContactData)) {
  509. throw new Exception('添加联系方式失败');
  510. }
  511. // if (!$this->companyRepository->modifyJobsNum($user->id, 1, 1)) {
  512. // throw new Exception('修改企业职位数失败!');
  513. // }
  514. // if (!$this->membersSetmealRepository->modifyJobsMeanwhile($setmeal->id, 1, 2)) {
  515. // throw new Exception('修改套餐可发布职位数失败!');
  516. // }
  517. //添加分站关系
  518. if ($subsite_id) {
  519. foreach ($subsite_id as $key => $val) {
  520. $sub_data[] = [
  521. 'subsite_id'=>$val,
  522. 'jobs_id'=>$job->id,
  523. 'created_at'=>date('Y-m-d H:i:s', time()),
  524. 'updated_at'=>date('Y-m-d H:i:s', time()),
  525. ];
  526. }
  527. if (false == $this->subsiteJobRepository->createData($sub_data)) {
  528. throw new Exception('职位同步至其他分站失败!');
  529. }
  530. }
  531. event_search_update(Jobs::class, (string)$job->id, 'update');
  532. event_search_update(Company::class, (string)$user->id, 'update');
  533. }
  534. DB::commit();
  535. if ($jid) {
  536. $msg = '修改';
  537. $log_type=1003;
  538. } else {
  539. $msg = '添加';
  540. $log_type=1002;
  541. $jid=$job->id;
  542. $total=$setmeal->jobs_meanwhile-$this->jobsRepository->jobsTotal($condition);
  543. $this->membersSetmealLogRepository->createLog($user,"发布了职位{$jobData['jobs_name']}",$total);
  544. }
  545. //写日志
  546. $this->memberLogRepository->createLog($user,$log_type,$jid);
  547. return response()->json(['status' => 1, 'msg' => $msg . "职位成功"]);
  548. } catch (Exception $e) {
  549. DB::rollback();
  550. return response()->json(['status' => 0, 'msg' => $e->getMessage()]);
  551. }
  552. }
  553. /**
  554. * 职位保存
  555. * @param $data
  556. * @param $user
  557. * @return JsonResponse
  558. */
  559. public function jobsSaveMobile($data, $user)
  560. {
  561. $jid = '';
  562. //分站关系
  563. if (isset($data['subsite_id'])) {
  564. $subsite_id = explode(',', $data['subsite_id']);
  565. } else {
  566. $subsite_id = [];
  567. }
  568. unset($data['subsite_id']);
  569. if (isset($data['id']) && $data['id']) {
  570. $jid = $data['id'];
  571. $job_info = $this->jobsRepository->findWhere(['id'=>$jid,'company_id'=>$user->id])->first();
  572. if (empty($job_info)){
  573. return response()->json(['status'=>0, 'msg'=>"无改职位!"]);
  574. }
  575. unset($data['id']);
  576. } else {
  577. //查询企业已发布多少职位数
  578. $condition['display'] = 1;
  579. $condition['valid'] = 1;
  580. $condition['company_id'] = $user->id;
  581. $jobsCount = $this->jobsRepository->jobsTotal($condition);
  582. //查询企业套餐内可发布职位数
  583. $mySetmeal = $this->membersSetmealRepository->getSetmealByUid($user->id, $user->utype);
  584. if (isExpire($mySetmeal)){
  585. return response()->json(['status'=>0, 'msg'=>"提醒:您的套餐已到期,请及时到我的套餐处升级套餐"]);
  586. }
  587. if ($mySetmeal->jobs_meanwhile<=$jobsCount) {
  588. return response()->json(['status'=>0, 'msg'=>"当前显示的职位已经达到最大限制,请升级服务套餐!"]);
  589. }
  590. }
  591. $basis_contact = $data['basis_contact'];
  592. unset($data['basis_contact']);
  593. $jobData = [];
  594. $contactData = [];
  595. foreach ($data as $key => $val) {
  596. if ($key == 'contact') {
  597. $contactData['contact'] = $val;
  598. } elseif ($key == 'telephone') {
  599. $contactData['telephone'] = $val;
  600. } elseif ($key == 'landline_tel') {
  601. if ($jid) {
  602. $contactData['landline_tel'] = $val;
  603. } else {
  604. $list1 = explode('-', $val);
  605. foreach ($list1 as $ke => $vo) {
  606. if ($vo) {
  607. $contactData['landline_tel'][$ke] = $vo;
  608. } else {
  609. $contactData['landline_tel'][$ke] = '';
  610. }
  611. }
  612. }
  613. } elseif ($key == 'email') {
  614. $contactData['email'] = $val;
  615. } elseif ($key == 'address') {
  616. $contactData['address'] = $val;
  617. } elseif ($key == 'telephone_show') {
  618. $contactData['telephone_show'] = $val;
  619. } elseif ($key == 'contact_show') {
  620. $contactData['contact_show'] = $val;
  621. } elseif ($key == 'landline_tel_show') {
  622. $contactData['landline_tel_show'] = $val;
  623. } elseif ($key == 'email_show') {
  624. $contactData['email_show'] = $val;
  625. } elseif ($key == 'notify_mobile') {
  626. $contactData['notify_mobile'] = $val;
  627. } elseif ($key == 'notify') {
  628. $contactData['notify'] = $val;
  629. } else {
  630. if ($key == 'jobcategory') {
  631. $category = explode('.', $val);
  632. $jobData['topclass'] = $category[0];
  633. $jobData['category'] = $category[1];
  634. $jobData['subclass'] = $category[2];
  635. } elseif ($key == 'deadline') {
  636. if ($val) {
  637. $jobData[$key] = time() + ($val * 86400);
  638. } else {
  639. $jobData[$key] = time() + 30 * 86400;
  640. }
  641. } elseif ($key == 'tag') {
  642. $jobData[$key] = explode(',', $val);
  643. } elseif ($key == 'age') {
  644. $jobData[$key] = $val;
  645. } else {
  646. $jobData[$key] = $val;
  647. }
  648. }
  649. }
  650. // if (isset($jobData['syqxz_min']) && $jobData['syqxz_min'] && $jobData['syqxz_min'] < $jobData['wage_min']*0.8 ) {
  651. //
  652. // return response()->json(['status'=>0, 'msg'=>"试用期薪资不得低于正式工资的80%"]);
  653. // }
  654. $com_info = $this->companyRepository->getCompanyColumn($user->id, ['*']);
  655. $setmeal = $this->membersSetmealRepository->getSetmealByUid($user->id, $user->utype);
  656. if (!$jid) {
  657. $jobData['audit']= 2;
  658. } else {
  659. if ($com_info['audit']==1) {
  660. $jobData['audit'] = config('aix.companyset.audit.audit_type.audit_verifycom_editjob') == 1?$job_info->audit:2;
  661. } else {
  662. $jobData['audit'] = config('aix.companyset.audit.audit_type.audit_unexaminedcom_editjob')==1?$job_info['audit']:2;
  663. }
  664. }
  665. $jobArr = ['map_zoom', 'scale', 'companyname', 'created_at', 'audit','trade','subsite_id'];
  666. foreach ($jobArr as $key => $val) {
  667. if ($val == 'companyname') {
  668. $jobData['company_name'] = $com_info['companyname'];
  669. } elseif ($val == 'created_at') {
  670. $jobData['company_addtime'] = strtotime($com_info['created_at']);
  671. } elseif ($val == 'audit') {
  672. $jobData['company_audit'] = $com_info['audit'];
  673. } else {
  674. $jobData[$val] = $com_info[$val];
  675. }
  676. }
  677. if ($data['wage']==-1) {
  678. $jobData['wage'] = -1;
  679. $jobData['wage_min']=0;
  680. $jobData['wage_max']=0;
  681. } else {
  682. if (intval($data['wage'])==0) {
  683. $jobData['wage'] = 0;
  684. $jobData['wage_min']=$data['wage_min'];
  685. $jobData['wage_max']=$data['wage_max'];
  686. } else {
  687. $wage = explode('~', format_wage(get_category($jobData['wage'])));
  688. if (isset($wage[1])) {
  689. $jobData['wage_max'] =intval($wage[1]);
  690. }
  691. $jobData['wage_min'] =intval($wage[0]);
  692. }
  693. }
  694. if(isset($data['syq'])){
  695. $jobData['syq']=$data['syq'];
  696. }
  697. if(isset($data['syqxz_min'])){
  698. $jobData['syqxz_min']=$data['syqxz_min'];
  699. }
  700. $jobData['company_id'] = $user->id;
  701. $jobData['robot'] = 0;
  702. $jobData['valid'] = 1;
  703. $jobData['refresh_time'] = time();
  704. $jobData['setmeal_deadline'] = $setmeal->endtime ? strtotime($setmeal->endtime) : 0;
  705. $jobData['setmeal_id'] = $setmeal->setmeal_id;
  706. $jobData['setmeal_name'] = $setmeal->setmeal_name;
  707. if ($basis_contact==1) {
  708. $contactArr = ['contact', 'telephone', 'landline_tel', 'email', 'address', 'contact_show', 'telephone_show', 'email_show', 'landline_tel_show'];
  709. foreach ($contactArr as $key => $val) {
  710. if ($val == 'telephone') {
  711. $conData[$val] = $com_info['mobile'];
  712. } elseif ($val == 'landline_tel') {
  713. if ($com_info[$val]) {
  714. if ($jid) {
  715. $conData[$val] = $com_info[$val];
  716. } else {
  717. $list = explode('-', $com_info[$val]);
  718. foreach ($list as $ke => $vo) {
  719. if ($vo) {
  720. $conData[$val][$ke] = $vo;
  721. } else {
  722. $conData[$val][$ke] = '';
  723. }
  724. }
  725. }
  726. } else {
  727. $conData[$val] = '';
  728. }
  729. } else {
  730. $conData[$val] = $com_info[$val];
  731. }
  732. }
  733. $jobContactData = $conData;
  734. } else {
  735. $jobContactData = $contactData;
  736. }
  737. $subsite_id[] = $com_info['subsite_id'];
  738. DB::beginTransaction();
  739. try {
  740. if ($jid) {
  741. if (!$this->jobsRepository->update($jobData, $jid)) {
  742. throw new Exception('修改职位失败');
  743. }
  744. //修改分站关系
  745. if ($subsite_id) {
  746. if ($this->subsiteJobRepository->findSubsite($jid)->isNotEmpty()) {
  747. if (!$this->subsiteJobRepository->deleteWhere(['jobs_id'=>$jid])) {
  748. throw new Exception('修改分站关系失败');
  749. }
  750. }
  751. foreach ($subsite_id as $key => $val) {
  752. $sub_data[] = [
  753. 'subsite_id'=>$val,
  754. 'jobs_id'=>$jid,
  755. 'created_at'=>date('Y-m-d H:i:s', time()),
  756. 'updated_at'=>date('Y-m-d H:i:s', time()),
  757. ];
  758. }
  759. if (false ===$this->subsiteJobRepository->createData($sub_data)) {
  760. throw new Exception('修改分站关系失败');
  761. }
  762. }
  763. if (false===$this->jobsContactRepository->update($jobContactData, $jid)) {
  764. throw new Exception('修改联系方式失败');
  765. }
  766. event_search_update(Jobs::class, (string)$jid, 'update');
  767. event_search_update(Company::class, (string)$com_info['id'], 'update');
  768. } else {
  769. if (false == $jobs = $this->jobsRepository->store($jobData)) {
  770. throw new Exception('添加职位失败');
  771. }
  772. $jobContactData['job_id'] = $jobs->id;
  773. if (false === $this->jobsContactRepository->create($jobContactData)) {
  774. throw new Exception('添加联系方式失败');
  775. }
  776. // if (!$this->companyRepository->modifyJobsNum($user->id, 1, 1)) {
  777. // throw new Exception('修改企业职位数失败!');
  778. // }
  779. // if (!$this->membersSetmealRepository->modifyJobsMeanwhile($setmeal->id, 1, 2)) {
  780. // throw new Exception('修改套餐可发布职位数失败!');
  781. // }
  782. //添加分站关系
  783. if ($subsite_id) {
  784. foreach ($subsite_id as $key => $val) {
  785. $sub_data[] = [
  786. 'subsite_id'=>$val,
  787. 'jobs_id'=>$jobContactData['job_id'],
  788. 'created_at'=>date('Y-m-d H:i:s', time()),
  789. 'updated_at'=>date('Y-m-d H:i:s', time()),
  790. ];
  791. }
  792. if (!$this->subsiteJobRepository->createData($sub_data)) {
  793. throw new Exception('职位同步至其他分站失败!');
  794. }
  795. }
  796. event_search_update(Jobs::class, (string)$jobs->id, 'update');
  797. event_search_update(Company::class, (string)$user->id, 'update');
  798. }
  799. DB::commit();
  800. if ($jid) {
  801. $msg = '修改';
  802. } else {
  803. $msg = '添加';
  804. }
  805. return response()->json(['status' => 1, 'msg' => $msg . "职位成功"]);
  806. } catch (Exception $e) {
  807. DB::rollback();
  808. return response()->json(['status' => 0, 'msg' => $e->getMessage()]);
  809. }
  810. }
  811. /**职位关闭
  812. * @param $request
  813. * @return JsonResponse
  814. */
  815. public function jobsClose($id,$user)
  816. {
  817. if (!is_array($id)) {
  818. $ids = explode(',', $id);
  819. } else {
  820. $ids = $id;
  821. }
  822. $jobsExist=$this->jobsRepository->jobsHas($user,$ids);
  823. if (empty($jobsExist) && !empty($data['id'])){
  824. return response()->json(['status'=>0, 'msg'=>"没有这个职位"]);
  825. }
  826. if (!$this->jobsRepository->closeJobs($ids)) {
  827. return response()->json(['status' => 0, 'msg' => '职位关闭失败', 'data' => '']);
  828. }
  829. $condition = [['whereIn','id', $ids]];
  830. event_search_update(Jobs::class, $condition, 'update');
  831. $com_ids =$this->jobsRepository->findWhereIn('id', $ids, ['company_id'])->toArray();
  832. $company_condition = [['whereIn','id', $com_ids]];
  833. event_search_update(Company::class, $company_condition, 'update');
  834. //写日志
  835. if (!is_array($id)) {
  836. foreach ($ids as $item) {
  837. if (!$this->memberLogRepository->createLog($user,1007,$item)) {
  838. throw new \Exception('添加刷新记录失败!');
  839. }
  840. }
  841. }else{
  842. if (!$this->memberLogRepository->createLog($user,1007,$id)) {
  843. throw new \Exception('添加刷新记录失败!');
  844. }
  845. }
  846. return response()->json(['status' => 1, 'msg' => '职位关闭成功', 'data' => '']);
  847. }
  848. /**
  849. * 职位恢复
  850. * @param $request
  851. * @return JsonResponse
  852. */
  853. public function jobsShow($id, $user)
  854. {
  855. $ids = explode(',', $id);
  856. $data['display'] = 1;
  857. $data['valid'] = 1;
  858. $data['deadline'] = time()+config('aix.companyset.comset.com_set.job_expire')*86400;
  859. $jobsExist=$this->jobsRepository->jobsHas($user,$ids);
  860. if (empty($jobsExist)){
  861. return response()->json(['status'=>0, 'msg'=>"没有这个职位"]);
  862. }
  863. //查询企业已发布多少职位数
  864. $condition['company_id'] = $user->id;
  865. $condition[] = ['audit','<>',3];
  866. $condition['display'] = 1;
  867. $condition['valid'] = 1;
  868. $jobsCount = $this->jobsRepository->jobsTotal($condition);
  869. //查询企业套餐内可发布职位数
  870. $mySetmeal = $this->membersSetmealRepository->getSetmealByUid($user->id, $user->utype);
  871. if ($mySetmeal->jobs_meanwhile<=$jobsCount) {
  872. return response()->json(['status'=>0, 'msg'=>"当前显示的职位已经达到最大限制,请升级服务套餐或关闭未招聘职位!"]);
  873. }
  874. if (!$this->jobsRepository->showJobs($ids, $data)) {
  875. return response()->json(['status' => 0, 'msg' => '职位恢复失败', 'data' => '']);
  876. }
  877. $condition = [['whereIn','id', $ids]];
  878. event_search_update(Jobs::class, $condition, 'update');
  879. $com_ids =$this->jobsRepository->findWhereIn('id', $ids, ['company_id'])->toArray();
  880. $company_condition = [['whereIn','id', $com_ids]];
  881. event_search_update(Company::class, $company_condition, 'update');
  882. //写日志
  883. if (!is_array($id)) {
  884. foreach ($ids as $item) {
  885. if (!$this->memberLogRepository->createLog($user,1008,$item)) {
  886. throw new \Exception('添加删除记录失败!');
  887. }
  888. }
  889. }else{
  890. if (!$this->memberLogRepository->createLog($user,1008,$id)) {
  891. throw new \Exception('添加删除记录失败!');
  892. }
  893. }
  894. return response()->json(['status' => 1, 'msg' => '职位恢复成功', 'data' => '']);
  895. }
  896. /**
  897. * 职位删除
  898. * @param $request
  899. * @return JsonResponse
  900. */
  901. public function jobsDel($id, $user)
  902. {
  903. if (!is_array($id)) {
  904. $ids = explode(',', $id);
  905. } else {
  906. $ids = $id;
  907. }
  908. $count = count($ids);
  909. $setmeal = $this->membersSetmealRepository->getSetmealByUid($user->id, $user->utype);
  910. DB::beginTransaction();
  911. try {
  912. if (!$this->jobsRepository->delJobs($ids)) {
  913. throw new Exception('职位删除失败');
  914. }
  915. // if (!$this->companyRepository->modifyJobsNum($user->id, 2, $count)) {
  916. // throw new Exception('修改企业职位数失败!');
  917. // }
  918. if (!$this->jobsContactRepository->delJobsContact($ids)) {
  919. throw new Exception('删除职位联系人失败!');
  920. }
  921. // if (!$this->membersSetmealRepository->modifyJobsMeanwhile($setmeal->id, $count, 1)) {
  922. // throw new Exception('修改套餐可发布职位数失败!');
  923. // }
  924. $condition = [['whereIn', 'id', $ids]];
  925. event_search_update(Jobs::class, $condition, 'delete');
  926. $com_ids =$this->jobsRepository->findWhereIn('id', $ids, ['company_id'])->toArray();
  927. $company_condition = [['whereIn','id', $com_ids]];
  928. event_search_update(Company::class, $company_condition, 'update');
  929. DB::commit();
  930. } catch (Exception $e) {
  931. DB::rollback();
  932. return response()->json(['status' => 0, 'msg' =>$e->getMessage(), 'data' => '']);
  933. }
  934. //写日志
  935. if (!is_array($id)) {
  936. foreach ($ids as $item) {
  937. if (!$this->memberLogRepository->createLog($user,1009,$item)) {
  938. throw new \Exception('添加删除记录失败!');
  939. }
  940. }
  941. }else{
  942. if (!$this->memberLogRepository->createLog($user,1009,$id)) {
  943. throw new \Exception('添加删除记录失败!');
  944. }
  945. }
  946. return response()->json(['status' => 1, 'msg' => '职位删除成功', 'data' => '']);
  947. }
  948. /**招聘效果统计==访客统计
  949. * @param $request
  950. * @return mixed
  951. * @throws \Throwable
  952. */
  953. public function statisticsVisitor($request, $user)
  954. {
  955. return $this->allStatistics($request, 'visitor', $user);
  956. }
  957. /**招聘效果统计==职位浏览
  958. * @param $request
  959. * @return mixed
  960. * @throws \Throwable
  961. */
  962. public function statisticsViewjobs($request, $user)
  963. {
  964. return $this->allStatistics($request, 'viewjobs', $user);
  965. }
  966. /**招聘效果统计==应聘
  967. * @param $request
  968. * @return mixed
  969. * @throws \Throwable
  970. */
  971. public function statisticsApply($request, $user)
  972. {
  973. return $this->allStatistics($request, 'apply', $user);
  974. }
  975. /**招聘效果统计
  976. * @param $request
  977. * @param $type
  978. * @return mixed
  979. * @throws \Throwable
  980. */
  981. public function allStatistics($request, $type, $user)
  982. {
  983. $settr = $request->settr?$request->settr:7;
  984. $source = $request->source?$request->source:1;
  985. $jobid = $request->jobid?$request->jobid:0;
  986. $where['company_id'] = $user->id;
  987. $where[] = ['apply', '>=', 0];
  988. $apply = 0;
  989. if ($type == "apply") {
  990. $where[] = ['apply', '>=',1];
  991. $apply = 1;
  992. }
  993. $model = $this->companyStatisticsRepository;
  994. $today = date('Y-m-d');
  995. $settr_tmp = strtotime($today)-($settr+1)*3600*24;
  996. if ($settr>0) {
  997. $where[] = ['created_at','>=', date('Y-m-d', $settr_tmp)];
  998. $where[] = ['created_at','<', $today];
  999. }
  1000. if ($source>0) {
  1001. $where['source'] = $source;
  1002. }
  1003. if ($jobid>0) {
  1004. $where['job_id'] = $jobid;
  1005. }
  1006. $param_array = ['settr','source','jobid','page'];
  1007. $params= [];
  1008. if ($request->all()) {
  1009. foreach ($request->all() as $k => $v) {
  1010. if (in_array($k, $param_array)) {
  1011. $params[$k] = $v;
  1012. }
  1013. }
  1014. }
  1015. $category = [];
  1016. $set_total = $set_login = [];
  1017. for ($i=$settr_tmp; $i < strtotime($today); $i=$i+3600*24) {
  1018. $category[] = date('Y-m-d', $i);
  1019. $set_total[$i] = 0;
  1020. $set_login[$i] = 0;
  1021. }
  1022. $uidArr = [];
  1023. $count_num = ['total'=>0,'login'=>0];
  1024. if ($type) {
  1025. $remark = $type.'_';
  1026. } else {
  1027. $remark='';
  1028. }
  1029. $statistics_list = $model->orderBy('created_at', 'desc')->findWhere($where)->toArray();
  1030. $view_time = [];
  1031. foreach ($statistics_list as $key => $value) {
  1032. if ($value['uid']>0) {
  1033. if ($value['job_id']>0 && $value['apply']==0 && !isset($view_time['time']['viewjobs'][$value['uid']])) {
  1034. $view_time['time']['viewjobs'][$value['uid']] = strtotime($value['created_at']);
  1035. $view_time['source']['viewjobs'][$value['uid']] = $value['source'];
  1036. }
  1037. if ($value['job_id']>0 && $value['apply']>0 && !isset($view_time['time']['apply'][$value['uid']])) {
  1038. $view_time['time']['apply'][$value['uid']] = strtotime($value['created_at']);
  1039. $view_time['source']['apply'][$value['uid']] = $value['source'];
  1040. $view_time['source']['visitor'][$value['uid']] = $value['source'];
  1041. $view_time['time']['visitor'][$value['uid']] = strtotime($value['created_at']);
  1042. }
  1043. if ($value['apply']==0 && !isset($view_time['time']['visitor'][$value['uid']])) {
  1044. $view_time['time']['visitor'][$value['uid']] = strtotime($value['created_at']);
  1045. $view_time['source']['visitor'][$value['uid']] = $value['source'];
  1046. }
  1047. $set_login[strtotime(date('Y-m-d', strtotime($value['created_at'])))]++;
  1048. $uidArr[] = $value['uid'];
  1049. }
  1050. $set_total[strtotime(date('Y-m-d', strtotime($value['created_at'])))]++;
  1051. $count_num['total']++;
  1052. }
  1053. $res ['view_time'] = $view_time;
  1054. $line_xml = '<chart palettecolors="#0075c2,#1aaf5d" bgcolor="#ffffff" showborder="0" showshadow="0" showcanvasborder="0" useplotgradientcolor="0" legendborderalpha="0" legendshadow="0" showaxislines="0" showalternatehgridcolor="0" divlinethickness="1" divlinedashed="1" divlinedashlen="1" showvalues="0">';
  1055. $line_xml.= '<categories>';
  1056. foreach ($category as $key => $value) {
  1057. $line_xml.= '<category label="'.$value.'" />';
  1058. }
  1059. $line_xml.= '</categories>';
  1060. if ($apply == 1) {
  1061. $line_xml.= '<dataset seriesname="用户应聘次数">';
  1062. foreach ($set_login as $key => $value) {
  1063. $line_xml.= '<set value="'.$value.'" />';
  1064. }
  1065. $line_xml.= '</dataset>';
  1066. } else {
  1067. $line_xml.= '<dataset seriesname="总浏览次数">';
  1068. foreach ($set_total as $key => $value) {
  1069. $line_xml.= '<set value="'.$value.'" />';
  1070. }
  1071. $line_xml.= '</dataset>';
  1072. $line_xml.= '<dataset seriesname="登录用户浏览次数">';
  1073. foreach ($set_login as $key => $value) {
  1074. $line_xml.= '<set value="'.$value.'" />';
  1075. }
  1076. $line_xml.= '</dataset>';
  1077. }
  1078. $line_xml.= '</chart>';
  1079. $res ['line_xml'] = $line_xml;
  1080. if (!empty($uidArr)) {
  1081. //这里如果需要缓存的话,需要做修改
  1082. // $resumelist = Cache::get($remark.$where['apply'].'_'.$user->id.'_'.$jobid.'_'.$source.'_'.$settr.'_resumelist');
  1083. // if (null === $resumelist) {
  1084. $resumelist = $this->resumeRepository->findResumeList($uidArr);
  1085. // Cache::put($remark.$where['apply'].'_'.$user->id.'_'.$jobid.'_'.$source.'_'.$settr.'_resumelist', $resumelist, 10);
  1086. // }
  1087. } else {
  1088. $resumelist = [];
  1089. }
  1090. $sex_total = [1=>0,2=>0];
  1091. $sex_total['total'] = 0;
  1092. $education_total = [];
  1093. $education_total['total'] = 0;
  1094. $experience_total = [];
  1095. $experience_total['total'] = 0;
  1096. $age_total = [];
  1097. $age_total['total'] = 0;
  1098. foreach ($resumelist as $key => $value) {
  1099. if ($value->display_name=="2") {
  1100. $resumelist[$key]->fullname="N".str_pad($value->id, 7, "0", STR_PAD_LEFT);
  1101. } elseif ($value->display_name=="3") {
  1102. if ($value->sex==1) {
  1103. $resumelist[$key]->fullname=cut_str($value->fullname, 1, 0, "先生");
  1104. } elseif ($value->sex == 2) {
  1105. $resumelist[$key]->fullname=cut_str($value->fullname, 1, 0, "女士");
  1106. } else {
  1107. $resumelist[$key]->fullname=cut_str($value->fullname, 1, 0, "**");
  1108. }
  1109. } else {
  1110. $resumelist[$key]->fullname=$value->fullname;
  1111. }
  1112. $resumelist[$key]->intention_jobs=cut_str($value->intention_jobs, 10, 0, '..');
  1113. $resumelist[$key]->age=date('Y')-$value->birthdate;
  1114. if (!$request->ajax()) {
  1115. $count_num['login']++;
  1116. if ($value->sex>0) {
  1117. if (isset($sex_total[$value->sex])) {
  1118. $sex_total[$value->sex]++;
  1119. } else {
  1120. $sex_total[$value->sex] = 1;
  1121. }
  1122. }
  1123. if ($value->experience>0) {
  1124. if (isset($experience_total['total'])) {
  1125. $experience_total['total'] += 1;
  1126. } else {
  1127. $experience_total['total'] = 0;
  1128. $experience_total['total'] +=1 ;
  1129. }
  1130. if (isset($experience_total['data'][$value->experience])) {
  1131. $experience_total['data'][$value->experience]['num']++;
  1132. } else {
  1133. $experience_total['data'][$value->experience]['label'] = $value->experience_cn;
  1134. $experience_total['data'][$value->experience]['num'] = 1;
  1135. }
  1136. }
  1137. if ($value->education>0) {
  1138. if (isset($education_total['total'])) {
  1139. $education_total['total'] += 1;
  1140. } else {
  1141. $education_total['total'] = 0;
  1142. $education_total['total'] +=1 ;
  1143. }
  1144. if (isset($education_total['data'][$value->education])) {
  1145. $education_total['data'][$value->education]['num']++;
  1146. } else {
  1147. $education_total['data'][$value->education]['label'] = $value->education_cn;
  1148. $education_total['data'][$value->education]['num'] = 1;
  1149. }
  1150. }
  1151. if ($value->birthdate>0) {
  1152. if (isset($age_total['total'])) {
  1153. $age_total['total'] += 1;
  1154. } else {
  1155. $age_total['total'] = 0;
  1156. $age_total['total'] +=1 ;
  1157. }
  1158. $minus_age = date('Y') - $value->birthdate;
  1159. if ($minus_age<26) {
  1160. $age_total['data'][0]['label'] = '18-25岁';
  1161. if (isset($age_total['data'][0]['num'])) {
  1162. $age_total['data'][0]['num'] += 1;
  1163. } else {
  1164. $age_total['data'][0]['num'] = 0;
  1165. $age_total['data'][0]['num'] +=1 ;
  1166. }
  1167. } elseif ($minus_age<31) {
  1168. $age_total['data'][1]['label'] = '26-30岁';
  1169. if (isset($age_total['data'][1]['num'])) {
  1170. $age_total['data'][1]['num'] += 1;
  1171. } else {
  1172. $age_total['data'][1]['num'] = 0;
  1173. $age_total['data'][1]['num'] +=1 ;
  1174. }
  1175. } elseif ($minus_age<41) {
  1176. $age_total['data'][2]['label'] = '31-40岁';
  1177. if (isset($age_total['data'][2]['num'])) {
  1178. $age_total['data'][2]['num'] += 1;
  1179. } else {
  1180. $age_total['data'][2]['num'] = 0;
  1181. $age_total['data'][2]['num'] +=1 ;
  1182. }
  1183. } elseif ($minus_age<51) {
  1184. $age_total['data'][3]['label'] = '41-50岁';
  1185. if (isset($age_total['data'][3]['num'])) {
  1186. $age_total['data'][3]['num'] += 1;
  1187. } else {
  1188. $age_total['data'][3]['num'] = 0;
  1189. $age_total['data'][3]['num'] +=1 ;
  1190. }
  1191. } else {
  1192. $age_total['data'][4]['label'] = '50岁';
  1193. if (isset($age_total['data'][4]['num'])) {
  1194. $age_total['data'][4]['num'] += 1;
  1195. } else {
  1196. $age_total['data'][4]['num'] = 0;
  1197. $age_total['data'][4]['num'] +=1 ;
  1198. }
  1199. }
  1200. }
  1201. }
  1202. }
  1203. $res['table_data'] = $resumelist;
  1204. if ($request->ajax()) {
  1205. $res['mark'] = $type;
  1206. $html = view('app.company.ajax.ajax_statistics_list', $res)->render();
  1207. return response()->json(['data'=>$html]);
  1208. }
  1209. $sex_xml = '<chart showborder="0" enablesmartlabels="0" showlabels="0" showpercentvalues="1" showlegend="1" defaultcenterlabel="性别 ('.($sex_total[1]+$sex_total[2]).'人)" centerlabel="$label: $value人" centerlabelbold="0" showtooltip="0" decimals="0" usedataplotcolorforlabels="1" theme="fint">';
  1210. if (!empty($sex_total['total'])) {
  1211. $sex_xml.= '<set label="男" value="'.$sex_total[1].'" />';
  1212. $sex_xml.= '<set label="女" value="'.$sex_total[2].'" />';
  1213. }
  1214. $sex_xml.= '</chart>';
  1215. $res['sex_xml'] = $sex_xml;
  1216. $experience_xml = '<chart showborder="0" enablesmartlabels="0" showlabels="0" showpercentvalues="1" showlegend="1" defaultcenterlabel="工作经验 ('.$experience_total['total'].'人)" centerlabel="$label: $value人" centerlabelbold="0" showtooltip="0" decimals="0" usedataplotcolorforlabels="1" theme="fint">';
  1217. if (!empty($experience_total['data'])) {
  1218. foreach ($experience_total['data'] as $key => $value) {
  1219. $experience_xml.= '<set label="'.$value['label'].'" value="'.$value['num'].'" />';
  1220. }
  1221. }
  1222. $experience_xml.= '</chart>';
  1223. $res['experience_xml'] = $experience_xml;
  1224. // dd($experience_xml);
  1225. $education_xml = '<chart showborder="0" enablesmartlabels="0" showlabels="0" showpercentvalues="1" showlegend="1" defaultcenterlabel="学历 ('.$education_total['total'].'人)" centerlabel="$label: $value人" centerlabelbold="0" showtooltip="0" decimals="0" usedataplotcolorforlabels="1" theme="fint">';
  1226. if (!empty($education_total['data'])) {
  1227. foreach ($education_total['data'] as $key => $value) {
  1228. $education_xml.= '<set label="'.$value['label'].'" value="'.$value['num'].'" />';
  1229. }
  1230. }
  1231. $education_xml.= '</chart>';
  1232. $res['education_xml'] = $education_xml;
  1233. $age_xml = '<chart showborder="0" enablesmartlabels="0" showlabels="0" showpercentvalues="1" showlegend="1" defaultcenterlabel="年龄 ('.$age_total['total'].'人)" centerlabel="$label: $value人" centerlabelbold="0" showtooltip="0" decimals="0" usedataplotcolorforlabels="1" theme="fint">';
  1234. if (!empty($age_total['data'])) {
  1235. foreach ($age_total['data'] as $key => $value) {
  1236. $age_xml.= '<set label="'.$value['label'].'" value="'.$value['num'].'" />';
  1237. }
  1238. }
  1239. $age_xml.= '</chart>';
  1240. $res['age_xml'] = $age_xml;
  1241. $res['source'] = $source;
  1242. $res['settr'] = $settr;
  1243. $res['jobid'] = $jobid;
  1244. $mysetmeal = $this->membersSetmealRepository->getSetmealByUid($user->id, 1);
  1245. $upper_limit = 0;
  1246. $jids = $this->jobsRepository->jobsTotal([['company_id', '=', $user->id]]);
  1247. if ($jids>=$mysetmeal->jobs_meanwhile) {
  1248. $upper_limit = 1;
  1249. }
  1250. $res['upper_limit'] = $upper_limit;
  1251. $res['source_arr'] = ['1'=>'PC端','2'=>'触屏端','3'=>'移动端'];
  1252. $res['count_num'] = $count_num;
  1253. $res['params'] = $params;
  1254. return $res;
  1255. }
  1256. public function callCashPay($user, $increment_info, $my_point, $order_pay_type, $payment_name = '', $amount = '0.0', $is_deductible, $deductible = 0, $description = '', $params = '', $points = 0, $stemeal = 0, $discount = '')
  1257. {
  1258. //获取支付方式
  1259. $paymenttpye = $this->paymentService->returnPayment($payment_name);
  1260. if (!$paymenttpye) {
  1261. return array( 'status'=>0, 'msg' => '支付方式错误!');
  1262. }
  1263. if ($my_point->points < $deductible) {
  1264. return array( 'status'=>0, 'msg' => '积分不足,请使用其他方式支付!');
  1265. }
  1266. if ($is_deductible==0) {
  1267. $deductible = 0;
  1268. }
  1269. if ($deductible>0) {
  1270. $m_amount = $amount- floatval($deductible/config('aix.companyset.points.points_set.payment_rate'));
  1271. } else {
  1272. $m_amount = $amount;
  1273. }
  1274. $m_amount=round($m_amount,2);
  1275. $paysetarr['ordtotal_fee']=$m_amount;
  1276. if ($description=='') {
  1277. $description = '购买服务:'.$increment_info['name'];
  1278. }
  1279. $description .= ';'.$paymenttpye->name.$paysetarr['ordtotal_fee'].'元';
  1280. if ($deductible>0) {
  1281. $description .= ';积分支付:'.$deductible.'积分';
  1282. }
  1283. $stime = time();
  1284. //生成订单
  1285. $order = $this->orderService->addOrder($user, $order_pay_type, $amount, $paysetarr['ordtotal_fee'], 0, $increment_info['name'], $payment_name, $paymenttpye->name, $description, 1, $deductible, $stemeal, 0, serialize($params), $discount);
  1286. $tradeNo = $this->payService->getTradeNo($order->id);
  1287. if (!$this->serviceService->updateOid($order->id, $tradeNo)) {
  1288. throw new ResponseException('生成订单号失败!');
  1289. }
  1290. if ($payment_name == 'wechat') {
  1291. $type = 'scan';
  1292. } else {
  1293. $type = 'web';
  1294. }
  1295. $payOrder = new PayOrder();
  1296. $payOrder->trade_no = $tradeNo;
  1297. $payOrder->subject = '购买' . $increment_info['name'];
  1298. $payOrder->detail = $description;
  1299. $payOrder->price = $m_amount;
  1300. //执行刷新操作或其他
  1301. $payOrder->callback = "App\Services\Common\OrderService.incrementSave";
  1302. $payOrder->return_url = route('jobs.list');
  1303. $result = $this->payService->pay($payment_name, $type, $payOrder);
  1304. if ($payment_name == 'wechat') {
  1305. return response()->json([
  1306. 'status' => 1,
  1307. 'tradeCode' => get_qrcode_html($result->code_url),
  1308. 'tradeNo' => $tradeNo,
  1309. ]);
  1310. } else {
  1311. return $result;
  1312. }
  1313. }
  1314. /**刷新职位 =======积分刷新职位或套餐内免费
  1315. * @param $jid
  1316. * @param $mySetmeal
  1317. * @return array
  1318. */
  1319. public function jobsRefreshSave($jid, $user, $mySetmeal)
  1320. {
  1321. $jobsCount = count($jid);
  1322. $where = [
  1323. 'uid' => $user->id,
  1324. 'utype' => 1,
  1325. 'type' => 1006,
  1326. 'mode' => 2
  1327. ];
  1328. $todayCount = $this->refreshLogRepository->getTodayRefreshTimes($where); //今天免费刷新次数
  1329. $headsel1 = 0;
  1330. $free_mode = 0;
  1331. if ($todayCount >= ($mySetmeal->refresh_jobs_free + config('aix.companyset.comsume.comsume_set.refresh_jobs_more'))) {
  1332. $myPoints = $this->memberPointRepository->getPointsOne($user->id, 1);
  1333. if ($myPoints['points'] < ($jobsCount * config('aix.companyset.comsume.comsume_set.refresh_jobs_price') * config('aix.companyset.points.points_set.payment_rate'))) {
  1334. return ['status' => 0, 'msg' => "你的积分不足,不能刷新职位!"];
  1335. }
  1336. $headsel1=1;
  1337. $handsel['uid'] = $user->id;
  1338. $handsel['utype'] = 1;
  1339. $handsel['htype'] = 'refresh_jobs';
  1340. $handsel['htype_cn'] = '刷新职位';
  1341. $handsel['operate'] = 2;
  1342. $handsel['points'] = config('aix.companyset.comsume.comsume_set.refresh_jobs_price') * config('aix.companyset.points.points_set.payment_rate') * $jobsCount;
  1343. $log_paymode = '积分兑换刷新';
  1344. } else {
  1345. $free_mode = 1;
  1346. $log_paymode = '套餐内免费刷新';
  1347. }
  1348. //查询职位名称
  1349. $jobs_name_arr = $this->jobsRepository->findJobsName($jid);
  1350. $josname = array_column($jobs_name_arr, 'jobs_name', 'id');
  1351. DB::beginTransaction();
  1352. try {
  1353. foreach ($jid as $key => $val) {
  1354. if (!$this->jobsRepository->jobsRefresh($val)) {
  1355. throw new \Exception('刷新失败');
  1356. }
  1357. if ($free_mode!=1) {
  1358. if (!$this->memberPointRepository->reportDeal($user->id, 1, 2, ($jobsCount * config('aix.companyset.comsume.comsume_set.refresh_jobs_price')*config('aix.companyset.points.points_set.payment_rate')))) {
  1359. throw new \Exception('积分设置失败!');
  1360. }
  1361. }
  1362. if (!$this->companyRepository->companySave(['refresh_time'=>time()], $user->id)) {
  1363. throw new \Exception('刷新失败!修改企业信息表失败');
  1364. }
  1365. // 写入会员积分操作日志
  1366. if ($headsel1) {
  1367. if (!$this->memberHandselRepository->addNew($handsel)) {
  1368. throw new \Exception('刷新失败!会员积分增减记录添加失败');
  1369. }
  1370. }
  1371. //添加刷新操作日志
  1372. $logData = [
  1373. 'uid' => $user->id,
  1374. 'utype' => 1,
  1375. 'mode' => 2,
  1376. 'type' => 1006,
  1377. 'obj_id'=> $val,
  1378. ];
  1379. if (!$this->refreshLogRepository->addLog($logData)) {
  1380. throw new \Exception('添加刷新记录失败!');
  1381. }
  1382. //写日志
  1383. if (!$this->memberLogRepository->createLog($user,1006,[$val,$log_paymode])) {
  1384. throw new \Exception('添加刷新记录失败!');
  1385. }
  1386. $members_log['log_uid']=$user->id;
  1387. $members_log['log_utype']=1;
  1388. $members_log['log_username']=$user->username;
  1389. $log_leave=$mySetmeal->refresh_jobs_free-1;
  1390. $members_log['log_leave'] = $log_leave<0?0:$log_leave;
  1391. $members_log['log_value'] = '刷新职位(职位名称:'.$josname[$val].')';
  1392. $members_log['log_source']='网页版';
  1393. if (!$this->membersSetmealLogRepository->addNew($members_log)) {
  1394. throw new \Exception('刷新失败!');
  1395. }
  1396. event_search_update(Jobs::class, (string)$val, 'update');
  1397. Cache::put('refresh_jobid_'.$val, $jid, config('aix.companyset.comset.other_set.refresh_jobs_space'));
  1398. }
  1399. DB::commit();
  1400. return ['status' => 1, 'msg' => "刷新成功!"];
  1401. } catch (Exception $e) {
  1402. DB::rollback();
  1403. return ['status' => 0, 'msg' => $e->getMessage()];
  1404. }
  1405. }
  1406. /**
  1407. * 付费刷新
  1408. */
  1409. public function jobRefreshPay($jobs_id, $user, $is_deductible,$deductible,$mySetmeal){
  1410. if (isExpire($mySetmeal)){
  1411. return ['status' => 0, 'msg' => "提醒:您的套餐已到期,请及时到我的套餐处升级套餐!"];
  1412. }
  1413. DB::beginTransaction();
  1414. try {
  1415. if (!$this->jobsRepository->jobsRefresh($jobs_id)) {
  1416. throw new \Exception('刷新失败');
  1417. }
  1418. if ($is_deductible) {
  1419. if (!$this->memberPointRepository->reportDeal($user->id, 1, 2,$deductible)) {
  1420. throw new \Exception('积分设置失败!');
  1421. }
  1422. }
  1423. if (!$this->companyRepository->companySave(['refresh_time'=>time()], $user->id)) {
  1424. throw new \Exception('刷新失败!修改企业信息表失败');
  1425. }
  1426. // 写入会员积分操作日志
  1427. $headsel1=1;
  1428. $handsel['uid'] = $user->id;
  1429. $handsel['utype'] = 1;
  1430. $handsel['htype'] = 'refresh_jobs';
  1431. $handsel['htype_cn'] = '刷新职位';
  1432. $handsel['operate'] = 2;
  1433. $handsel['points'] = $deductible;
  1434. if ($headsel1) {
  1435. if (!$this->memberHandselRepository->addNew($handsel)) {
  1436. throw new \Exception('刷新失败!会员积分增减记录添加失败');
  1437. }
  1438. }
  1439. //添加刷新操作日志
  1440. $logData = [
  1441. 'uid' => $user->id,
  1442. 'utype' => 1,
  1443. 'mode' => 2,
  1444. 'type' => 1006,
  1445. 'obj_id'=> $jobs_id,
  1446. ];
  1447. if (!$this->refreshLogRepository->addLog($logData)) {
  1448. throw new \Exception('添加刷新记录失败!');
  1449. }
  1450. //写会员操作日志
  1451. if (!$this->memberLogRepository->createLog($user,1006,[$jobs_id,"付费刷新"])) {
  1452. throw new \Exception('添加刷新记录失败!');
  1453. }
  1454. $members_log['log_uid']=$user->id;
  1455. $members_log['log_utype']=1;
  1456. $members_log['log_username']=$user->username;
  1457. $log_leave=$mySetmeal->refresh_jobs_free-1;
  1458. $members_log['log_leave'] = $log_leave<0?0:$log_leave;
  1459. $josname = $this->jobsRepository->getName($jobs_id);
  1460. $members_log['log_value'] = '刷新职位(职位名称:'.$josname.')';
  1461. $members_log['log_source']='网页版';
  1462. if (!$this->membersSetmealLogRepository->addNew($members_log)) {
  1463. throw new \Exception('刷新失败!');
  1464. }
  1465. event_search_update(Jobs::class, (string)$jobs_id, 'update');
  1466. DB::commit();
  1467. Cache::put('refresh_jobid_'.$jobs_id, $jobs_id, config('aix.companyset.comset.other_set.refresh_jobs_space'));
  1468. return ['status' => 1, 'msg' => "刷新成功!"];
  1469. } catch (Exception $e) {
  1470. DB::rollback();
  1471. return ['status' => 0, 'msg' => $e->getMessage()];
  1472. }
  1473. }
  1474. /**
  1475. * 微信公众号刷新职位
  1476. */
  1477. public function jobsRefreshWechat($user)
  1478. {
  1479. //企业发布职位数
  1480. $map['company_id'] = $user->id;
  1481. if (config('aix.companyset.comset.show_set.jobs_display')== 1) {
  1482. $map['audit'] = 1;
  1483. }
  1484. $map['display'] = 1;
  1485. $map['valid'] = 1;
  1486. $user_jobs = $this->jobsRepository->getComJobs($map);
  1487. //我的套餐
  1488. $mySetmeal = $this->membersSetmealRepository->getSetmealByUid($user->id, $user->utype);
  1489. if (isExpire($mySetmeal)){
  1490. return ['status' => 0, 'msg' => "提醒:您的套餐已到期,请及时到我的套餐处升级套餐!"];
  1491. }
  1492. //我的积分
  1493. $myPoints = $this->memberPointRepository->getPointsOne($user->id, 1);
  1494. $where = [
  1495. 'uid' => $user->id,
  1496. 'utype' => 1,
  1497. 'type' => 1006,
  1498. 'mode' => 2
  1499. ];
  1500. $todayCount = $this->refreshLogRepository->getTodayRefreshTimes($where); //今天免费刷新次数
  1501. //没有可刷新职位
  1502. if (count($user_jobs)==0) {
  1503. return ['status'=>2,'msg'=>'没有可刷新的职位'];
  1504. }
  1505. //刷新间隔时间
  1506. $where1 = [
  1507. 'uid' => $user->id,
  1508. 'utype' => 1,
  1509. 'type' => 1006,
  1510. 'mode' => 2
  1511. ];
  1512. $refrestime = $this->refreshLogRepository->getLastRefreshDate($where1);
  1513. $duringtime = time() - strtotime($refrestime?$refrestime->created_at:0);
  1514. $space = config('aix.companyset.comset.other_set.refresh_jobs_space') * 60;
  1515. if ($space > 0 && $duringtime <= $space) {
  1516. return ['status' => 3, 'msg' => $space . "秒内不能重复刷新职位",];
  1517. }
  1518. $headsel1 = 0;
  1519. $free_mode = 0;
  1520. if ($todayCount >= ($mySetmeal->refresh_jobs_free + config('aix.companyset.comsume.comsume_set.refresh_jobs_more'))) {
  1521. if ($myPoints['points'] < (count($user_jobs) * config('aix.companyset.comsume.comsume_set.refresh_jobs_price') * config('aix.companyset.points.points_set.payment_rate'))) {
  1522. return ['status' => 4, 'msg' => "你的积分不足,不能刷新职位!", 'url'=>route('mobile.firm.service.points.add')];
  1523. }
  1524. $headsel1=1;
  1525. $handsel['uid'] = $user->id;
  1526. $handsel['utype'] = 1;
  1527. $handsel['htype'] = 'refresh_jobs';
  1528. $handsel['htype_cn'] = '刷新职位';
  1529. $handsel['operate'] = 2;
  1530. $handsel['points'] = config('aix.companyset.comsume.comsume_set.refresh_jobs_price') * config('aix.companyset.points.points_set.payment_rate') * count($user_jobs);
  1531. $log_paymode = '积分兑换刷新';
  1532. } else {
  1533. $free_mode = 1;
  1534. $log_paymode = '套餐内免费刷新';
  1535. }
  1536. //查询职位名称
  1537. $jobs_name_arr = $this->jobsRepository->getComJobs($map, ['id','jobs_name']);
  1538. $josname = array_column($jobs_name_arr, 'jobs_name', 'id');
  1539. $jid = array_column($jobs_name_arr, 'id', 'jobs_name');
  1540. DB::beginTransaction();
  1541. try {
  1542. foreach ($jid as $key => $val) {
  1543. if (!$this->jobsRepository->jobsRefresh($val)) {
  1544. throw new \Exception('刷新失败');
  1545. }
  1546. if ($free_mode!=1) {
  1547. if (!$this->memberPointRepository->reportDeal($user->id, 1, 2, (count($user_jobs) * config('aix.companyset.comsume.comsume_set.refresh_jobs_price')*config('aix.companyset.points.points_set.payment_rate')))) {
  1548. throw new \Exception('积分设置失败!');
  1549. }
  1550. }
  1551. if (!$this->companyRepository->companySave(['refresh_time'=>time()], $user->id)) {
  1552. throw new \Exception('刷新失败!修改企业信息表失败');
  1553. }
  1554. // 写入会员积分操作日志
  1555. if ($headsel1) {
  1556. if (!$this->memberHandselRepository->addNew($handsel)) {
  1557. throw new \Exception('刷新失败!会员积分增减记录添加失败');
  1558. }
  1559. }
  1560. //添加刷新操作日志
  1561. $logData = [
  1562. 'uid' => $user->id,
  1563. 'utype' => 1,
  1564. 'mode' => 2,
  1565. 'type' => 1006,
  1566. 'obj_id'=> $val,
  1567. ];
  1568. if (!$this->refreshLogRepository->addLog($logData)) {
  1569. throw new \Exception('添加刷新记录失败!');
  1570. }
  1571. $members_log['log_uid']=$user->id;
  1572. $members_log['log_utype']=1;
  1573. $members_log['log_username']=$user->username;
  1574. $log_leave=$mySetmeal->refresh_jobs_free-1;
  1575. $members_log['log_leave'] = $log_leave<0?0:$log_leave;
  1576. $members_log['log_value'] = '刷新职位(职位名称:'.$josname[$val].')'.$log_paymode;
  1577. $members_log['log_source']='网页版';
  1578. if (!$this->membersSetmealLogRepository->addNew($members_log)) {
  1579. throw new \Exception('刷新失败!');
  1580. }
  1581. Cache::put('refresh_jobid_'.$val, $jid, config('aix.companyset.comset.other_set.refresh_jobs_space'));
  1582. }
  1583. DB::commit();
  1584. return ['status' => 1, 'msg' => "刷新成功!"];
  1585. } catch (Exception $e) {
  1586. DB::rollback();
  1587. return ['status' => 0, 'msg' => $e->getMessage()];
  1588. }
  1589. }
  1590. /**
  1591. * 企业会员中心首页一键刷新职位
  1592. */
  1593. public function jobsRefreshAll($user)
  1594. {
  1595. $map['company_id'] = $user->id;
  1596. if (config('aix.companyset.comset.show_set.jobs_display')== 1) { //如果是先审核再展示
  1597. $map['audit'] = 1;
  1598. }else{
  1599. $map[]= ['audit', '!=',"3"];//如果是先展示再审核,去掉审核未通过的
  1600. }
  1601. $map['valid'] = 1;
  1602. $user_jobs = $this->jobsRepository->jobsTotal($map);
  1603. if ($user_jobs==0) {
  1604. return response()->json(['status'=>0,'msg'=>'没有可刷新的职位']);
  1605. }
  1606. $where = [
  1607. 'uid' => $user->id,
  1608. 'utype' => 1,
  1609. 'type' => 1006,
  1610. 'mode' => 2
  1611. ];
  1612. $refresh_time = $this->refreshLogRepository->getTodayRefreshTimes($where);
  1613. $mySetmeal = $this->membersSetmealRepository->getSetmealByUid($user->id, $user->utype);
  1614. if (isExpire($mySetmeal)){
  1615. return response()->json(['status' => 0, 'msg' => "提醒:您的套餐已到期,请及时到我的套餐处升级套餐!"]);
  1616. }
  1617. if (!$mySetmeal) {
  1618. return response()->json(['status'=>0,'msg'=>'您还没有开通服务,请开通!']);
  1619. }
  1620. if ($mySetmeal->exprie == 1 && $mySetmeal->setmeal_id > 1) {
  1621. return response()->json(['status'=>0,'msg'=>'您的服务已经到期,请重新开通!']);
  1622. }
  1623. $route = route('jobs.list');
  1624. if(is_mobile_route()){
  1625. $route = route('mobile.firm.jobs.list');
  1626. }
  1627. if(isset(request()->vail)&&!empty(request()->vail)){
  1628. $condition['company_id'] = $user->id;
  1629. if (config('aix.companyset.comset.show_set.jobs_display')== 1) {
  1630. $condition['audit'] = 1;
  1631. }else{
  1632. $condition[]= ['audit', '!=',"3"];//如果是先展示再审核,去掉审核未通过的
  1633. }
  1634. $condition['valid'] = 1;
  1635. $jobsid_arr = $this->jobsRepository->findWhere($condition, ['id'])->toArray();
  1636. $yid = array_column($jobsid_arr, 'id');
  1637. $r = $this->jobsRefreshSave($yid, $user, $mySetmeal);
  1638. return response()->json(['status'=>$r['status'],'msg'=>$r['msg']]);
  1639. }else{
  1640. if ($refresh_time >= $mySetmeal->refresh_jobs_free) {
  1641. return response()->json(['status'=>2,'msg'=>'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;您当前共有 <span class="font_yellow">'.$user_jobs.'</span> 条在招职位,今天免费刷新次数已用完。</br>请前往 <a target="_blank" href="'.$route.'" class="font_blue">职位列表</a> 单条刷新。','data'=>route('jobs.list', ['type'=>1])]);
  1642. /*
  1643. $mobile_surplus = $mySetmeal->refresh_jobs_free + config('aix.companyset.comsume.comsume_set.refresh_jobs_more')-$refresh_time;
  1644. if ($mobile_surplus >= 0) {
  1645. return response()->json(['status'=>2,'msg'=>'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;您当前共有 <span class="font_yellow">'.$user_jobs.'</span> 条在招职位,今天免费刷新次数已用完。</br>请前往 <a target="_blank" href="'.$route.'" class="font_blue">职位列表</a> 单条刷新。使用触屏版还可免费刷新 <span class="font_yellow">'.$mobile_surplus.'</span> 次!','data'=>route('jobs.list', ['type'=>1])]);
  1646. } else {
  1647. return response()->json(['status'=>2,'msg'=>'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;您当前共有 <span class="font_yellow">'.$user_jobs.'</span> 条在招职位,今天免费刷新次数已用完。</br>请前往 <a target="_blank" href="'.$route.'" class="font_blue">职位列表</a> 单条刷新。','data'=>route('jobs.list', ['type'=>1])]);
  1648. }*/
  1649. } elseif ($user_jobs+$refresh_time>$mySetmeal->refresh_jobs_free) {
  1650. $surplus = $mySetmeal->refresh_jobs_free - $refresh_time;
  1651. return response()->json(['status'=>2,'msg'=>'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;您当前共有 <span class="font_yellow">'.$user_jobs.'</span> 条在招职位,今天免费刷新次数剩余 <span class="font_yellow">'.$surplus.'</span> 次。</br>请前往 <a target="_blank" href="'.$route.'" class="font_blue">职位列表</a> 单条刷新。','data'=>route('jobs.list', ['type'=>1])]);
  1652. } else {
  1653. $surplus = $mySetmeal->refresh_jobs_free - $refresh_time;
  1654. return response()->json(['status'=>3,'msg'=>'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;您当前共有 <span class="font_yellow">'.$user_jobs.'</span> 条在招职位,今天免费刷新次数剩余 <span class="font_yellow">'.$surplus.'</span> 次。</br>如不需要批量刷新职位,请前往 <a target="_blank" href="'.$route.'" class="font_blue">职位列表</a> 单条刷新。','data'=>route('jobs.list', ['type'=>1])]);
  1655. }
  1656. }
  1657. }
  1658. //找工作
  1659. public function getLists($whereData)
  1660. {
  1661. //默认地区
  1662. $citycategory = array_get($whereData, 'citycategory');
  1663. if (!$citycategory) {
  1664. $citycategory = config('aix.system.site_other.site_other.district');
  1665. }
  1666. return false;
  1667. }
  1668. public function getJobInfo($where, $user = null)
  1669. {
  1670. $val = $this->jobsRepository->getInfo($where);
  1671. if (!$val) {
  1672. return ['status'=>0,'error'=>'职位不存在'];
  1673. }
  1674. if (!($user && $user->utype == 1 && $user->id == $val->company_id)) {
  1675. if ($val->display != 1) {
  1676. return ['status'=>0,'error'=>'职位已关闭'];
  1677. }
  1678. if ($val->valid != 1) {
  1679. return ['status'=>0,'error'=>'职位已失效'];
  1680. }
  1681. if (config('aix.companyset.comset.show_set.jobs_display')==1) {
  1682. if ($val->audit !='1') {
  1683. return ['status'=>0,'error'=>'职位审核中或审核失败'];
  1684. }
  1685. } else {
  1686. if ($val->audit =='3') {
  1687. return ['status'=>0,'error'=>'职位审核失败'];
  1688. }
  1689. }
  1690. }
  1691. $companyInfo = $this->companyRepository->find($val->company_id, ['utype']);
  1692. $tmp = 0;
  1693. if (($val->audit == 2 && config('aix.companyset.comset.show_set.jobs_display') == 1) || $val->audit == '3') {
  1694. $tmp = 1;
  1695. }
  1696. /*if ($tmp) {
  1697. throw new ResponseException('职位不存在', '', '404');
  1698. }*/
  1699. $val->tmp = $tmp;
  1700. /*$subsite_type = Cache::get('subsite_type');
  1701. //TODO 获取职位信息时添加分站判断,判断职位是否可以在当前分站显示
  1702. if ($subsite_type) {
  1703. //获取职位分站id
  1704. $subsite_id = get_jobs_subsite_id($val);
  1705. //判断分站是否可以访问
  1706. check_url(Cache::get('subsite_id'), $subsite_id);
  1707. }*/
  1708. if ($val->deadline < time()) {
  1709. $val->jobs_overtime = 1;
  1710. } elseif ($val->audit <> '1' || $val->display <> '1' || ($val->setmeal_deadline <> '0' && $val->setmeal_deadline < time())) {
  1711. $val->jobs_overtime = 2;
  1712. }
  1713. if ($val->setmeal_deadline < time() && $val->setmeal_deadline <> "0" && $val->add_mode == "2") {
  1714. $val->deadline = $val->setmeal_deadline;
  1715. }
  1716. if ($val->amount == 0) {
  1717. $val->amount = '若干';
  1718. }
  1719. $subsite_id = get_jobs_subsite_id($val);
  1720. $val->jobs_url = route(url_rewrite('AIX_jobsshow', null, $subsite_id), array('id'=>$val['id']));
  1721. $setmeal = $this->membersSetmealRepository->getSetmealByUid($val->company_id, $companyInfo->utype);
  1722. $val->show_contact_direct = $setmeal->show_contact_direct;
  1723. $profile = $this->companyRepository->getCompanyInfo(array('id'=>$val->company_id));
  1724. $profile->setmeal_id = $setmeal->setmeal_id;
  1725. $profile->setmeal_name = $setmeal->setmeal_name;
  1726. $val->company = $profile;
  1727. $val->contact =$this->jobsContactRepository->getContactInfo(array('job_id'=>$val->id));
  1728. $val->expire = sub_day($val->deadline, time());
  1729. $val->contents = htmlspecialchars_decode($val->contents, ENT_QUOTES);
  1730. $val->refresh_time_cn = daterange(time(), $val->refresh_time, 'Y-m-d', "#FF3300");
  1731. $val->company_url = route(url_rewrite('AIX_companyshow'), array('id'=>$val->company_id));
  1732. if ($val->company->logo) {
  1733. $val->company->logo=upload_asset($val->company->logo);
  1734. } else {
  1735. $val->company->logo = public_data_path('data/upload/no_logo.png');
  1736. }
  1737. if ($val->company->website) {
  1738. $val->company->website_ = $val->company->website;
  1739. if ((strstr($val->company->website, "http://") === false) && (strstr($val->company->website, "https://") === false)) {
  1740. $val->company->website = "http://".$val->company->website;
  1741. } else {
  1742. if (strstr($val->company->website, "http://") === false) {
  1743. $val->company->website_ = str_replace("https://", "", $val->company->website_);
  1744. } else {
  1745. $val->company->website_ = str_replace("http://", "", $val->company->website_);
  1746. }
  1747. }
  1748. }
  1749. //薪资待遇
  1750. if ($val->wage > 0) {
  1751. $wage_category = $this->categoryRepository->getOriginCategory(array('alias'=>'AIX_wage','id'=>$val->wage));
  1752. if ($wage_category && preg_match_all('(\d+)', $wage_category->demand, $reg)) {
  1753. $reg = $reg[0];
  1754. if (config('aix.system.site_other.site_other.site_salary') == 1) {
  1755. $val->minwage = $reg[0]%1000==0?(($reg[0]/1000).'K'):(round($reg[0]/1000, 1).'K');
  1756. $val->maxwage = array_has($reg, 1)?($reg[1]%1000==0?(($reg[1]/1000).'K'):(round($reg[1]/1000, 1).'K')):0;
  1757. } elseif (config('aix.system.site_other.site_other.site_salary') == 2) {
  1758. if ($reg[0] >= 10000) {
  1759. if ($reg[0]%10000 == 0) {
  1760. $val->minwage = ($reg[0]/10000).'万';
  1761. } else {
  1762. $minwage = round($reg[0]/10000, 1);
  1763. $val->minwage = strpos($minwage, '.') ? str_replace('.', '万', $minwage) : $minwage.'万';
  1764. }
  1765. } else {
  1766. if ($reg[0]%1000 == 0) {
  1767. $val->minwage = ($reg[0]/1000).'千';
  1768. } else {
  1769. $minwage = round($reg[0]/1000, 1);
  1770. $val->minwage = strpos($minwage, '.') ? str_replace('.', '千', $minwage) : $minwage.'千';
  1771. }
  1772. }
  1773. if (array_has($reg, 1)) {
  1774. if ($reg[1] >= 10000) {
  1775. if ($reg[1]%10000 == 0) {
  1776. $val->maxwage = ($reg[1]/10000).'万';
  1777. } else {
  1778. $maxwage = round($reg[1]/10000, 1);
  1779. $val->maxwage = strpos($maxwage, '.') ? str_replace('.', '万', $maxwage) : $maxwage.'万';
  1780. }
  1781. } elseif ($reg[1]) {
  1782. if ($reg[1]%1000 == 0) {
  1783. $val->maxwage = ($reg[1]/1000).'千';
  1784. } else {
  1785. $maxwage = round($reg[1]/1000, 1);
  1786. $val->maxwage = strpos($maxwage, '.') ? str_replace('.', '千', $maxwage) : $maxwage.'千';
  1787. }
  1788. } else {
  1789. $val->maxwage = 0;
  1790. }
  1791. } else {
  1792. $val->maxwage = 0;
  1793. }
  1794. }
  1795. } else {
  1796. $val->maxwage = 0;
  1797. }
  1798. if ($val->minwage == $val->maxwage) {
  1799. $val->wage_cn = $val->minwage.'/月';
  1800. } else {
  1801. if ($val->minwage>0 && $val->maxwage==0) {
  1802. $val->wage_cn = $val->minwage.'以上/月';
  1803. } else {
  1804. $val->wage_cn = $val->minwage.'~'.$val->maxwage.'/月';
  1805. }
  1806. }
  1807. } elseif ($val->wage == -1) {
  1808. $val->wage_cn = '面议';
  1809. } else {
  1810. //自定义薪资
  1811. $maxwage = $val->wage_max;
  1812. $minwage = $val->wage_min;
  1813. if ($val->ygxs == '363') {
  1814. $val->wage_cn = $val->wage_min . '元/小时';
  1815. } else {
  1816. if (config('aix.system.site_other.site_other.site_salary') == 1) {
  1817. $val->minwage = $minwage % 1000 == 0 ? (($minwage / 1000) . 'K') : (round($minwage / 1000, 1) . 'K');
  1818. if ($minwage == 0) {
  1819. $val->maxwage = '以上';
  1820. } else {
  1821. $val->maxwage = $maxwage % 1000 == 0 ? (($maxwage / 1000) . 'K') : (round($maxwage / 1000, 1) . 'K');
  1822. }
  1823. } elseif (config('aix.system.site_other.site_other.site_salary') == 2) {
  1824. if ($minwage >= 10000) {
  1825. if ($minwage % 10000 == 0) {
  1826. $val->minwage = ($minwage / 10000) . '万';
  1827. } else {
  1828. $minwage = round($minwage / 10000, 1);
  1829. $val->minwage = strpos($minwage, '.') ? str_replace('.', '万', $minwage) : $minwage . '万';
  1830. }
  1831. } else {
  1832. if ($minwage % 1000 == 0) {
  1833. $val->minwage = ($minwage / 1000) . '千';
  1834. } else {
  1835. $minwage = round($minwage / 1000, 1);
  1836. $val->minwage = strpos($minwage, '.') ? str_replace('.', '千', $minwage) : $minwage . '千';
  1837. }
  1838. }
  1839. if ($maxwage > 0) {
  1840. if ($maxwage >= 10000) {
  1841. if ($maxwage % 10000 == 0) {
  1842. $val->maxwage = ($maxwage / 10000) . '万';
  1843. } else {
  1844. $maxwage = round($maxwage / 10000, 1);
  1845. $val->maxwage = strpos($maxwage, '.') ? str_replace('.', '万', $maxwage) : $maxwage . '万';
  1846. }
  1847. } elseif ($maxwage) {
  1848. if ($maxwage % 1000 == 0) {
  1849. $val->maxwage = ($maxwage / 1000) . '千';
  1850. } else {
  1851. $maxwage = round($maxwage / 1000, 1);
  1852. $val->maxwage = strpos($maxwage, '.') ? str_replace('.', '千', $maxwage) : $maxwage . '千';
  1853. }
  1854. } else {
  1855. $val->maxwage = '0';
  1856. }
  1857. } else {
  1858. $val->maxwage = '0';
  1859. }
  1860. }
  1861. if ($val->minwage == $val->maxwage) {
  1862. $val->wage_cn = $val->minwage . '/月';
  1863. } else {
  1864. if ($val->minwage > 0 && $val->maxwage == 0) {
  1865. $val->wage_cn = $val->minwage . '以上/月';
  1866. } else {
  1867. $val->wage_cn = $val->minwage . '~' . $val->maxwage . '/月';
  1868. }
  1869. }
  1870. }
  1871. }
  1872. $age = $val->age;
  1873. if (count($age)>1) {
  1874. if (!$age[0] && !$age[1]) {
  1875. $val->age_cn = '不限';
  1876. } else {
  1877. if ($age[0] && $age[1]) {
  1878. $val->age_cn = $age[0].'-'.$age[1].'岁';
  1879. } else {
  1880. $age[0] && $val->age_cn = $age[0].'岁以上';
  1881. $age[1] && $val->age_cn = $age[1].'岁以下';
  1882. }
  1883. }
  1884. } else {
  1885. $val->age_cn = $val->age_cn = (int)$age[0].'岁以上';
  1886. }
  1887. $other_categories = $this->categoryRepository->getCategories();
  1888. //企业性质
  1889. if ($other_categories) {
  1890. $company_types = array_get($other_categories, 'AIX_company_type');
  1891. if ($company_types) {
  1892. $type_cn = array_get($company_types, $val->company->nature);
  1893. if ($type_cn) {
  1894. $val->company->nature_cn = $type_cn['demand'];
  1895. }
  1896. }
  1897. //企业行业
  1898. $company_trades = array_get($other_categories, 'AIX_trade');
  1899. if ($company_trades) {
  1900. $trade_cn = array_get($company_trades, $val->company->trade);
  1901. if ($trade_cn) {
  1902. $val->company->trade_cn = $trade_cn['demand'];
  1903. }
  1904. }
  1905. //企业规模
  1906. $company_scales = array_get($other_categories, 'AIX_scale');
  1907. if ($company_scales) {
  1908. $scale_cn = array_get($company_scales, $val->company->scale);
  1909. if ($scale_cn) {
  1910. $val->company->scale_cn = $scale_cn['demand'];
  1911. }
  1912. }
  1913. } else {
  1914. $val->company->nature_cn = '';
  1915. $val->company->trade_cn = '';
  1916. $val->company->scale_cn = '';
  1917. }
  1918. //标签
  1919. $job_tags = array();
  1920. if ($other_categories) {
  1921. $job_tags = array_get($other_categories, 'AIX_jobtag');
  1922. }
  1923. if (implode(',', $val->tag)) {
  1924. $tag_cn = array();
  1925. foreach ($val->tag as $k => $v) {
  1926. $tag = array_get($job_tags, $v);
  1927. $tag_cn[] = $tag['demand'];
  1928. }
  1929. $val->tag_cn = $tag_cn;
  1930. } else {
  1931. $val->tag_cn = array();
  1932. }
  1933. if ($other_categories) {
  1934. //工作性质
  1935. $job_nature = array_get($other_categories, 'AIX_jobs_nature');
  1936. if ($job_nature) {
  1937. $nature_cn = array_get($job_nature, $val->nature);
  1938. if ($nature_cn) {
  1939. $val->nature_cn = $nature_cn['demand'];
  1940. } else {
  1941. $val->nature_cn = '不限';
  1942. }
  1943. }
  1944. //工作经验
  1945. $job_experience = array_get($other_categories, 'AIX_experience');
  1946. if ($job_experience) {
  1947. $experience_cn = array_get($job_experience, $val->experience);
  1948. }
  1949. if ($experience_cn) {
  1950. $val->experience_cn = $experience_cn['demand'];
  1951. } else {
  1952. $val->experience_cn = '不限';
  1953. }
  1954. //学历要求
  1955. $job_education = array_get($other_categories, 'AIX_education');
  1956. if ($job_education) {
  1957. $education_cn = array_get($job_education, $val->education);
  1958. }
  1959. if ($education_cn) {
  1960. $val->education_cn = $education_cn['demand'];
  1961. } else {
  1962. $val->education_cn = '不限';
  1963. }
  1964. //职位类别
  1965. $categories = array();
  1966. if (Cache::has('jobs_cate_list')) {
  1967. $categories = Cache::get('jobs_cate_list');
  1968. } else {
  1969. $categories = $this->categoryJobsRepository->jobsCateInfoCache();
  1970. Cache::put('jobs_cate_list', $categories, '86400');
  1971. }
  1972. $category = array();
  1973. if ($val->subclass) {
  1974. $category = array_get($categories['id'], $val->subclass);
  1975. } elseif ($val->category) {
  1976. $category = array_get($categories['id'], $val->category);
  1977. } elseif ($val->topclass) {
  1978. $category = array_get($categories['id'], $val->topclass);
  1979. }
  1980. if ($category) {
  1981. $val->category_cn = $category['name'];
  1982. } else {
  1983. $val->category_cn = '';
  1984. }
  1985. //职位类别
  1986. if ($this->app_spell) {
  1987. $spell = $val->category ? $val->category : $val->topclass;
  1988. if ($spell) {
  1989. $val->jobcategory = $categories['id'][$spell]['spell'];
  1990. } else {
  1991. $val->jobcategory = '';
  1992. }
  1993. $val->jobcategory_id = $spell;
  1994. } else {
  1995. $val->jobcategory = intval($val->topclass).".".intval($val->category).".0";
  1996. $val->jobcategory_id = $val->category ? $val->category : $val->topclass;
  1997. }
  1998. //用工形式
  1999. $company_ygxs = array_get($other_categories, 'AIX_ygxs');
  2000. if ($company_ygxs) {
  2001. $ygxs_cn = array_get($company_ygxs, $val->ygxs);
  2002. if ($ygxs_cn) {
  2003. $val->ygxs_cn = $ygxs_cn['demand'];
  2004. } else {
  2005. $val->ygxs_cn = '不限';
  2006. }
  2007. }
  2008. //技能等级
  2009. $techlevels = array_get($other_categories, 'AIX_techlevel');
  2010. if ($techlevels) {
  2011. $techlevel_cn = array_get($techlevels, $val->techlevel);
  2012. if ($techlevel_cn) {
  2013. $val->techlevel_cn = $techlevel_cn['demand'];
  2014. } else {
  2015. $val->techlevel_cn = '不限';
  2016. }
  2017. }
  2018. //试用期
  2019. $syqs = array_get($other_categories, 'zs_syq');
  2020. if ($syqs) {
  2021. if (empty($val->syq)) {
  2022. $val->syq = 367;
  2023. }
  2024. $syq_cn = array_get($syqs, $val->syq);
  2025. if ($syq_cn) {
  2026. $val->syq_cn = $syq_cn['demand'];
  2027. } else {
  2028. $val->syq_cn = '无';
  2029. }
  2030. }
  2031. //试用期工资:
  2032. if ($val->wage == -1) {
  2033. $val->syqxz_min_cn='面议';
  2034. } else {
  2035. $val->syqxz_min_cn=$val->syqxz_min.'元/月';
  2036. }
  2037. }
  2038. //性别要求
  2039. if ($val->sex =='1') {
  2040. $val->sex_cn = '男';
  2041. } elseif ($val->sex =='2') {
  2042. $val->sex_cn = '女';
  2043. } else {
  2044. $val->sex_cn = '不限';
  2045. }
  2046. //工作地点
  2047. $city_cates = Cache::get('city_cate_list');
  2048. if (null === $city_cates) {
  2049. $city_cates = $this->categoryDistrictRepository->cityCateCache();
  2050. Cache::put('city_cate_list', $city_cates, '86400');
  2051. }
  2052. if (!strpos($val->district, ".")) {
  2053. if (array_get($city_cates['id'], $val->district)) {
  2054. $val->district_cn = $city_cates['id'][$val->district]['name'];
  2055. if ($city_cates['id'][$val->district]['parent_id'] > 0) {
  2056. $parent_district = array_get($city_cates['id'], $city_cates['id'][$val->district]['parent_id']);
  2057. if ($parent_district) {
  2058. $val->district_cn = $parent_district['name'].$val->district_cn;
  2059. if ($parent_district['parent_id'] > 0) {
  2060. $pp_district = array_get($city_cates['id'], $parent_district['parent_id']);
  2061. if ($pp_district) {
  2062. $val->district_cn = $pp_district['name'].$val->district_cn;
  2063. }
  2064. }
  2065. }
  2066. }
  2067. }
  2068. } else {
  2069. $city_district = explode('.', $val->district);
  2070. $city_district_cn = array();
  2071. foreach ($city_district as $k => $v) {
  2072. if ($v) {
  2073. $district_info = array_get($city_cates['id'], $v);
  2074. if ($district_info) {
  2075. $city_district_cn[] = $district_info['name'];
  2076. }
  2077. }
  2078. }
  2079. $val->district_cn = implode('/', $city_district_cn);
  2080. }
  2081. //企业所在地区
  2082. if (!strpos($val->company->district, ".")) { //直接读取地区信息
  2083. $district_cn = array_get($city_cates['id'], $val->company->district);
  2084. if ($district_cn) {
  2085. $val->company->district_cn = $district_cn['name'];
  2086. }
  2087. } else {//处理地区信息
  2088. $c_district = explode('.', $val->company->district);
  2089. $district_cn = [];
  2090. foreach ($c_district as $k => $v) {
  2091. if ($v) {
  2092. $district_info = array_get($city_cates['id'], $v);
  2093. if ($district_info) {
  2094. $district_cn[] = $district_info['name'];
  2095. }
  2096. }
  2097. }
  2098. $district_cn = implode('/', $district_cn);
  2099. $val->company->district_cn = $district_cn;
  2100. }
  2101. //处理联系方式是否显示
  2102. $hide = true;
  2103. if (isMobile()) {
  2104. $showjobcontact = config('aix.companyset.comset.contact_set.showjobcontact_wap');
  2105. } else {
  2106. $showjobcontact = config('aix.companyset.comset.contact_set.showjobcontact');
  2107. }
  2108. if ($showjobcontact == 0) {
  2109. $hide = false;
  2110. } elseif ($showjobcontact == 1) {
  2111. if ($user) {
  2112. $hide = false;
  2113. }
  2114. }
  2115. //判断是否是企业用户自己创建的职位
  2116. if ($hide) {
  2117. if ($user && $user->utype ==1 && $val->company_id == $user->id) {
  2118. $hide = false;
  2119. }
  2120. }
  2121. $val->contact->telephone_all = $val->contact->telephone;
  2122. if ($hide) {
  2123. if ($val->contact->telephone) {
  2124. $val->contact->telephone = contact_hide($val->contact->telephone);
  2125. } else {
  2126. $val->contact->telephone = contact_hide(trim(implode('-', $val->contact->landline_tel), '-'), 1);
  2127. }
  2128. } else {
  2129. if ($user && $user->utype ==1 && $val->company_id == $user->id) {
  2130. $val->contact->contact_show = 1;
  2131. $val->contact->telephone_show = 1;
  2132. if (!$val->contact->telephone) {
  2133. $val->contact->telephone = trim(implode('-', $val->contact->landline_tel), '-');
  2134. }
  2135. } else {
  2136. if ($val->contact->telephone_show==0 && $val->contact->landline_tel_show==0) {
  2137. $val->contact->telephone_show = 0;
  2138. } elseif ($val->contact->telephone_show==1 && $val->contact->telephone) {
  2139. $val->contact->telephone_show = $val->contact->telephone_show;
  2140. } elseif ($val->contact->telephone && (!$val->contact->landline_tel || ($val->contact->landline_tel && !trim(implode('-', $val->contact->landline_tel), '-'))) && $val->contact->telephone_show==0) {
  2141. $val->contact->telephone_show = $val->contact->telephone_show;
  2142. } else {
  2143. $val->contact->telephone = trim(implode('-', $val->contact->landline_tel), '-');
  2144. $val->contact->telephone_show = $val->contact->landline_tel_show;
  2145. }
  2146. }
  2147. }
  2148. $val->contact->telephone_ = $val->contact->telephone;
  2149. if (config('aix.companyset.comset.contact_type_set.contact_img_com') == 2) {
  2150. $pwdhash = config('aix.system.site_other.site_other.pwb_hash');
  2151. $val->contact->telephone = "<img src='".route('common.contact_img', array('text'=>encrypt($val->contact->telephone, $pwdhash),'type'=>'phone'))."' />";
  2152. } elseif (config('aix.companyset.comset.contact_type_set.contact_img_com') == 3 && C('LOG_SOURCE')!=2) {// 扫码获取
  2153. $val->contact->telephone = '';
  2154. }
  2155. $val->hide = $hide;
  2156. //简历处理效率
  2157. $app_where[] = array('jobs_id','=',$val->id);
  2158. $app_where[] = array('created_at','>',date('Y-m-d H:i:s', strtotime("-14day")));
  2159. $apply = $this->personalJobsApplyRepository->getJobsApply($app_where);
  2160. $val->deliver = 0;
  2161. $reply = 0;
  2162. $reply_time = 0;
  2163. foreach ($apply as $key => $v) {
  2164. if ($v->is_reply) {
  2165. $reply++;
  2166. if ($v->reply_time) {
  2167. $reply_time += $v->reply_time - strtotime($v->created_at);
  2168. }
  2169. }
  2170. if ($user && $user->utype==2 && $user->id == $v->personal_uid) {
  2171. $val->deliver = 1;
  2172. }
  2173. }
  2174. if (count($apply)) {
  2175. $val->company->reply_ratio = !$apply ? '0%' : intval($reply / count($apply) * 100).'%';
  2176. } else {
  2177. $val->company->reply_ratio = '0%';
  2178. }
  2179. $val->company->reply_time = !$reply_time ? '0天' : sub_day(intval($reply_time / count($apply)), 0);
  2180. if (!$val->company->last_login_time) {
  2181. $val->company->last_login_time = '未登录';
  2182. }
  2183. if ($user && $user->utype == 2) {
  2184. $resume = $this->resumeRepository->getPersonInfo($user->id);
  2185. $val->resume = $resume;
  2186. if ($resume) {
  2187. $val->resume->url = route(url_rewrite('AIX_resumeshow'), ['id'=>$val->resume->id]);
  2188. }
  2189. //判断是否在黑名单
  2190. $shield_where = [
  2191. 'uid' => $user->id,
  2192. 'company_id' => $val->company_id
  2193. ];
  2194. if(!$this->ResumePrivacyRepository->getShield($shield_where))
  2195. {
  2196. //没有记录访问记录
  2197. $log_where = array('uid'=>$user->id,'job_id'=>$val->id);
  2198. $view_log = $this->viewJobRepository->getLog($log_where, 1);
  2199. if ($view_log) {
  2200. $log_data = array('updated_at' => date('Y-m-d H:i:s', time()));
  2201. $this->viewJobRepository->update($log_data, $log_where);
  2202. } else {
  2203. $time = date('Y-m-d H:i:s', time());
  2204. $log_data = array(
  2205. 'uid' => $user->id,
  2206. 'job_id' => $val->id,
  2207. 'company_id' => $val->company_id,
  2208. 'created_at' => $time,
  2209. 'updated_at' => $time
  2210. );
  2211. $this->viewJobRepository->addLog($log_data);
  2212. }
  2213. }
  2214. //检测是否已收藏
  2215. $favor_log = $this->personFavoriteRepository->getInfo(array('job_id'=>$val->id,'uid'=>$user->id));
  2216. if ($favor_log) {
  2217. $val->favor = 1;
  2218. } else {
  2219. $val->favor = 0;
  2220. }
  2221. } else {
  2222. $val->favor = 0;
  2223. }
  2224. //来源分站名称
  2225. $subsites = Cache::get('subsites_list');
  2226. if (array_has($subsites, $val->subsite_id)) {
  2227. $val->subsite_cn = $subsites[$val->subsite_id]['sitename'];
  2228. } else {
  2229. $val->subsite_cn = '';
  2230. }
  2231. // if(!$this->memberLogRepository->createLog(auth('web-company')->user(),2034,$where['id'])){
  2232. // throw new \Exception("日志记失败!");
  2233. // }
  2234. return ['status'=>1, 'job'=>$val];
  2235. }
  2236. public function incrementData($where, $num, $filed)
  2237. {
  2238. return $this->jobsRepository->incrementData($where, $num, $filed);
  2239. }
  2240. //获取紧急招聘职位
  2241. public function getEmergencyJobs($limit = '')
  2242. {
  2243. $emergency_jobs = array();
  2244. $emergency_where = array(
  2245. array('valid','=','1'),
  2246. array('emergency','=','1')
  2247. );
  2248. if (config('aix.companyset.comset.show_set.jobs_display')==1) {
  2249. $emergency_where[] = array('audit','=',1);
  2250. } else {
  2251. $emergency_where[] = array('audit','<>',3);
  2252. }
  2253. $emergency_where[] = array('display','=',1);
  2254. $emergency_where[] = array('valid','=',1);
  2255. $emergency_jobs = $this->getOtherJobs($emergency_where, $limit);
  2256. return $emergency_jobs;
  2257. }
  2258. //获取最新职位
  2259. public function getNewJobs($limit = '')
  2260. {
  2261. $new_jobs = array();
  2262. $where = array(
  2263. array('valid','=','1'),
  2264. );
  2265. if (config('aix.companyset.comset.show_set.jobs_display')==1) {
  2266. $where[] = array('audit','=',1);
  2267. } else {
  2268. $where[] = array('audit','<>',3);
  2269. }
  2270. $where[] = array('display','=',1);
  2271. $where[] = array('valid','=',1);
  2272. $where[] = array('deadline','>',time());
  2273. $jobs = $this->jobsRepository->getCompanyJobs($where, array(), array('refresh_time'=>'desc'), $limit);
  2274. if ($jobs->isNotEmpty()) {
  2275. $other_categories = $this->categoryRepository->getCategories();
  2276. if ($other_categories) {
  2277. $wages = array_get($other_categories, 'AIX_wage');
  2278. $educations = array_get($other_categories, 'AIX_education');
  2279. $experiences = array_get($other_categories, 'AIX_experience');
  2280. $natures = array_get($other_categories, 'AIX_job_nature');
  2281. } else {
  2282. $wages = array();
  2283. $educations = array();
  2284. $experiences = array();
  2285. $natures = array();
  2286. }
  2287. $city_cates = Cache::get('city_cate_list');
  2288. if (null === $city_cates) {
  2289. $city_cates = $this->categoryDistrictRepository->cityCateCache();
  2290. Cache::put('city_cate_list', $city_cates, '86400');
  2291. }
  2292. foreach ($jobs as $k => $v) {
  2293. //修改薪资信息
  2294. $jobs[$k]->wage_cn = '薪资面议';
  2295. if ($wages) {
  2296. if ($wage= array_get($wages, $v->wage)) {
  2297. $jobs[$k]->wage_cn = $wage['demand'];
  2298. if (config('aix.system.site_other.site_other.site_salary') == 1) {
  2299. $jobs[$k]->wage_cn = array_has($wages, [$v->wage])?$wages[$v->wage]['k_demand']:'面议';
  2300. } elseif (config('aix.system.site_other.site_other.site_salary') == 2) {
  2301. $jobs[$k]->wage_cn = array_has($wages, [$v->wage])?$wages[$v->wage]['c_demand']:'面议';
  2302. }
  2303. }
  2304. }
  2305. //修改学历
  2306. $jobs[$k]->education_cn = '学历不限';
  2307. if ($educations) {
  2308. if ($education = array_get($educations, $v->education)) {
  2309. $jobs[$k]->education_cn = $education['demand'];
  2310. }
  2311. }
  2312. //工作经验
  2313. $jobs[$k]->experience_cn = '经验不限';
  2314. if ($experiences) {
  2315. if ($experience = array_get($experiences, $v->experience)) {
  2316. $jobs[$k]->experience_cn = $experience['demand'];
  2317. }
  2318. }
  2319. //职位性质
  2320. $jobs[$k]->nature_cn = '不限';
  2321. if ($natures) {
  2322. if ($nature = array_get($natures, $v->nature)) {
  2323. $jobs[$k]->nature_cn = $nature['demand'];
  2324. }
  2325. }
  2326. //修改工作所在地
  2327. $jobs[$k]->district_cn ='';
  2328. if (!strpos($v->district, ".")) {
  2329. $district_cn = array_get($city_cates['id'], $v->district);
  2330. if ($district_cn) {
  2331. $jobs[$k]->district_cn = $district_cn['name'];
  2332. }
  2333. } else {
  2334. $c_district = explode('.', $v->district);
  2335. $district_cn = array();
  2336. foreach ($c_district as $j => $val) {
  2337. if ($val) {
  2338. $district_info = array_get($city_cates['id'], $val);
  2339. if ($district_info) {
  2340. $district_cn[] = $district_info['name'];
  2341. }
  2342. }
  2343. }
  2344. $district_cn = implode('/', $district_cn);
  2345. $jobs[$k]->district_cn = $district_cn;
  2346. }
  2347. //企业logo
  2348. $company = $v->company;
  2349. if ($company->logo) {
  2350. $jobs[$k]->company_logo=upload_asset($company->logo);
  2351. } else {
  2352. $jobs[$k]->company_logo = public_data_path('data/upload/no_logo.png');
  2353. }
  2354. }
  2355. $new_jobs = $jobs;
  2356. }
  2357. return $new_jobs;
  2358. }
  2359. public function getOtherJobs($where, $limit = '')
  2360. {
  2361. $lists = $this->jobsRepository->getOtherJobs($where, $limit);
  2362. if (!$lists->toArray()) {
  2363. return $lists;
  2364. } else {
  2365. $other_categories = $this->categoryRepository->getCategories();
  2366. if ($other_categories) {
  2367. $wages = array_get($other_categories, 'AIX_wage');
  2368. $educations = array_get($other_categories, 'AIX_education');
  2369. $experiences = array_get($other_categories, 'AIX_experience');
  2370. $natures = array_get($other_categories, 'AIX_job_nature');
  2371. } else {
  2372. $wages = array();
  2373. $educations = array();
  2374. $experiences = array();
  2375. $natures = array();
  2376. }
  2377. $city_cates = Cache::get('city_cate_list');
  2378. if (null === $city_cates) {
  2379. $city_cates = $this->categoryDistrictRepository->cityCateCache();
  2380. Cache::put('city_cate_list', $city_cates, '86400');
  2381. }
  2382. foreach ($lists as $k => $v) {
  2383. //修改薪资信息
  2384. $lists[$k]->wage_cn = '面议';
  2385. if ($v->wage >0) {
  2386. if ($wages) {
  2387. if ($wage= array_get($wages, $v->wage)) {
  2388. $lists[$k]->wage_cn = $wage['demand'];
  2389. if (config('aix.system.site_other.site_other.site_salary') == 1) {
  2390. $lists[$k]->wage_cn = array_has($wages, [$v->wage])?$wages[$v->wage]['k_demand']:'面议';
  2391. } elseif (config('aix.system.site_other.site_other.site_salary') == 2) {
  2392. $lists[$k]->wage_cn = array_has($wages, [$v->wage])?$wages[$v->wage]['c_demand']:'面议';
  2393. }
  2394. }
  2395. }
  2396. } elseif ($v->wage == 0) {
  2397. $lists[$k]->wage_cn = $this->dealWage($v->wage, $v->wage_min, $v->wage_max);
  2398. }
  2399. //修改学历
  2400. $lists[$k]->education_cn = '学历不限';
  2401. if ($educations) {
  2402. if ($education = array_get($educations, $v->education)) {
  2403. $lists[$k]->education_cn = $education['demand'];
  2404. }
  2405. }
  2406. //工作经验
  2407. $lists[$k]->experience_cn = '经验不限';
  2408. if ($experiences) {
  2409. if ($experience = array_get($experiences, $v->experience)) {
  2410. $lists[$k]->experience_cn = $experience['demand'];
  2411. }
  2412. }
  2413. //职位性质
  2414. $lists[$k]->nature_cn = '不限';
  2415. if ($natures) {
  2416. if ($nature = array_get($natures, $v->nature)) {
  2417. $lists[$k]->nature_cn = $nature['demand'];
  2418. }
  2419. }
  2420. //修改工作所在地
  2421. $lists[$k]->district_cn ='';
  2422. if (!strpos($v->district, ".")) {
  2423. $district_cn = array_get($city_cates['id'], $v->district);
  2424. if ($district_cn) {
  2425. $lists[$k]->district_cn = $district_cn['name'];
  2426. }
  2427. } else {
  2428. $c_district = explode('.', $v->district);
  2429. $district_cn = array();
  2430. foreach ($c_district as $j => $val) {
  2431. if ($val) {
  2432. $district_info = array_get($city_cates['id'], $val);
  2433. if ($district_info) {
  2434. $district_cn[] = $district_info['name'];
  2435. }
  2436. }
  2437. }
  2438. $district_cn = implode('/', $district_cn);
  2439. $lists[$k]->district_cn = $district_cn;
  2440. }
  2441. //年龄限制
  2442. if (is_array($v->age)) {
  2443. if (implode('', $v->age)=='') {
  2444. $lists[$k]->age_cn = '不限';
  2445. } else {
  2446. $lists[$k]->age_cn = implode('-', $v->age).'岁';
  2447. }
  2448. } else {
  2449. if ($v->age == '-' || $v->age == '0') {
  2450. $lists[$k]->age_cn = '不限';
  2451. } else {
  2452. $lists[$k]->age_cn = $v->age.'岁';
  2453. }
  2454. }
  2455. $lists[$k]->refresh_time_cn = date('Y-m-d', $v->refresh_time);
  2456. }
  2457. }
  2458. return $lists;
  2459. }
  2460. //收藏职位
  2461. public function jobFavor($job_id)
  2462. {
  2463. if (!$job_id) {
  2464. throw new ResponseException('请选择要收藏的职位!');
  2465. }
  2466. if (!is_array($job_id)) {
  2467. $jobs_id = explode(',', $job_id);
  2468. } else {
  2469. $jobs_id = $job_id;
  2470. }
  2471. if (count($jobs_id) == 1) { //单个收藏
  2472. $jobInfo = $this->jobsRepository->getJobsById($job_id);
  2473. if (!$jobInfo) {
  2474. throw new ResponseException('请选择有效职位!');
  2475. }
  2476. //判断当前职位是否已收藏
  2477. $uid = auth('web-member')->user()->id;
  2478. $favor_log = $this->personFavoriteRepository->getInfo(array('job_id'=>$job_id,'uid'=>$uid));
  2479. if ($favor_log) {
  2480. //throw new ResponseException('您已经收藏该职位,不能重复收藏!');
  2481. //取消收藏
  2482. $cancel_rst = $this->personFavoriteRepository->cancelFavor(array('job_id'=>$job_id,'uid'=>$uid));
  2483. if (!$cancel_rst) {
  2484. throw new ResponseException('取消收藏失败!');
  2485. }
  2486. //return true;
  2487. return 1;
  2488. }
  2489. $time = date('Y-m-d H:i:s', time());
  2490. $favor_data = array(
  2491. 'uid' => $uid,
  2492. 'job_id' => $job_id,
  2493. 'job_name' => $jobInfo->jobs_name,
  2494. 'created_at' => $time,
  2495. 'updated_at'=>$time
  2496. );
  2497. $add_res = $this->personFavoriteRepository->addData($favor_data);
  2498. if ($add_res) {
  2499. //return true;
  2500. return 2;
  2501. } else {
  2502. throw new ResponseException('收藏失败!');
  2503. }
  2504. } else {
  2505. //批量收藏
  2506. //获取所选有效职位信息
  2507. //获取当前用户收藏的所有职位信息
  2508. //所选职位是否已收藏,组成添加数据
  2509. $jobs = $this->jobsRepository->getJobs($jobs_id);
  2510. $fav_jobs = $this->getFavoriteJobs(array('uid'=>auth('web-member')->user()->id), 'job_id');
  2511. $fav_data = array();
  2512. $stime = date('Y-m-d H:i:s', time());
  2513. foreach ($jobs as $k => $v) {
  2514. if (!$fav_jobs || ($fav_jobs && !array_has($fav_jobs, $v->id))) {
  2515. $fav_data[] = array(
  2516. 'uid' => auth('web-member')->user()->id,
  2517. 'job_id' => $v->id,
  2518. 'job_name' => $v->jobs_name,
  2519. 'created_at' => $stime,
  2520. 'updated_at' => $stime
  2521. );
  2522. }
  2523. }
  2524. if ($fav_data) {
  2525. $rst = $this->personFavoriteRepository->insertData($fav_data);
  2526. if ($rst) {
  2527. return true;
  2528. } else {
  2529. throw new ResponseException('收藏失败!');
  2530. }
  2531. } else {
  2532. throw new ResponseException('您已经收藏所选职位,不能重复收藏!');
  2533. }
  2534. }
  2535. }
  2536. //获取企业会员审核通过的职位(有效、通过审核(后台职位显示设置要求)、在招的职位)
  2537. public function getAuditJobs($company_id)
  2538. {
  2539. $where = array(
  2540. array('company_id','=',$company_id),
  2541. array('valid','=','1'),
  2542. array('display','=','1')
  2543. );
  2544. if (config('aix.companyset.comset.show_set.jobs_display') == 1) {
  2545. $where[] = array('audit','=', '1');
  2546. } else {
  2547. $where[] = array('audit','<>', '3');
  2548. }
  2549. return $this->jobsRepository->getOtherJobsCount($where);
  2550. }
  2551. public function getAuditJobsNum($company_id)
  2552. {
  2553. $rst = $this->getAuditJobs($company_id);
  2554. return count($rst);
  2555. }
  2556. public function dealjobList($data, $limit)
  2557. {
  2558. $list = array();
  2559. if ($data) {
  2560. $wage_categories = $this->categoryRepository->getCategories();
  2561. foreach ($data as $key => $val) {
  2562. if ($limit && ($key >= $limit)) {
  2563. break;
  2564. }
  2565. $list[$key] = $val;
  2566. //薪资字段
  2567. if ($val->wage > 0) {
  2568. if ($wage_categories) {
  2569. if (config('aix.system.site_other.site_other.site_salary') == 1) {
  2570. $list[$key]->wage_cn = array_has($wage_categories['AIX_wage_k'], [$val->wage])?$wage_categories['AIX_wage_k'][$val->wage]:'面议';
  2571. } elseif (config('aix.system.site_other.site_other.site_salary') == 2) {
  2572. $list[$key]->wage_cn = array_has($wage_categories['AIX_wage_c'], [$val->wage])?$wage_categories['AIX_wage_c'][$val->wage]:'面议';
  2573. }
  2574. }
  2575. } elseif ($val->wage==0) {
  2576. $list[$key]->wage_cn = $this->dealWage($val->wage, $val->wage_min, $val->wage_max);
  2577. } else {
  2578. $list[$key]->wage_cn = '面议';
  2579. }
  2580. $list[$key]->experience_cn = '经验不限';
  2581. $list[$key]->education_cn = '学历不限';
  2582. $other_categories = $this->categoryRepository->getCategories();
  2583. if ($other_categories) {
  2584. if ($val->experience) {
  2585. $job_experience = array_get($other_categories, 'AIX_experience');
  2586. if ($job_experience) {
  2587. $list[$key]->experience_cn = $job_experience[$val->experience]['demand'];
  2588. }
  2589. }
  2590. if ($val->education) {
  2591. $job_education = array_get($other_categories, 'AIX_education');
  2592. if ($job_education) {
  2593. $list[$key]->education_cn = $job_education[$val->education]['demand'];
  2594. }
  2595. }
  2596. }
  2597. $city_cates = Cache::get('city_cate_list');
  2598. if (null === $city_cates) {
  2599. $city_cates = $this->categoryDistrictRepository->cityCateCache();
  2600. Cache::put('city_cate_list', $city_cates, '86400');
  2601. }
  2602. if (!strpos($val->district, ".")) {
  2603. if (array_get($city_cates['id'], $val->district)) {
  2604. $list[$key]->district_cn = $city_cates['id'][$val->district]['name'];
  2605. if ($city_cates['id'][$val->district]['parent_id'] > 0) {
  2606. $parent_district = array_get($city_cates['id'], $city_cates['id'][$val->district]['parent_id']);
  2607. if ($parent_district) {
  2608. $list[$key]->district_cn = $parent_district['name'].$list[$key]->district_cn;
  2609. if ($parent_district['parent_id'] > 0) {
  2610. $pp_district = array_get($city_cates['id'], $parent_district['parent_id']);
  2611. if ($pp_district) {
  2612. $list[$key]->district_cn = $pp_district['name'].$list[$key]->district_cn;
  2613. }
  2614. }
  2615. }
  2616. }
  2617. }
  2618. } else {
  2619. $city_district = explode('.', $val->district);
  2620. $city_district_cn = array();
  2621. foreach ($city_district as $k => $v) {
  2622. if ($v) {
  2623. $district_info = array_get($city_cates['id'], $v);
  2624. if ($district_info) {
  2625. $city_district_cn[] = $district_info['name'];
  2626. }
  2627. }
  2628. }
  2629. $list[$key]->district_cn = implode('/', $city_district_cn);
  2630. }
  2631. }
  2632. }
  2633. return $list;
  2634. }
  2635. public function dealWage($wage, $minwage, $maxwage,$ygxs = 0)
  2636. {
  2637. // 小时工处理
  2638. $date_str = '月';
  2639. if($ygxs == 363){
  2640. $date_str = '小时';
  2641. }else{
  2642. if (config('aix.system.site_other.site_other.site_salary') == 1) {
  2643. $minwage = $minwage%1000==0?(($minwage/1000).'K'):(round($minwage/1000, 1).'K');
  2644. if ($minwage == 0) {
  2645. $maxwage = '以上';
  2646. } else {
  2647. $maxwage = $maxwage%1000==0?(($maxwage/1000).'K'):(round($maxwage/1000, 1).'K');
  2648. }
  2649. } elseif (config('aix.system.site_other.site_other.site_salary') == 2) {
  2650. if ($minwage >= 10000) {
  2651. if ($minwage%10000 == 0) {
  2652. $minwage = ($minwage/10000).'万';
  2653. } else {
  2654. $minwage = round($minwage/10000, 1);
  2655. $minwage = strpos($minwage, '.') ? str_replace('.', '万', $minwage) : $minwage.'万';
  2656. }
  2657. } else {
  2658. if ($minwage%1000 == 0) {
  2659. $minwage = ($minwage/1000).'千';
  2660. } else {
  2661. $minwage = round($minwage/1000, 1);
  2662. $minwage = strpos($minwage, '.') ? str_replace('.', '千', $minwage) : $minwage.'千';
  2663. }
  2664. }
  2665. if ($maxwage > 0) {
  2666. if ($maxwage >= 10000) {
  2667. if ($maxwage%10000 == 0) {
  2668. $maxwage = ($maxwage/10000).'万';
  2669. } else {
  2670. $maxwage = round($maxwage/10000, 1);
  2671. $maxwage = strpos($maxwage, '.') ? str_replace('.', '万', $maxwage) : $maxwage.'万';
  2672. }
  2673. } elseif ($maxwage) {
  2674. if ($maxwage%1000 == 0) {
  2675. $maxwage = ($maxwage/1000).'千';
  2676. } else {
  2677. $maxwage = round($maxwage/1000, 1);
  2678. $maxwage = strpos($maxwage, '.') ? str_replace('.', '千', $maxwage) : $maxwage.'千';
  2679. }
  2680. } else {
  2681. $maxwage = '0';
  2682. }
  2683. } else {
  2684. $maxwage = '0';
  2685. }
  2686. }
  2687. }
  2688. if ($minwage == $maxwage) {
  2689. if($ygxs == 363){
  2690. $wage_cn = $minwage.'元/'.$date_str;
  2691. }else{
  2692. $wage_cn = $minwage.'/'.$date_str;
  2693. }
  2694. } else {
  2695. if ($minwage>0 && $maxwage==0) {
  2696. $wage_cn = $minwage.'以上/'.$date_str;
  2697. } elseif ($wage==0 && $minwage==0 && $maxwage==0) {
  2698. $wage_cn = $minwage.'以上/'.$date_str;
  2699. } else {
  2700. $wage_cn = $minwage.'~'.$maxwage.'/'.$date_str;
  2701. }
  2702. }
  2703. return $wage_cn;
  2704. }
  2705. public function dealjobFilelds($list, $map_data = array(), $limit = '')
  2706. {
  2707. $favor_jobs = array();
  2708. $apply_jobs = array();
  2709. if (auth('web-member')->check()) {
  2710. //个人用户登录时获取个人收藏的简历信息和一段时间间隔内已申请的职位信息 config('aix.personal_set.per_set.per_set.apply_job_space')
  2711. $favor_where = array('uid'=> auth('web-member')->user()->id);
  2712. $favor_jobs = $this->getFavoriteJobs($favor_where);
  2713. $space_time = (integer)config('aix.personal_set.per_set.per_set.apply_job_space');
  2714. $stime = date('Y-m-d H:i:s', strtotime(date("Y-m-d", strtotime("-".$space_time." day"))));
  2715. $apply_where = array(array('personal_uid','=',auth('web-member')->user()->id),array('created_at','>=',$stime));
  2716. $apply_jobs = $this->getApplyJobs($apply_where);
  2717. }
  2718. $other_categories = $this->categoryRepository->getCategories();
  2719. $wage_categories = $this->categoryRepository->getCategories();
  2720. $city_cates = Cache::get('city_cate_list');
  2721. if (null === $city_cates) {
  2722. $city_cates = $this->categoryDistrictRepository->cityCateCache();
  2723. Cache::put('city_cate_list', $city_cates, '86400');
  2724. }
  2725. $categories = array();
  2726. if (Cache::has('jobs_cate_list')) {
  2727. $categories = Cache::get('jobs_cate_list');
  2728. } else {
  2729. $categories = $this->categoryJobsRepository->jobsCateInfoCache();
  2730. Cache::put('jobs_cate_list', $categories, '86400');
  2731. }
  2732. $filter_lat = '';
  2733. $filter_lng = '';
  2734. if ($map_data) {
  2735. $filter_lng = $map_data['lng'];
  2736. $filter_lat = $map_data['lat'];
  2737. }
  2738. $return_list = array();
  2739. foreach ($list as $key => $val) {
  2740. if ($limit && ($key >= $limit)) {
  2741. break;
  2742. }
  2743. $return_list[$key] = $val;
  2744. if (!$val->company) {
  2745. $companyInfo = $this->companyRepository->getCompanyInfo(['id'=>$val->company_id]);
  2746. $return_list[$key]->company = $companyInfo;
  2747. $val->company = $companyInfo;
  2748. $val->company->membersSetmeal = $this->membersSetmealRepository->getSetmealByUid($companyInfo->id, 1);
  2749. }
  2750. //套餐图片
  2751. if ($val->company->membersSetmeal) {
  2752. $val->setmeal_img = $val->company->membersSetmeal->setmeal_img;
  2753. } else {
  2754. $val->setmeal_img = null;
  2755. }
  2756. if ($favor_jobs && array_has($favor_jobs, $val->id)) {
  2757. $return_list[$key]->has_favor = 1;
  2758. } else {
  2759. $return_list[$key]->has_favor = 0;
  2760. }
  2761. if ($apply_jobs && array_has($apply_jobs, $val->id)) {
  2762. $return_list[$key]->has_deliver = 1;
  2763. } else {
  2764. $return_list[$key]->has_deliver = 0;
  2765. }
  2766. //薪资字段
  2767. if ($val->wage == -1) {
  2768. $return_list[$key]->wage_cn = '面议';
  2769. } else {
  2770. if ($val->wage > 0) {
  2771. if ($wage_categories) {
  2772. if (config('aix.system.site_other.site_other.site_salary') == 1) {
  2773. $return_list[$key]->wage_cn = array_has($wage_categories['AIX_wage_k'], [$val->wage])?$wage_categories['AIX_wage_k'][$val->wage]:'面议';
  2774. } elseif (config('aix.system.site_other.site_other.site_salary') == 2) {
  2775. $return_list[$key]->wage_cn = array_has($wage_categories['AIX_wage_c'], [$val->wage])?$wage_categories['AIX_wage_c'][$val->wage]:'面议';
  2776. }
  2777. }
  2778. } else {
  2779. $return_list[$key]->wage_cn = $this->dealWage($val->wage, $val->wage_min, $val->wage_max,$val->ygxs);
  2780. }
  2781. }
  2782. $return_list[$key]->experience_cn = '经验不限';
  2783. $return_list[$key]->nature_cn = '职位性质不限';
  2784. $return_list[$key]->education_cn = '学历不限';
  2785. $return_list[$key]->tag_cn = array();
  2786. $return_list[$key]->category_cn = '';
  2787. $return_list[$key]->company->nature_cn = '';
  2788. $return_list[$key]->company->scale_cn = '';
  2789. if ($other_categories) {
  2790. if ($val->experience) {
  2791. $job_experience = array_get($other_categories, 'AIX_experience');
  2792. if ($job_experience) {
  2793. $return_list[$key]->experience_cn = $job_experience[$val->experience]['demand'];
  2794. }
  2795. }
  2796. if ($val->nature) {
  2797. $job_nature = array_get($other_categories, 'AIX_jobs_nature');
  2798. if ($job_nature) {
  2799. $return_list[$key]->nature_cn = $job_nature[$val->nature]['demand'];
  2800. }
  2801. }
  2802. if ($val->education) {
  2803. $job_education = array_get($other_categories, 'AIX_education');
  2804. if ($job_education) {
  2805. $return_list[$key]->education_cn = $job_education[$val->education]['demand'];
  2806. }
  2807. }
  2808. $return_list[$key]->company_audit = $val->company->audit;
  2809. $return_list[$key]->setmeal_id = $val->company->setmeal_id;
  2810. $return_list[$key]->setmeal_name = $val->company->setmeal_name;
  2811. $job_tags = array_get($other_categories, 'AIX_jobtag');
  2812. if (implode(',', $val->tag)) {
  2813. $tag_cn = array();
  2814. foreach ($val->tag as $k => $v) {
  2815. $tag = array_get($job_tags, $v);
  2816. $tag_cn[] = $tag['demand'];
  2817. }
  2818. $return_list[$key]->tag_cn = $tag_cn;
  2819. }
  2820. //企业性质
  2821. $company_types = array_get($other_categories, 'AIX_company_type');
  2822. if ($company_types) {
  2823. $type_cn = array_get($company_types, $val->company->nature);
  2824. if ($type_cn) {
  2825. $return_list[$key]->company->nature_cn= $type_cn['demand'];
  2826. }
  2827. }
  2828. //企业规模
  2829. $company_scales = array_get($other_categories, 'AIX_scale');
  2830. if ($company_scales) {
  2831. $scale_cn = array_get($company_scales, $val->company->scale);
  2832. if ($scale_cn) {
  2833. $return_list[$key]->company->scale_cn = $scale_cn['demand'];
  2834. }
  2835. }
  2836. //企业行业
  2837. $company_trades = array_get($other_categories, 'AIX_trade');
  2838. if ($company_trades) {
  2839. $trade_cn = array_get($company_trades, $val->company->trade);
  2840. if ($trade_cn) {
  2841. $return_list[$key]->company->trade_cn = $trade_cn['demand'];
  2842. }
  2843. }
  2844. //企业logo
  2845. if ($val->company->logo) {
  2846. $return_list[$key]->company->logo = upload_asset($val->company->logo);
  2847. } else {
  2848. $return_list[$key]->company->logo = public_data_path('data/upload/no_logo.png');
  2849. }
  2850. }
  2851. //职位类别
  2852. $category = array();
  2853. if ($val->subclass) {
  2854. $category = array_get($categories['id'], $val->subclass);
  2855. } elseif ($val->category) {
  2856. $category = array_get($categories['id'], $val->category);
  2857. } elseif ($val->topclass) {
  2858. $category = array_get($categories['id'], $val->topclass);
  2859. }
  2860. if ($category) {
  2861. $return_list[$key]->category_cn = $category['name'];
  2862. }
  2863. //工作地点
  2864. if (!strpos($val->district, ".")) {
  2865. if (array_get($city_cates['id'], $val->district)) {
  2866. $return_list[$key]->district_cn = $city_cates['id'][$val->district]['name'];
  2867. if ($city_cates['id'][$val->district]['parent_id'] > 0) {
  2868. $parent_district = array_get($city_cates['id'], $city_cates['id'][$val->district]['parent_id']);
  2869. if ($parent_district) {
  2870. $return_list[$key]->district_cn = $parent_district['name'].$return_list[$key]->district_cn;
  2871. if ($parent_district['parent_id'] > 0) {
  2872. $pp_district = array_get($city_cates['id'], $parent_district['parent_id']);
  2873. if ($pp_district) {
  2874. $return_list[$key]->district_cn = $pp_district['name'].$return_list[$key]->district_cn;
  2875. }
  2876. }
  2877. }
  2878. }
  2879. }
  2880. } else {
  2881. $city_district = explode('.', $val->district);
  2882. $city_district_cn = array();
  2883. foreach ($city_district as $k => $v) {
  2884. if ($v) {
  2885. $district_info = array_get($city_cates['id'], $v);
  2886. if ($district_info) {
  2887. $city_district_cn[] = $district_info['name'];
  2888. }
  2889. }
  2890. }
  2891. $return_list[$key]->district_cn = implode('/', $city_district_cn);
  2892. }
  2893. //刷新时间
  2894. if (!$val->refresh_time) {
  2895. $return_list[$key]->refresh_time = strtotime($val->updated_at);
  2896. }
  2897. //距离
  2898. if ($map_data) {
  2899. $filter_lng = $map_data['lng'];
  2900. $filter_lat = $map_data['lat'];
  2901. $return_list[$key]->map_range = $this->getDistance($filter_lng, $filter_lat, $val->map_x, $val->map_y);
  2902. }
  2903. //招聘人数
  2904. if (!$val->amount) {
  2905. $return_list[$key]->amount = '若干';
  2906. }
  2907. //年龄限制
  2908. if (is_array($val->age)) {
  2909. /*
  2910. if ((implode('', $val->age)=='') || ((int)implode('', $val->age)==0)) {
  2911. $return_list[$key]->age_cn = '不限';
  2912. } else {
  2913. $return_list[$key]->age_cn = implode('-', $val->age).'岁';
  2914. }*/
  2915. if (count($val->age)>1) {
  2916. $age = $val->age;
  2917. if (!$age[0] && !$age[1]) {
  2918. $return_list[$key]->age_cn = '不限';
  2919. } else {
  2920. if ($age[0] && $age[1]) {
  2921. $return_list[$key]->age_cn = $age[0].'-'.$age[1].'岁';
  2922. } else {
  2923. $age[0] && $return_list[$key]->age_cn = $age[0].'岁以上';
  2924. $age[1] && $return_list[$key]->age_cn = $age[1].'岁以下';
  2925. }
  2926. }
  2927. } else {
  2928. $age = $val->age;
  2929. $return_list[$key]->age_cn = $val->age_cn = (int)$age[0].'岁以上';
  2930. }
  2931. } else {
  2932. if ($val->age == '-' || $val->age == '0') {
  2933. $return_list[$key]->age_cn = '不限';
  2934. } else {
  2935. $return_list[$key]->age_cn = $val->age.'岁';
  2936. }
  2937. }
  2938. //性别
  2939. if ($val->sex == 1) {
  2940. $return_list[$key]->sex_cn = '男';
  2941. } elseif ($val->sex == 2) {
  2942. $return_list[$key]->sex_cn = '女';
  2943. } else {
  2944. $return_list[$key]->sex_cn = '不限';
  2945. }
  2946. }
  2947. return $return_list;
  2948. }
  2949. public function getApplyJobs($where, $field = 'jobs_id')
  2950. {
  2951. $rst = $this->personalJobsApplyRepository->getJobsApply($where);
  2952. $list = array();
  2953. if ($rst->toArray()) {
  2954. foreach ($rst as $key => $val) {
  2955. $list[$val->$field] = $val;
  2956. }
  2957. }
  2958. return $list;
  2959. }
  2960. public function getFavoriteJobs($where, $field = 'job_id')
  2961. {
  2962. $rst = $this->personFavoriteRepository->getList($where);
  2963. $list = array();
  2964. if ($rst->toArray()) {
  2965. foreach ($rst as $key => $val) {
  2966. $list[$val->$field] = $val;
  2967. }
  2968. }
  2969. return $list;
  2970. }
  2971. public function getDistance($lng1, $lat1, $lng2, $lat2)
  2972. {
  2973. $radLat1 = deg2rad($lat1);
  2974. $radLat2 = deg2rad($lat2);
  2975. $radLng1 = deg2rad($lng1);
  2976. $radLng2 = deg2rad($lng2);
  2977. $a = $radLat1 - $radLat2;
  2978. $b = $radLng1 - $radLng2;
  2979. $s = 2 * asin(sqrt(pow(sin($a / 2), 2) + cos($radLat1) * cos($radLat2) * pow(sin($b / 2), 2))) * 6378.137;
  2980. return round($s, 2).'km';
  2981. }
  2982. public function dealJobCompanies($jobs)
  2983. {
  2984. $job_companys = array();
  2985. if ($jobs) {
  2986. foreach ($jobs as $k => $val) {
  2987. if (!$job_companys || ($job_companys && !array_has($job_companys, $val->company_id))) {
  2988. $job_companys[$val->company_id] = $val->company;
  2989. $jobs_where = array(array('company_id','=',$val->company_id),array('valid','=',1),array('display','=',1));
  2990. if (config('aix.companyset.comset.show_set.jobs_display') == 1) {
  2991. $jobs_where[] = array('audit','=','1');
  2992. } else {
  2993. $jobs_where[] = array('audit','<>','3');
  2994. }
  2995. $jobs = $this->getOtherJobs($jobs_where, 3);
  2996. $job_companys[$val->company_id]->jobs = $jobs;
  2997. }
  2998. }
  2999. }
  3000. return array_values($job_companys);
  3001. }
  3002. //获取推荐职位
  3003. public function getRecommendOrder($user = array())
  3004. {
  3005. $order = array();
  3006. /*if (auth('web-member')->check()) {
  3007. $order = array('refresh_time'=>'desc');
  3008. } else {
  3009. $order = array('click'=>'desc','stime'=>'desc','refresh_time'=> 'desc');
  3010. }*/
  3011. $order = array('click'=>'desc','stime'=>'desc','refresh_time'=> 'desc');
  3012. return $order;
  3013. }
  3014. //TODO 修改用户读取方式
  3015. public function getRecommendWhere($user = array())
  3016. {
  3017. $where = array();
  3018. //个人会员
  3019. if ($user && $user->utype==2) {
  3020. $filter_resume = array(
  3021. array('uid','=',$user->id)
  3022. );
  3023. if (config('aix.personal_set.per_set.show_set.resume_display')==2) {
  3024. $filter_resume[] = array('audit','<>',0);
  3025. } else {
  3026. $filter_resume[] = array('audit','=',2);
  3027. }
  3028. $resumes = $this->resumeRepository->getResumes($filter_resume);
  3029. if ($resumes->isNotEmpty()) {
  3030. $or_where = array();
  3031. foreach ($resumes as $k => $v) {
  3032. $or_where[] = $this->setRecommendJobWhere($v);
  3033. }
  3034. $and_where = array();
  3035. $and_where[] = array('valid','=',1);
  3036. $and_where[] = array('display','=',1);
  3037. if (config('aix.companyset.comset.show_set.jobs_display')==1) {
  3038. $and_where[] = array('audit','=',1);
  3039. } else {
  3040. $and_where[] = array('audit','<>',3);
  3041. }
  3042. $where['or'] = $or_where;
  3043. $where['and'] = $and_where;
  3044. }
  3045. return $where;
  3046. } else {
  3047. //游客、企业会员 - 点击次数、置顶职位、刷新靠前的职位
  3048. /*$where[] = array('valid','=',1);
  3049. $where[] = array('display','=',1);
  3050. if (config('aix.companyset.comset.show_set.jobs_display')==1) {
  3051. $where[] = array('audit','=',1);
  3052. } else {
  3053. $where[] = array('audit','<>',3);
  3054. }
  3055. $where[] = array('subsite_ids','=',get_subsite_id());*/
  3056. $where['and'][] = array('valid','=',1);
  3057. $where['and'][] = array('display','=',1);
  3058. if (config('aix.companyset.comset.show_set.jobs_display')==1) {
  3059. $where['and'][] = array('audit','=',1);
  3060. } else {
  3061. $where['and'][] = array('audit','<>',3);
  3062. }
  3063. $where['and'][] = array('subsite_ids','=',get_subsite_id());
  3064. }
  3065. return $where;
  3066. }
  3067. //匹配个人推荐职位的查询条件
  3068. public function setRecommendJobWhere($resume)
  3069. {
  3070. $where = array();
  3071. /*$where[] = array('valid','=',1);
  3072. $where[] = array('display','=',1);
  3073. if (config('aix.companyset.comset.show_set.jobs_display')==1) {
  3074. $where[] = array('audit','=',1);
  3075. } else {
  3076. $where[] = array('audit','<>',3);
  3077. }*/
  3078. //匹配性别
  3079. if ($resume->sex == 1) {
  3080. $where[] = array('sex','<>',2);
  3081. } else {
  3082. $where[] = array('sex','<>',1);
  3083. }
  3084. //匹配年龄age_min、age_max
  3085. $age = date("Y") - $resume->birthdate;
  3086. $where[] = array('age_min','<=',$age);
  3087. $where[] = array('age_max','>=',$age);
  3088. $where[] = array('education','<=',$resume->education); //匹配学历
  3089. $where[] = array('experience','<=',$resume->experience); //匹配工作经验
  3090. $where[] = array('nature','=',$resume->nature); //匹配工作性质 - 精准匹配
  3091. //匹配期望行业trade - 如果没有值则不添加匹配条件
  3092. if ($resume->trade) {
  3093. $trades = explode(',', $resume->trade);
  3094. $where[] = array('trade','in',$trades);
  3095. }
  3096. //匹配期望职位 - 二级职位
  3097. $intention_jobs_cates = explode(',', $resume->intention_jobs_id);
  3098. $intention_cates = array();
  3099. foreach ($intention_jobs_cates as $k => $v) {
  3100. $i_ids = explode('.', $v);
  3101. if (array_has($i_ids, 1)) {
  3102. $intention_cates[] = (int)$i_ids[1];
  3103. }
  3104. }
  3105. if ($intention_cates) {
  3106. $where[] = array('intention_jobs_id','in',$intention_cates);
  3107. }
  3108. //匹配工作地区(职位的工作地区)(三级地区存在时匹配三级地区,不存在时匹配二级地区)
  3109. $district = explode(',', $resume->district);
  3110. $district_ids = array();
  3111. if ($district) {
  3112. foreach ($district as $k => $v) {
  3113. if (!strpos($v, ".")) {
  3114. $district_ids[] = $v;
  3115. } else {
  3116. $district_arr = explode('.', $v);
  3117. if (array_has($district_arr, 2) && array_get($district_arr, 2)>0) {
  3118. $district_ids[] = (int)$district_arr[2];
  3119. } else {
  3120. $district_ids[] = (int)$district_arr[1];
  3121. }
  3122. }
  3123. }
  3124. }
  3125. if ($district_ids) {
  3126. $where[] = array('district','in',$district_ids);
  3127. }
  3128. //匹配期望薪资 - (第二版逻辑:职位薪资最大值和最小值包含期望薪资、面议)
  3129. $where[] = array('wage_min','<=',$resume->wage_min);
  3130. $where[] = array('wage_max','>=',$resume->wage_max);
  3131. $where[] = array('subsite_ids','=',get_subsite_id());
  3132. return $where;
  3133. }
  3134. public function autoRefreshJobs(array $pid_arr)
  3135. {
  3136. if ($this->jobsRepository->autoRefreshJobs($pid_arr)) {
  3137. return true;
  3138. }
  3139. return false;
  3140. }
  3141. /**将职位管理内的职位转入招聘会职位库
  3142. * @param $request
  3143. * @return JsonResponse
  3144. * @throws \Prettus\Validator\Exceptions\ValidatorException
  3145. */
  3146. public function jobsAddToJobfair($request,$user)
  3147. {
  3148. $jid = $request->id;
  3149. if (!$jid || !$jobsInfo = $this->jobsRepository->find($jid)) {
  3150. return response()->json(['status'=>0,'msg'=>"参数错误或无此职位"]);
  3151. }
  3152. $this->isOwn($jid,$user);
  3153. $type1 = $this->jobfairJobRepository->findWhere(['jobs_name'=>$jobsInfo->jobs_name,'company_id'=>$jobsInfo->company_id,'type'=>1])->isNotEmpty();
  3154. $type2 = $this->jobfairJobRepository->findWhere(['jobs_name'=>$jobsInfo->jobs_name,'company_id'=>$jobsInfo->company_id,'type'=>2])->isNotEmpty();
  3155. if($type1 && $type2 ){
  3156. return response()->json(['status'=>0,'msg'=>"该职位已存在招聘会职位库中,请添加其他职位"]);
  3157. }
  3158. $insertArr = [];
  3159. if ($jobCatact = $this->jobsContactRepository->getContactInfo(['job_id'=>$jid])) {
  3160. $contactData = $this->jobsContactRepository->find($jobCatact->id);
  3161. $contactArr = ['contact','qq','mobile','notify','landline_tel','email','address','notify_mobile','contact_show','telephone_show','email_show','landline_tel_show'];
  3162. foreach ($contactArr as $key => $val) {
  3163. if ($val == 'mobile') {
  3164. $insertArr[$val] = $jobCatact->telephone;
  3165. } elseif ($val=='landline_tel') {
  3166. if (isset($jobCatact->landline_tel)) {
  3167. $insertArr[$val] = implode('-', $jobCatact->landline_tel);
  3168. } else {
  3169. $insertArr[$val]='--';
  3170. }
  3171. } else {
  3172. $insertArr[$val] = $jobCatact->$val;
  3173. }
  3174. }
  3175. }
  3176. $jobfairArr = [
  3177. 'jobs_name',
  3178. 'company_id',
  3179. 'company_name',
  3180. 'company_addtime',
  3181. 'company_audit',
  3182. 'stick',
  3183. 'amount',
  3184. 'negotiable',
  3185. 'jobs_content',
  3186. 'audit',
  3187. 'click',
  3188. 'display',
  3189. 'robot',
  3190. 'map_x',
  3191. 'map_y',
  3192. 'map_zoom',
  3193. 'add_mode',
  3194. 'department',
  3195. 'nature',
  3196. 'sex',
  3197. 'age',
  3198. 'topclass',
  3199. 'category',
  3200. 'subclass',
  3201. 'trade',
  3202. 'scale',
  3203. 'district',
  3204. 'education',
  3205. 'experience',
  3206. 'wage',
  3207. 'wage_max',
  3208. 'wage_min',
  3209. 'ygxs',
  3210. 'syq',
  3211. 'syqxz_min',
  3212. 'techlevel'
  3213. ];
  3214. foreach ($jobfairArr as $key => $val) {
  3215. $insertData[$val] = $jobsInfo->$val;
  3216. }
  3217. if ($jobsInfo['topclass'] && $jobsInfo['category'] && $jobsInfo['subclass']) {
  3218. $insertData['category_cn'] = get_job_category_cn($jobsInfo['topclass'].".".$jobsInfo['category'].'.'.$jobsInfo['subclass']);
  3219. } else {
  3220. $insertData['category_cn'] = '';
  3221. }
  3222. if(!empty($insertData['age'])){
  3223. $insertData['age'] = implode('-',$insertData['age'] );
  3224. }
  3225. $insertData['nature_cn'] = $jobsInfo['nature']?get_category($jobsInfo['nature']):'';
  3226. $insertData['trade_cn'] = $jobsInfo['trade']?get_category($jobsInfo['trade']):'';
  3227. $insertData['scale_cn'] = $jobsInfo['scale']?get_category($jobsInfo['scale']):'';
  3228. $insertData['education_cn'] = $jobsInfo['education']?get_category($jobsInfo['education']):'';
  3229. $insertData['experience_cn'] = $jobsInfo['experience']?get_category($jobsInfo['experience']):"";
  3230. if (intval($insertData['wage']) == 0) {
  3231. if ($insertData['wage_max']) {
  3232. $insertData['wage_cn'] = $insertData['wage_min'].'~'.$insertData['wage_max'].'/月';
  3233. } else {
  3234. $insertData['wage_cn'] = $insertData['wage_min'].'/月以上';
  3235. }
  3236. }elseif(intval($insertData['wage']) == -1){
  3237. $insertData['wage_cn'] = '面议';
  3238. }else{
  3239. $insertData['wage_cn'] = $jobsInfo['wage']?get_category($jobsInfo['wage']):'';
  3240. }
  3241. $insertData['ygxs'] = $jobsInfo['ygxs']?$jobsInfo['ygxs']:'';
  3242. $insertData['syq'] = $jobsInfo['syq']?$jobsInfo['syq']:'';
  3243. $insertData['syqxz_min'] = $jobsInfo['syqxz_min']?$jobsInfo['syqxz_min']:'';
  3244. $insertData['techlevel'] = $jobsInfo['techlevel']?$jobsInfo['techlevel']:'';
  3245. $insertData['district_cn'] = get_district_cn($jobsInfo['district']);
  3246. if ($jobsInfo['tag'][0]) {
  3247. $insertData['tag_cn'] = get_tag_cn(implode(',', $jobsInfo['tag']));
  3248. } else {
  3249. $insertData['tag_cn']='';
  3250. }
  3251. switch ($jobsInfo['sex']) {
  3252. case 1:
  3253. $insertData['sex_cn'] = '男';
  3254. break;
  3255. case 2:
  3256. $insertData['sex_cn'] = '女';
  3257. break;
  3258. case 0:
  3259. $insertData['sex_cn'] = '不限';
  3260. break;
  3261. }
  3262. try{
  3263. if(!$type1){
  3264. $insertData['type'] = 1;
  3265. if (!$jobfair_jobid = $this->jobfairJobRepository->create($insertData)) {
  3266. throw new \Exception('转入招聘会职位库失败!');
  3267. }
  3268. if ($insertArr) {
  3269. $insertArr['pid'] = $jobfair_jobid->id;
  3270. $this->jobfairJobsContactRepository->create($insertArr);
  3271. }
  3272. }
  3273. if(!$type2){
  3274. $insertData['type'] = 2;
  3275. if (!$jobfairout_jobid = $this->jobfairJobRepository->create($insertData)) {
  3276. throw new \Exception('转入招聘会职位库失败!');
  3277. }
  3278. if ($insertArr) {
  3279. $insertArr['pid'] = $jobfairout_jobid->id;
  3280. $this->jobfairJobsContactRepository->create($insertArr);
  3281. }
  3282. }
  3283. DB::commit();
  3284. return response()->json(['status'=>1,'msg'=>"成功转入招聘会职位库!",'data' => '']);
  3285. }catch (Exception $e) {
  3286. DB::rollback();
  3287. return response()->json(['status'=>1,'msg'=>$e->getMessage(),'data' => '']);
  3288. }
  3289. }
  3290. public function isOwn($ids,$user)
  3291. {
  3292. $ids = is_array($ids)?$ids:explode(',',$ids);
  3293. $putJobs = $this->jobsRepository->getPluck(['company_id'=>$user->id],'id')->toArray();
  3294. if(array_diff($ids,$putJobs))
  3295. {
  3296. throw new ResponseException('抱歉,您只能操作自己的招聘会职位!');
  3297. }
  3298. }
  3299. }