JobsService.php 148 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490
  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. if ($hide) {
  2122. if ($val->contact->telephone) {
  2123. $val->contact->telephone = contact_hide($val->contact->telephone);
  2124. } else {
  2125. $val->contact->telephone = contact_hide(trim(implode('-', $val->contact->landline_tel), '-'), 1);
  2126. }
  2127. } else {
  2128. if ($user && $user->utype ==1 && $val->company_id == $user->id) {
  2129. $val->contact->contact_show = 1;
  2130. $val->contact->telephone_show = 1;
  2131. if (!$val->contact->telephone) {
  2132. $val->contact->telephone = trim(implode('-', $val->contact->landline_tel), '-');
  2133. }
  2134. } else {
  2135. if ($val->contact->telephone_show==0 && $val->contact->landline_tel_show==0) {
  2136. $val->contact->telephone_show = 0;
  2137. } elseif ($val->contact->telephone_show==1 && $val->contact->telephone) {
  2138. $val->contact->telephone_show = $val->contact->telephone_show;
  2139. } elseif ($val->contact->telephone && (!$val->contact->landline_tel || ($val->contact->landline_tel && !trim(implode('-', $val->contact->landline_tel), '-'))) && $val->contact->telephone_show==0) {
  2140. $val->contact->telephone_show = $val->contact->telephone_show;
  2141. } else {
  2142. $val->contact->telephone = trim(implode('-', $val->contact->landline_tel), '-');
  2143. $val->contact->telephone_show = $val->contact->landline_tel_show;
  2144. }
  2145. }
  2146. }
  2147. $val->contact->telephone_ = $val->contact->telephone;
  2148. if (config('aix.companyset.comset.contact_type_set.contact_img_com') == 2) {
  2149. $pwdhash = config('aix.system.site_other.site_other.pwb_hash');
  2150. $val->contact->telephone = "<img src='".route('common.contact_img', array('text'=>encrypt($val->contact->telephone, $pwdhash),'type'=>'phone'))."' />";
  2151. } elseif (config('aix.companyset.comset.contact_type_set.contact_img_com') == 3 && C('LOG_SOURCE')!=2) {// 扫码获取
  2152. $val->contact->telephone = '';
  2153. }
  2154. $val->hide = $hide;
  2155. //简历处理效率
  2156. $app_where[] = array('jobs_id','=',$val->id);
  2157. $app_where[] = array('created_at','>',date('Y-m-d H:i:s', strtotime("-14day")));
  2158. $apply = $this->personalJobsApplyRepository->getJobsApply($app_where);
  2159. $val->deliver = 0;
  2160. $reply = 0;
  2161. $reply_time = 0;
  2162. foreach ($apply as $key => $v) {
  2163. if ($v->is_reply) {
  2164. $reply++;
  2165. if ($v->reply_time) {
  2166. $reply_time += $v->reply_time - strtotime($v->created_at);
  2167. }
  2168. }
  2169. if ($user && $user->utype==2 && $user->id == $v->personal_uid) {
  2170. $val->deliver = 1;
  2171. }
  2172. }
  2173. if (count($apply)) {
  2174. $val->company->reply_ratio = !$apply ? '0%' : intval($reply / count($apply) * 100).'%';
  2175. } else {
  2176. $val->company->reply_ratio = '0%';
  2177. }
  2178. $val->company->reply_time = !$reply_time ? '0天' : sub_day(intval($reply_time / count($apply)), 0);
  2179. if (!$val->company->last_login_time) {
  2180. $val->company->last_login_time = '未登录';
  2181. }
  2182. if ($user && $user->utype == 2) {
  2183. $resume = $this->resumeRepository->getPersonInfo($user->id);
  2184. $val->resume = $resume;
  2185. if ($resume) {
  2186. $val->resume->url = route(url_rewrite('AIX_resumeshow'), ['id'=>$val->resume->id]);
  2187. }
  2188. //判断是否在黑名单
  2189. $shield_where = [
  2190. 'uid' => $user->id,
  2191. 'company_id' => $val->company_id
  2192. ];
  2193. if(!$this->ResumePrivacyRepository->getShield($shield_where))
  2194. {
  2195. //没有记录访问记录
  2196. $log_where = array('uid'=>$user->id,'job_id'=>$val->id);
  2197. $view_log = $this->viewJobRepository->getLog($log_where, 1);
  2198. if ($view_log) {
  2199. $log_data = array('updated_at' => date('Y-m-d H:i:s', time()));
  2200. $this->viewJobRepository->update($log_data, $log_where);
  2201. } else {
  2202. $time = date('Y-m-d H:i:s', time());
  2203. $log_data = array(
  2204. 'uid' => $user->id,
  2205. 'job_id' => $val->id,
  2206. 'company_id' => $val->company_id,
  2207. 'created_at' => $time,
  2208. 'updated_at' => $time
  2209. );
  2210. $this->viewJobRepository->addLog($log_data);
  2211. }
  2212. }
  2213. //检测是否已收藏
  2214. $favor_log = $this->personFavoriteRepository->getInfo(array('job_id'=>$val->id,'uid'=>$user->id));
  2215. if ($favor_log) {
  2216. $val->favor = 1;
  2217. } else {
  2218. $val->favor = 0;
  2219. }
  2220. } else {
  2221. $val->favor = 0;
  2222. }
  2223. //来源分站名称
  2224. $subsites = Cache::get('subsites_list');
  2225. if (array_has($subsites, $val->subsite_id)) {
  2226. $val->subsite_cn = $subsites[$val->subsite_id]['sitename'];
  2227. } else {
  2228. $val->subsite_cn = '';
  2229. }
  2230. // if(!$this->memberLogRepository->createLog(auth('web-company')->user(),2034,$where['id'])){
  2231. // throw new \Exception("日志记失败!");
  2232. // }
  2233. return ['status'=>1, 'job'=>$val];
  2234. }
  2235. public function incrementData($where, $num, $filed)
  2236. {
  2237. return $this->jobsRepository->incrementData($where, $num, $filed);
  2238. }
  2239. //获取紧急招聘职位
  2240. public function getEmergencyJobs($limit = '')
  2241. {
  2242. $emergency_jobs = array();
  2243. $emergency_where = array(
  2244. array('valid','=','1'),
  2245. array('emergency','=','1')
  2246. );
  2247. if (config('aix.companyset.comset.show_set.jobs_display')==1) {
  2248. $emergency_where[] = array('audit','=',1);
  2249. } else {
  2250. $emergency_where[] = array('audit','<>',3);
  2251. }
  2252. $emergency_where[] = array('display','=',1);
  2253. $emergency_where[] = array('valid','=',1);
  2254. $emergency_jobs = $this->getOtherJobs($emergency_where, $limit);
  2255. return $emergency_jobs;
  2256. }
  2257. //获取最新职位
  2258. public function getNewJobs($limit = '')
  2259. {
  2260. $new_jobs = array();
  2261. $where = array(
  2262. array('valid','=','1'),
  2263. );
  2264. if (config('aix.companyset.comset.show_set.jobs_display')==1) {
  2265. $where[] = array('audit','=',1);
  2266. } else {
  2267. $where[] = array('audit','<>',3);
  2268. }
  2269. $where[] = array('display','=',1);
  2270. $where[] = array('valid','=',1);
  2271. $where[] = array('deadline','>',time());
  2272. $jobs = $this->jobsRepository->getCompanyJobs($where, array(), array('refresh_time'=>'desc'), $limit);
  2273. if ($jobs->isNotEmpty()) {
  2274. $other_categories = $this->categoryRepository->getCategories();
  2275. if ($other_categories) {
  2276. $wages = array_get($other_categories, 'AIX_wage');
  2277. $educations = array_get($other_categories, 'AIX_education');
  2278. $experiences = array_get($other_categories, 'AIX_experience');
  2279. $natures = array_get($other_categories, 'AIX_job_nature');
  2280. } else {
  2281. $wages = array();
  2282. $educations = array();
  2283. $experiences = array();
  2284. $natures = array();
  2285. }
  2286. $city_cates = Cache::get('city_cate_list');
  2287. if (null === $city_cates) {
  2288. $city_cates = $this->categoryDistrictRepository->cityCateCache();
  2289. Cache::put('city_cate_list', $city_cates, '86400');
  2290. }
  2291. foreach ($jobs as $k => $v) {
  2292. //修改薪资信息
  2293. $jobs[$k]->wage_cn = '薪资面议';
  2294. if ($wages) {
  2295. if ($wage= array_get($wages, $v->wage)) {
  2296. $jobs[$k]->wage_cn = $wage['demand'];
  2297. if (config('aix.system.site_other.site_other.site_salary') == 1) {
  2298. $jobs[$k]->wage_cn = array_has($wages, [$v->wage])?$wages[$v->wage]['k_demand']:'面议';
  2299. } elseif (config('aix.system.site_other.site_other.site_salary') == 2) {
  2300. $jobs[$k]->wage_cn = array_has($wages, [$v->wage])?$wages[$v->wage]['c_demand']:'面议';
  2301. }
  2302. }
  2303. }
  2304. //修改学历
  2305. $jobs[$k]->education_cn = '学历不限';
  2306. if ($educations) {
  2307. if ($education = array_get($educations, $v->education)) {
  2308. $jobs[$k]->education_cn = $education['demand'];
  2309. }
  2310. }
  2311. //工作经验
  2312. $jobs[$k]->experience_cn = '经验不限';
  2313. if ($experiences) {
  2314. if ($experience = array_get($experiences, $v->experience)) {
  2315. $jobs[$k]->experience_cn = $experience['demand'];
  2316. }
  2317. }
  2318. //职位性质
  2319. $jobs[$k]->nature_cn = '不限';
  2320. if ($natures) {
  2321. if ($nature = array_get($natures, $v->nature)) {
  2322. $jobs[$k]->nature_cn = $nature['demand'];
  2323. }
  2324. }
  2325. //修改工作所在地
  2326. $jobs[$k]->district_cn ='';
  2327. if (!strpos($v->district, ".")) {
  2328. $district_cn = array_get($city_cates['id'], $v->district);
  2329. if ($district_cn) {
  2330. $jobs[$k]->district_cn = $district_cn['name'];
  2331. }
  2332. } else {
  2333. $c_district = explode('.', $v->district);
  2334. $district_cn = array();
  2335. foreach ($c_district as $j => $val) {
  2336. if ($val) {
  2337. $district_info = array_get($city_cates['id'], $val);
  2338. if ($district_info) {
  2339. $district_cn[] = $district_info['name'];
  2340. }
  2341. }
  2342. }
  2343. $district_cn = implode('/', $district_cn);
  2344. $jobs[$k]->district_cn = $district_cn;
  2345. }
  2346. //企业logo
  2347. $company = $v->company;
  2348. if ($company->logo) {
  2349. $jobs[$k]->company_logo=upload_asset($company->logo);
  2350. } else {
  2351. $jobs[$k]->company_logo = public_data_path('data/upload/no_logo.png');
  2352. }
  2353. }
  2354. $new_jobs = $jobs;
  2355. }
  2356. return $new_jobs;
  2357. }
  2358. public function getOtherJobs($where, $limit = '')
  2359. {
  2360. $lists = $this->jobsRepository->getOtherJobs($where, $limit);
  2361. if (!$lists->toArray()) {
  2362. return $lists;
  2363. } else {
  2364. $other_categories = $this->categoryRepository->getCategories();
  2365. if ($other_categories) {
  2366. $wages = array_get($other_categories, 'AIX_wage');
  2367. $educations = array_get($other_categories, 'AIX_education');
  2368. $experiences = array_get($other_categories, 'AIX_experience');
  2369. $natures = array_get($other_categories, 'AIX_job_nature');
  2370. } else {
  2371. $wages = array();
  2372. $educations = array();
  2373. $experiences = array();
  2374. $natures = array();
  2375. }
  2376. $city_cates = Cache::get('city_cate_list');
  2377. if (null === $city_cates) {
  2378. $city_cates = $this->categoryDistrictRepository->cityCateCache();
  2379. Cache::put('city_cate_list', $city_cates, '86400');
  2380. }
  2381. foreach ($lists as $k => $v) {
  2382. //修改薪资信息
  2383. $lists[$k]->wage_cn = '面议';
  2384. if ($v->wage >0) {
  2385. if ($wages) {
  2386. if ($wage= array_get($wages, $v->wage)) {
  2387. $lists[$k]->wage_cn = $wage['demand'];
  2388. if (config('aix.system.site_other.site_other.site_salary') == 1) {
  2389. $lists[$k]->wage_cn = array_has($wages, [$v->wage])?$wages[$v->wage]['k_demand']:'面议';
  2390. } elseif (config('aix.system.site_other.site_other.site_salary') == 2) {
  2391. $lists[$k]->wage_cn = array_has($wages, [$v->wage])?$wages[$v->wage]['c_demand']:'面议';
  2392. }
  2393. }
  2394. }
  2395. } elseif ($v->wage == 0) {
  2396. $lists[$k]->wage_cn = $this->dealWage($v->wage, $v->wage_min, $v->wage_max);
  2397. }
  2398. //修改学历
  2399. $lists[$k]->education_cn = '学历不限';
  2400. if ($educations) {
  2401. if ($education = array_get($educations, $v->education)) {
  2402. $lists[$k]->education_cn = $education['demand'];
  2403. }
  2404. }
  2405. //工作经验
  2406. $lists[$k]->experience_cn = '经验不限';
  2407. if ($experiences) {
  2408. if ($experience = array_get($experiences, $v->experience)) {
  2409. $lists[$k]->experience_cn = $experience['demand'];
  2410. }
  2411. }
  2412. //职位性质
  2413. $lists[$k]->nature_cn = '不限';
  2414. if ($natures) {
  2415. if ($nature = array_get($natures, $v->nature)) {
  2416. $lists[$k]->nature_cn = $nature['demand'];
  2417. }
  2418. }
  2419. //修改工作所在地
  2420. $lists[$k]->district_cn ='';
  2421. if (!strpos($v->district, ".")) {
  2422. $district_cn = array_get($city_cates['id'], $v->district);
  2423. if ($district_cn) {
  2424. $lists[$k]->district_cn = $district_cn['name'];
  2425. }
  2426. } else {
  2427. $c_district = explode('.', $v->district);
  2428. $district_cn = array();
  2429. foreach ($c_district as $j => $val) {
  2430. if ($val) {
  2431. $district_info = array_get($city_cates['id'], $val);
  2432. if ($district_info) {
  2433. $district_cn[] = $district_info['name'];
  2434. }
  2435. }
  2436. }
  2437. $district_cn = implode('/', $district_cn);
  2438. $lists[$k]->district_cn = $district_cn;
  2439. }
  2440. //年龄限制
  2441. if (is_array($v->age)) {
  2442. if (implode('', $v->age)=='') {
  2443. $lists[$k]->age_cn = '不限';
  2444. } else {
  2445. $lists[$k]->age_cn = implode('-', $v->age).'岁';
  2446. }
  2447. } else {
  2448. if ($v->age == '-' || $v->age == '0') {
  2449. $lists[$k]->age_cn = '不限';
  2450. } else {
  2451. $lists[$k]->age_cn = $v->age.'岁';
  2452. }
  2453. }
  2454. $lists[$k]->refresh_time_cn = date('Y-m-d', $v->refresh_time);
  2455. }
  2456. }
  2457. return $lists;
  2458. }
  2459. //收藏职位
  2460. public function jobFavor($job_id)
  2461. {
  2462. if (!$job_id) {
  2463. throw new ResponseException('请选择要收藏的职位!');
  2464. }
  2465. if (!is_array($job_id)) {
  2466. $jobs_id = explode(',', $job_id);
  2467. } else {
  2468. $jobs_id = $job_id;
  2469. }
  2470. if (count($jobs_id) == 1) { //单个收藏
  2471. $jobInfo = $this->jobsRepository->getJobsById($job_id);
  2472. if (!$jobInfo) {
  2473. throw new ResponseException('请选择有效职位!');
  2474. }
  2475. //判断当前职位是否已收藏
  2476. $uid = auth('web-member')->user()->id;
  2477. $favor_log = $this->personFavoriteRepository->getInfo(array('job_id'=>$job_id,'uid'=>$uid));
  2478. if ($favor_log) {
  2479. //throw new ResponseException('您已经收藏该职位,不能重复收藏!');
  2480. //取消收藏
  2481. $cancel_rst = $this->personFavoriteRepository->cancelFavor(array('job_id'=>$job_id,'uid'=>$uid));
  2482. if (!$cancel_rst) {
  2483. throw new ResponseException('取消收藏失败!');
  2484. }
  2485. //return true;
  2486. return 1;
  2487. }
  2488. $time = date('Y-m-d H:i:s', time());
  2489. $favor_data = array(
  2490. 'uid' => $uid,
  2491. 'job_id' => $job_id,
  2492. 'job_name' => $jobInfo->jobs_name,
  2493. 'created_at' => $time,
  2494. 'updated_at'=>$time
  2495. );
  2496. $add_res = $this->personFavoriteRepository->addData($favor_data);
  2497. if ($add_res) {
  2498. //return true;
  2499. return 2;
  2500. } else {
  2501. throw new ResponseException('收藏失败!');
  2502. }
  2503. } else {
  2504. //批量收藏
  2505. //获取所选有效职位信息
  2506. //获取当前用户收藏的所有职位信息
  2507. //所选职位是否已收藏,组成添加数据
  2508. $jobs = $this->jobsRepository->getJobs($jobs_id);
  2509. $fav_jobs = $this->getFavoriteJobs(array('uid'=>auth('web-member')->user()->id), 'job_id');
  2510. $fav_data = array();
  2511. $stime = date('Y-m-d H:i:s', time());
  2512. foreach ($jobs as $k => $v) {
  2513. if (!$fav_jobs || ($fav_jobs && !array_has($fav_jobs, $v->id))) {
  2514. $fav_data[] = array(
  2515. 'uid' => auth('web-member')->user()->id,
  2516. 'job_id' => $v->id,
  2517. 'job_name' => $v->jobs_name,
  2518. 'created_at' => $stime,
  2519. 'updated_at' => $stime
  2520. );
  2521. }
  2522. }
  2523. if ($fav_data) {
  2524. $rst = $this->personFavoriteRepository->insertData($fav_data);
  2525. if ($rst) {
  2526. return true;
  2527. } else {
  2528. throw new ResponseException('收藏失败!');
  2529. }
  2530. } else {
  2531. throw new ResponseException('您已经收藏所选职位,不能重复收藏!');
  2532. }
  2533. }
  2534. }
  2535. //获取企业会员审核通过的职位(有效、通过审核(后台职位显示设置要求)、在招的职位)
  2536. public function getAuditJobs($company_id)
  2537. {
  2538. $where = array(
  2539. array('company_id','=',$company_id),
  2540. array('valid','=','1'),
  2541. array('display','=','1')
  2542. );
  2543. if (config('aix.companyset.comset.show_set.jobs_display') == 1) {
  2544. $where[] = array('audit','=', '1');
  2545. } else {
  2546. $where[] = array('audit','<>', '3');
  2547. }
  2548. return $this->jobsRepository->getOtherJobsCount($where);
  2549. }
  2550. public function getAuditJobsNum($company_id)
  2551. {
  2552. $rst = $this->getAuditJobs($company_id);
  2553. return count($rst);
  2554. }
  2555. public function dealjobList($data, $limit)
  2556. {
  2557. $list = array();
  2558. if ($data) {
  2559. $wage_categories = $this->categoryRepository->getCategories();
  2560. foreach ($data as $key => $val) {
  2561. if ($limit && ($key >= $limit)) {
  2562. break;
  2563. }
  2564. $list[$key] = $val;
  2565. //薪资字段
  2566. if ($val->wage > 0) {
  2567. if ($wage_categories) {
  2568. if (config('aix.system.site_other.site_other.site_salary') == 1) {
  2569. $list[$key]->wage_cn = array_has($wage_categories['AIX_wage_k'], [$val->wage])?$wage_categories['AIX_wage_k'][$val->wage]:'面议';
  2570. } elseif (config('aix.system.site_other.site_other.site_salary') == 2) {
  2571. $list[$key]->wage_cn = array_has($wage_categories['AIX_wage_c'], [$val->wage])?$wage_categories['AIX_wage_c'][$val->wage]:'面议';
  2572. }
  2573. }
  2574. } elseif ($val->wage==0) {
  2575. $list[$key]->wage_cn = $this->dealWage($val->wage, $val->wage_min, $val->wage_max);
  2576. } else {
  2577. $list[$key]->wage_cn = '面议';
  2578. }
  2579. $list[$key]->experience_cn = '经验不限';
  2580. $list[$key]->education_cn = '学历不限';
  2581. $other_categories = $this->categoryRepository->getCategories();
  2582. if ($other_categories) {
  2583. if ($val->experience) {
  2584. $job_experience = array_get($other_categories, 'AIX_experience');
  2585. if ($job_experience) {
  2586. $list[$key]->experience_cn = $job_experience[$val->experience]['demand'];
  2587. }
  2588. }
  2589. if ($val->education) {
  2590. $job_education = array_get($other_categories, 'AIX_education');
  2591. if ($job_education) {
  2592. $list[$key]->education_cn = $job_education[$val->education]['demand'];
  2593. }
  2594. }
  2595. }
  2596. $city_cates = Cache::get('city_cate_list');
  2597. if (null === $city_cates) {
  2598. $city_cates = $this->categoryDistrictRepository->cityCateCache();
  2599. Cache::put('city_cate_list', $city_cates, '86400');
  2600. }
  2601. if (!strpos($val->district, ".")) {
  2602. if (array_get($city_cates['id'], $val->district)) {
  2603. $list[$key]->district_cn = $city_cates['id'][$val->district]['name'];
  2604. if ($city_cates['id'][$val->district]['parent_id'] > 0) {
  2605. $parent_district = array_get($city_cates['id'], $city_cates['id'][$val->district]['parent_id']);
  2606. if ($parent_district) {
  2607. $list[$key]->district_cn = $parent_district['name'].$list[$key]->district_cn;
  2608. if ($parent_district['parent_id'] > 0) {
  2609. $pp_district = array_get($city_cates['id'], $parent_district['parent_id']);
  2610. if ($pp_district) {
  2611. $list[$key]->district_cn = $pp_district['name'].$list[$key]->district_cn;
  2612. }
  2613. }
  2614. }
  2615. }
  2616. }
  2617. } else {
  2618. $city_district = explode('.', $val->district);
  2619. $city_district_cn = array();
  2620. foreach ($city_district as $k => $v) {
  2621. if ($v) {
  2622. $district_info = array_get($city_cates['id'], $v);
  2623. if ($district_info) {
  2624. $city_district_cn[] = $district_info['name'];
  2625. }
  2626. }
  2627. }
  2628. $list[$key]->district_cn = implode('/', $city_district_cn);
  2629. }
  2630. }
  2631. }
  2632. return $list;
  2633. }
  2634. public function dealWage($wage, $minwage, $maxwage,$ygxs = 0)
  2635. {
  2636. // 小时工处理
  2637. $date_str = '月';
  2638. if($ygxs == 363){
  2639. $date_str = '小时';
  2640. }else{
  2641. if (config('aix.system.site_other.site_other.site_salary') == 1) {
  2642. $minwage = $minwage%1000==0?(($minwage/1000).'K'):(round($minwage/1000, 1).'K');
  2643. if ($minwage == 0) {
  2644. $maxwage = '以上';
  2645. } else {
  2646. $maxwage = $maxwage%1000==0?(($maxwage/1000).'K'):(round($maxwage/1000, 1).'K');
  2647. }
  2648. } elseif (config('aix.system.site_other.site_other.site_salary') == 2) {
  2649. if ($minwage >= 10000) {
  2650. if ($minwage%10000 == 0) {
  2651. $minwage = ($minwage/10000).'万';
  2652. } else {
  2653. $minwage = round($minwage/10000, 1);
  2654. $minwage = strpos($minwage, '.') ? str_replace('.', '万', $minwage) : $minwage.'万';
  2655. }
  2656. } else {
  2657. if ($minwage%1000 == 0) {
  2658. $minwage = ($minwage/1000).'千';
  2659. } else {
  2660. $minwage = round($minwage/1000, 1);
  2661. $minwage = strpos($minwage, '.') ? str_replace('.', '千', $minwage) : $minwage.'千';
  2662. }
  2663. }
  2664. if ($maxwage > 0) {
  2665. if ($maxwage >= 10000) {
  2666. if ($maxwage%10000 == 0) {
  2667. $maxwage = ($maxwage/10000).'万';
  2668. } else {
  2669. $maxwage = round($maxwage/10000, 1);
  2670. $maxwage = strpos($maxwage, '.') ? str_replace('.', '万', $maxwage) : $maxwage.'万';
  2671. }
  2672. } elseif ($maxwage) {
  2673. if ($maxwage%1000 == 0) {
  2674. $maxwage = ($maxwage/1000).'千';
  2675. } else {
  2676. $maxwage = round($maxwage/1000, 1);
  2677. $maxwage = strpos($maxwage, '.') ? str_replace('.', '千', $maxwage) : $maxwage.'千';
  2678. }
  2679. } else {
  2680. $maxwage = '0';
  2681. }
  2682. } else {
  2683. $maxwage = '0';
  2684. }
  2685. }
  2686. }
  2687. if ($minwage == $maxwage) {
  2688. if($ygxs == 363){
  2689. $wage_cn = $minwage.'元/'.$date_str;
  2690. }else{
  2691. $wage_cn = $minwage.'/'.$date_str;
  2692. }
  2693. } else {
  2694. if ($minwage>0 && $maxwage==0) {
  2695. $wage_cn = $minwage.'以上/'.$date_str;
  2696. } elseif ($wage==0 && $minwage==0 && $maxwage==0) {
  2697. $wage_cn = $minwage.'以上/'.$date_str;
  2698. } else {
  2699. $wage_cn = $minwage.'~'.$maxwage.'/'.$date_str;
  2700. }
  2701. }
  2702. return $wage_cn;
  2703. }
  2704. public function dealjobFilelds($list, $map_data = array(), $limit = '')
  2705. {
  2706. $favor_jobs = array();
  2707. $apply_jobs = array();
  2708. if (auth('web-member')->check()) {
  2709. //个人用户登录时获取个人收藏的简历信息和一段时间间隔内已申请的职位信息 config('aix.personal_set.per_set.per_set.apply_job_space')
  2710. $favor_where = array('uid'=> auth('web-member')->user()->id);
  2711. $favor_jobs = $this->getFavoriteJobs($favor_where);
  2712. $space_time = (integer)config('aix.personal_set.per_set.per_set.apply_job_space');
  2713. $stime = date('Y-m-d H:i:s', strtotime(date("Y-m-d", strtotime("-".$space_time." day"))));
  2714. $apply_where = array(array('personal_uid','=',auth('web-member')->user()->id),array('created_at','>=',$stime));
  2715. $apply_jobs = $this->getApplyJobs($apply_where);
  2716. }
  2717. $other_categories = $this->categoryRepository->getCategories();
  2718. $wage_categories = $this->categoryRepository->getCategories();
  2719. $city_cates = Cache::get('city_cate_list');
  2720. if (null === $city_cates) {
  2721. $city_cates = $this->categoryDistrictRepository->cityCateCache();
  2722. Cache::put('city_cate_list', $city_cates, '86400');
  2723. }
  2724. $categories = array();
  2725. if (Cache::has('jobs_cate_list')) {
  2726. $categories = Cache::get('jobs_cate_list');
  2727. } else {
  2728. $categories = $this->categoryJobsRepository->jobsCateInfoCache();
  2729. Cache::put('jobs_cate_list', $categories, '86400');
  2730. }
  2731. $filter_lat = '';
  2732. $filter_lng = '';
  2733. if ($map_data) {
  2734. $filter_lng = $map_data['lng'];
  2735. $filter_lat = $map_data['lat'];
  2736. }
  2737. $return_list = array();
  2738. foreach ($list as $key => $val) {
  2739. if ($limit && ($key >= $limit)) {
  2740. break;
  2741. }
  2742. $return_list[$key] = $val;
  2743. if (!$val->company) {
  2744. $companyInfo = $this->companyRepository->getCompanyInfo(['id'=>$val->company_id]);
  2745. $return_list[$key]->company = $companyInfo;
  2746. $val->company = $companyInfo;
  2747. $val->company->membersSetmeal = $this->membersSetmealRepository->getSetmealByUid($companyInfo->id, 1);
  2748. }
  2749. //套餐图片
  2750. if ($val->company->membersSetmeal) {
  2751. $val->setmeal_img = $val->company->membersSetmeal->setmeal_img;
  2752. } else {
  2753. $val->setmeal_img = null;
  2754. }
  2755. if ($favor_jobs && array_has($favor_jobs, $val->id)) {
  2756. $return_list[$key]->has_favor = 1;
  2757. } else {
  2758. $return_list[$key]->has_favor = 0;
  2759. }
  2760. if ($apply_jobs && array_has($apply_jobs, $val->id)) {
  2761. $return_list[$key]->has_deliver = 1;
  2762. } else {
  2763. $return_list[$key]->has_deliver = 0;
  2764. }
  2765. //薪资字段
  2766. if ($val->wage == -1) {
  2767. $return_list[$key]->wage_cn = '面议';
  2768. } else {
  2769. if ($val->wage > 0) {
  2770. if ($wage_categories) {
  2771. if (config('aix.system.site_other.site_other.site_salary') == 1) {
  2772. $return_list[$key]->wage_cn = array_has($wage_categories['AIX_wage_k'], [$val->wage])?$wage_categories['AIX_wage_k'][$val->wage]:'面议';
  2773. } elseif (config('aix.system.site_other.site_other.site_salary') == 2) {
  2774. $return_list[$key]->wage_cn = array_has($wage_categories['AIX_wage_c'], [$val->wage])?$wage_categories['AIX_wage_c'][$val->wage]:'面议';
  2775. }
  2776. }
  2777. } else {
  2778. $return_list[$key]->wage_cn = $this->dealWage($val->wage, $val->wage_min, $val->wage_max,$val->ygxs);
  2779. }
  2780. }
  2781. $return_list[$key]->experience_cn = '经验不限';
  2782. $return_list[$key]->nature_cn = '职位性质不限';
  2783. $return_list[$key]->education_cn = '学历不限';
  2784. $return_list[$key]->tag_cn = array();
  2785. $return_list[$key]->category_cn = '';
  2786. $return_list[$key]->company->nature_cn = '';
  2787. $return_list[$key]->company->scale_cn = '';
  2788. if ($other_categories) {
  2789. if ($val->experience) {
  2790. $job_experience = array_get($other_categories, 'AIX_experience');
  2791. if ($job_experience) {
  2792. $return_list[$key]->experience_cn = $job_experience[$val->experience]['demand'];
  2793. }
  2794. }
  2795. if ($val->nature) {
  2796. $job_nature = array_get($other_categories, 'AIX_jobs_nature');
  2797. if ($job_nature) {
  2798. $return_list[$key]->nature_cn = $job_nature[$val->nature]['demand'];
  2799. }
  2800. }
  2801. if ($val->education) {
  2802. $job_education = array_get($other_categories, 'AIX_education');
  2803. if ($job_education) {
  2804. $return_list[$key]->education_cn = $job_education[$val->education]['demand'];
  2805. }
  2806. }
  2807. $return_list[$key]->company_audit = $val->company->audit;
  2808. $return_list[$key]->setmeal_id = $val->company->setmeal_id;
  2809. $return_list[$key]->setmeal_name = $val->company->setmeal_name;
  2810. $job_tags = array_get($other_categories, 'AIX_jobtag');
  2811. if (implode(',', $val->tag)) {
  2812. $tag_cn = array();
  2813. foreach ($val->tag as $k => $v) {
  2814. $tag = array_get($job_tags, $v);
  2815. $tag_cn[] = $tag['demand'];
  2816. }
  2817. $return_list[$key]->tag_cn = $tag_cn;
  2818. }
  2819. //企业性质
  2820. $company_types = array_get($other_categories, 'AIX_company_type');
  2821. if ($company_types) {
  2822. $type_cn = array_get($company_types, $val->company->nature);
  2823. if ($type_cn) {
  2824. $return_list[$key]->company->nature_cn= $type_cn['demand'];
  2825. }
  2826. }
  2827. //企业规模
  2828. $company_scales = array_get($other_categories, 'AIX_scale');
  2829. if ($company_scales) {
  2830. $scale_cn = array_get($company_scales, $val->company->scale);
  2831. if ($scale_cn) {
  2832. $return_list[$key]->company->scale_cn = $scale_cn['demand'];
  2833. }
  2834. }
  2835. //企业行业
  2836. $company_trades = array_get($other_categories, 'AIX_trade');
  2837. if ($company_trades) {
  2838. $trade_cn = array_get($company_trades, $val->company->trade);
  2839. if ($trade_cn) {
  2840. $return_list[$key]->company->trade_cn = $trade_cn['demand'];
  2841. }
  2842. }
  2843. //企业logo
  2844. if ($val->company->logo) {
  2845. $return_list[$key]->company->logo = upload_asset($val->company->logo);
  2846. } else {
  2847. $return_list[$key]->company->logo = public_data_path('data/upload/no_logo.png');
  2848. }
  2849. }
  2850. //职位类别
  2851. $category = array();
  2852. if ($val->subclass) {
  2853. $category = array_get($categories['id'], $val->subclass);
  2854. } elseif ($val->category) {
  2855. $category = array_get($categories['id'], $val->category);
  2856. } elseif ($val->topclass) {
  2857. $category = array_get($categories['id'], $val->topclass);
  2858. }
  2859. if ($category) {
  2860. $return_list[$key]->category_cn = $category['name'];
  2861. }
  2862. //工作地点
  2863. if (!strpos($val->district, ".")) {
  2864. if (array_get($city_cates['id'], $val->district)) {
  2865. $return_list[$key]->district_cn = $city_cates['id'][$val->district]['name'];
  2866. if ($city_cates['id'][$val->district]['parent_id'] > 0) {
  2867. $parent_district = array_get($city_cates['id'], $city_cates['id'][$val->district]['parent_id']);
  2868. if ($parent_district) {
  2869. $return_list[$key]->district_cn = $parent_district['name'].$return_list[$key]->district_cn;
  2870. if ($parent_district['parent_id'] > 0) {
  2871. $pp_district = array_get($city_cates['id'], $parent_district['parent_id']);
  2872. if ($pp_district) {
  2873. $return_list[$key]->district_cn = $pp_district['name'].$return_list[$key]->district_cn;
  2874. }
  2875. }
  2876. }
  2877. }
  2878. }
  2879. } else {
  2880. $city_district = explode('.', $val->district);
  2881. $city_district_cn = array();
  2882. foreach ($city_district as $k => $v) {
  2883. if ($v) {
  2884. $district_info = array_get($city_cates['id'], $v);
  2885. if ($district_info) {
  2886. $city_district_cn[] = $district_info['name'];
  2887. }
  2888. }
  2889. }
  2890. $return_list[$key]->district_cn = implode('/', $city_district_cn);
  2891. }
  2892. //刷新时间
  2893. if (!$val->refresh_time) {
  2894. $return_list[$key]->refresh_time = strtotime($val->updated_at);
  2895. }
  2896. //距离
  2897. if ($map_data) {
  2898. $filter_lng = $map_data['lng'];
  2899. $filter_lat = $map_data['lat'];
  2900. $return_list[$key]->map_range = $this->getDistance($filter_lng, $filter_lat, $val->map_x, $val->map_y);
  2901. }
  2902. //招聘人数
  2903. if (!$val->amount) {
  2904. $return_list[$key]->amount = '若干';
  2905. }
  2906. //年龄限制
  2907. if (is_array($val->age)) {
  2908. /*
  2909. if ((implode('', $val->age)=='') || ((int)implode('', $val->age)==0)) {
  2910. $return_list[$key]->age_cn = '不限';
  2911. } else {
  2912. $return_list[$key]->age_cn = implode('-', $val->age).'岁';
  2913. }*/
  2914. if (count($val->age)>1) {
  2915. $age = $val->age;
  2916. if (!$age[0] && !$age[1]) {
  2917. $return_list[$key]->age_cn = '不限';
  2918. } else {
  2919. if ($age[0] && $age[1]) {
  2920. $return_list[$key]->age_cn = $age[0].'-'.$age[1].'岁';
  2921. } else {
  2922. $age[0] && $return_list[$key]->age_cn = $age[0].'岁以上';
  2923. $age[1] && $return_list[$key]->age_cn = $age[1].'岁以下';
  2924. }
  2925. }
  2926. } else {
  2927. $age = $val->age;
  2928. $return_list[$key]->age_cn = $val->age_cn = (int)$age[0].'岁以上';
  2929. }
  2930. } else {
  2931. if ($val->age == '-' || $val->age == '0') {
  2932. $return_list[$key]->age_cn = '不限';
  2933. } else {
  2934. $return_list[$key]->age_cn = $val->age.'岁';
  2935. }
  2936. }
  2937. //性别
  2938. if ($val->sex == 1) {
  2939. $return_list[$key]->sex_cn = '男';
  2940. } elseif ($val->sex == 2) {
  2941. $return_list[$key]->sex_cn = '女';
  2942. } else {
  2943. $return_list[$key]->sex_cn = '不限';
  2944. }
  2945. }
  2946. return $return_list;
  2947. }
  2948. public function getApplyJobs($where, $field = 'jobs_id')
  2949. {
  2950. $rst = $this->personalJobsApplyRepository->getJobsApply($where);
  2951. $list = array();
  2952. if ($rst->toArray()) {
  2953. foreach ($rst as $key => $val) {
  2954. $list[$val->$field] = $val;
  2955. }
  2956. }
  2957. return $list;
  2958. }
  2959. public function getFavoriteJobs($where, $field = 'job_id')
  2960. {
  2961. $rst = $this->personFavoriteRepository->getList($where);
  2962. $list = array();
  2963. if ($rst->toArray()) {
  2964. foreach ($rst as $key => $val) {
  2965. $list[$val->$field] = $val;
  2966. }
  2967. }
  2968. return $list;
  2969. }
  2970. public function getDistance($lng1, $lat1, $lng2, $lat2)
  2971. {
  2972. $radLat1 = deg2rad($lat1);
  2973. $radLat2 = deg2rad($lat2);
  2974. $radLng1 = deg2rad($lng1);
  2975. $radLng2 = deg2rad($lng2);
  2976. $a = $radLat1 - $radLat2;
  2977. $b = $radLng1 - $radLng2;
  2978. $s = 2 * asin(sqrt(pow(sin($a / 2), 2) + cos($radLat1) * cos($radLat2) * pow(sin($b / 2), 2))) * 6378.137;
  2979. return round($s, 2).'km';
  2980. }
  2981. public function dealJobCompanies($jobs)
  2982. {
  2983. $job_companys = array();
  2984. if ($jobs) {
  2985. foreach ($jobs as $k => $val) {
  2986. if (!$job_companys || ($job_companys && !array_has($job_companys, $val->company_id))) {
  2987. $job_companys[$val->company_id] = $val->company;
  2988. $jobs_where = array(array('company_id','=',$val->company_id),array('valid','=',1),array('display','=',1));
  2989. if (config('aix.companyset.comset.show_set.jobs_display') == 1) {
  2990. $jobs_where[] = array('audit','=','1');
  2991. } else {
  2992. $jobs_where[] = array('audit','<>','3');
  2993. }
  2994. $jobs = $this->getOtherJobs($jobs_where, 3);
  2995. $job_companys[$val->company_id]->jobs = $jobs;
  2996. }
  2997. }
  2998. }
  2999. return array_values($job_companys);
  3000. }
  3001. //获取推荐职位
  3002. public function getRecommendOrder($user = array())
  3003. {
  3004. $order = array();
  3005. /*if (auth('web-member')->check()) {
  3006. $order = array('refresh_time'=>'desc');
  3007. } else {
  3008. $order = array('click'=>'desc','stime'=>'desc','refresh_time'=> 'desc');
  3009. }*/
  3010. $order = array('click'=>'desc','stime'=>'desc','refresh_time'=> 'desc');
  3011. return $order;
  3012. }
  3013. //TODO 修改用户读取方式
  3014. public function getRecommendWhere($user = array())
  3015. {
  3016. $where = array();
  3017. //个人会员
  3018. if ($user && $user->utype==2) {
  3019. $filter_resume = array(
  3020. array('uid','=',$user->id)
  3021. );
  3022. if (config('aix.personal_set.per_set.show_set.resume_display')==2) {
  3023. $filter_resume[] = array('audit','<>',0);
  3024. } else {
  3025. $filter_resume[] = array('audit','=',2);
  3026. }
  3027. $resumes = $this->resumeRepository->getResumes($filter_resume);
  3028. if ($resumes->isNotEmpty()) {
  3029. $or_where = array();
  3030. foreach ($resumes as $k => $v) {
  3031. $or_where[] = $this->setRecommendJobWhere($v);
  3032. }
  3033. $and_where = array();
  3034. $and_where[] = array('valid','=',1);
  3035. $and_where[] = array('display','=',1);
  3036. if (config('aix.companyset.comset.show_set.jobs_display')==1) {
  3037. $and_where[] = array('audit','=',1);
  3038. } else {
  3039. $and_where[] = array('audit','<>',3);
  3040. }
  3041. $where['or'] = $or_where;
  3042. $where['and'] = $and_where;
  3043. }
  3044. return $where;
  3045. } else {
  3046. //游客、企业会员 - 点击次数、置顶职位、刷新靠前的职位
  3047. /*$where[] = array('valid','=',1);
  3048. $where[] = array('display','=',1);
  3049. if (config('aix.companyset.comset.show_set.jobs_display')==1) {
  3050. $where[] = array('audit','=',1);
  3051. } else {
  3052. $where[] = array('audit','<>',3);
  3053. }
  3054. $where[] = array('subsite_ids','=',get_subsite_id());*/
  3055. $where['and'][] = array('valid','=',1);
  3056. $where['and'][] = array('display','=',1);
  3057. if (config('aix.companyset.comset.show_set.jobs_display')==1) {
  3058. $where['and'][] = array('audit','=',1);
  3059. } else {
  3060. $where['and'][] = array('audit','<>',3);
  3061. }
  3062. $where['and'][] = array('subsite_ids','=',get_subsite_id());
  3063. }
  3064. return $where;
  3065. }
  3066. //匹配个人推荐职位的查询条件
  3067. public function setRecommendJobWhere($resume)
  3068. {
  3069. $where = array();
  3070. /*$where[] = array('valid','=',1);
  3071. $where[] = array('display','=',1);
  3072. if (config('aix.companyset.comset.show_set.jobs_display')==1) {
  3073. $where[] = array('audit','=',1);
  3074. } else {
  3075. $where[] = array('audit','<>',3);
  3076. }*/
  3077. //匹配性别
  3078. if ($resume->sex == 1) {
  3079. $where[] = array('sex','<>',2);
  3080. } else {
  3081. $where[] = array('sex','<>',1);
  3082. }
  3083. //匹配年龄age_min、age_max
  3084. $age = date("Y") - $resume->birthdate;
  3085. $where[] = array('age_min','<=',$age);
  3086. $where[] = array('age_max','>=',$age);
  3087. $where[] = array('education','<=',$resume->education); //匹配学历
  3088. $where[] = array('experience','<=',$resume->experience); //匹配工作经验
  3089. $where[] = array('nature','=',$resume->nature); //匹配工作性质 - 精准匹配
  3090. //匹配期望行业trade - 如果没有值则不添加匹配条件
  3091. if ($resume->trade) {
  3092. $trades = explode(',', $resume->trade);
  3093. $where[] = array('trade','in',$trades);
  3094. }
  3095. //匹配期望职位 - 二级职位
  3096. $intention_jobs_cates = explode(',', $resume->intention_jobs_id);
  3097. $intention_cates = array();
  3098. foreach ($intention_jobs_cates as $k => $v) {
  3099. $i_ids = explode('.', $v);
  3100. if (array_has($i_ids, 1)) {
  3101. $intention_cates[] = (int)$i_ids[1];
  3102. }
  3103. }
  3104. if ($intention_cates) {
  3105. $where[] = array('intention_jobs_id','in',$intention_cates);
  3106. }
  3107. //匹配工作地区(职位的工作地区)(三级地区存在时匹配三级地区,不存在时匹配二级地区)
  3108. $district = explode(',', $resume->district);
  3109. $district_ids = array();
  3110. if ($district) {
  3111. foreach ($district as $k => $v) {
  3112. if (!strpos($v, ".")) {
  3113. $district_ids[] = $v;
  3114. } else {
  3115. $district_arr = explode('.', $v);
  3116. if (array_has($district_arr, 2) && array_get($district_arr, 2)>0) {
  3117. $district_ids[] = (int)$district_arr[2];
  3118. } else {
  3119. $district_ids[] = (int)$district_arr[1];
  3120. }
  3121. }
  3122. }
  3123. }
  3124. if ($district_ids) {
  3125. $where[] = array('district','in',$district_ids);
  3126. }
  3127. //匹配期望薪资 - (第二版逻辑:职位薪资最大值和最小值包含期望薪资、面议)
  3128. $where[] = array('wage_min','<=',$resume->wage_min);
  3129. $where[] = array('wage_max','>=',$resume->wage_max);
  3130. $where[] = array('subsite_ids','=',get_subsite_id());
  3131. return $where;
  3132. }
  3133. public function autoRefreshJobs(array $pid_arr)
  3134. {
  3135. if ($this->jobsRepository->autoRefreshJobs($pid_arr)) {
  3136. return true;
  3137. }
  3138. return false;
  3139. }
  3140. /**将职位管理内的职位转入招聘会职位库
  3141. * @param $request
  3142. * @return JsonResponse
  3143. * @throws \Prettus\Validator\Exceptions\ValidatorException
  3144. */
  3145. public function jobsAddToJobfair($request,$user)
  3146. {
  3147. $jid = $request->id;
  3148. if (!$jid || !$jobsInfo = $this->jobsRepository->find($jid)) {
  3149. return response()->json(['status'=>0,'msg'=>"参数错误或无此职位"]);
  3150. }
  3151. $this->isOwn($jid,$user);
  3152. $type1 = $this->jobfairJobRepository->findWhere(['jobs_name'=>$jobsInfo->jobs_name,'company_id'=>$jobsInfo->company_id,'type'=>1])->isNotEmpty();
  3153. $type2 = $this->jobfairJobRepository->findWhere(['jobs_name'=>$jobsInfo->jobs_name,'company_id'=>$jobsInfo->company_id,'type'=>2])->isNotEmpty();
  3154. if($type1 && $type2 ){
  3155. return response()->json(['status'=>0,'msg'=>"该职位已存在招聘会职位库中,请添加其他职位"]);
  3156. }
  3157. $insertArr = [];
  3158. if ($jobCatact = $this->jobsContactRepository->getContactInfo(['job_id'=>$jid])) {
  3159. $contactData = $this->jobsContactRepository->find($jobCatact->id);
  3160. $contactArr = ['contact','qq','mobile','notify','landline_tel','email','address','notify_mobile','contact_show','telephone_show','email_show','landline_tel_show'];
  3161. foreach ($contactArr as $key => $val) {
  3162. if ($val == 'mobile') {
  3163. $insertArr[$val] = $jobCatact->telephone;
  3164. } elseif ($val=='landline_tel') {
  3165. if (isset($jobCatact->landline_tel)) {
  3166. $insertArr[$val] = implode('-', $jobCatact->landline_tel);
  3167. } else {
  3168. $insertArr[$val]='--';
  3169. }
  3170. } else {
  3171. $insertArr[$val] = $jobCatact->$val;
  3172. }
  3173. }
  3174. }
  3175. $jobfairArr = [
  3176. 'jobs_name',
  3177. 'company_id',
  3178. 'company_name',
  3179. 'company_addtime',
  3180. 'company_audit',
  3181. 'stick',
  3182. 'amount',
  3183. 'negotiable',
  3184. 'jobs_content',
  3185. 'audit',
  3186. 'click',
  3187. 'display',
  3188. 'robot',
  3189. 'map_x',
  3190. 'map_y',
  3191. 'map_zoom',
  3192. 'add_mode',
  3193. 'department',
  3194. 'nature',
  3195. 'sex',
  3196. 'age',
  3197. 'topclass',
  3198. 'category',
  3199. 'subclass',
  3200. 'trade',
  3201. 'scale',
  3202. 'district',
  3203. 'education',
  3204. 'experience',
  3205. 'wage',
  3206. 'wage_max',
  3207. 'wage_min',
  3208. 'ygxs',
  3209. 'syq',
  3210. 'syqxz_min',
  3211. 'techlevel'
  3212. ];
  3213. foreach ($jobfairArr as $key => $val) {
  3214. $insertData[$val] = $jobsInfo->$val;
  3215. }
  3216. if ($jobsInfo['topclass'] && $jobsInfo['category'] && $jobsInfo['subclass']) {
  3217. $insertData['category_cn'] = get_job_category_cn($jobsInfo['topclass'].".".$jobsInfo['category'].'.'.$jobsInfo['subclass']);
  3218. } else {
  3219. $insertData['category_cn'] = '';
  3220. }
  3221. if(!empty($insertData['age'])){
  3222. $insertData['age'] = implode('-',$insertData['age'] );
  3223. }
  3224. $insertData['nature_cn'] = $jobsInfo['nature']?get_category($jobsInfo['nature']):'';
  3225. $insertData['trade_cn'] = $jobsInfo['trade']?get_category($jobsInfo['trade']):'';
  3226. $insertData['scale_cn'] = $jobsInfo['scale']?get_category($jobsInfo['scale']):'';
  3227. $insertData['education_cn'] = $jobsInfo['education']?get_category($jobsInfo['education']):'';
  3228. $insertData['experience_cn'] = $jobsInfo['experience']?get_category($jobsInfo['experience']):"";
  3229. if (intval($insertData['wage']) == 0) {
  3230. if ($insertData['wage_max']) {
  3231. $insertData['wage_cn'] = $insertData['wage_min'].'~'.$insertData['wage_max'].'/月';
  3232. } else {
  3233. $insertData['wage_cn'] = $insertData['wage_min'].'/月以上';
  3234. }
  3235. }elseif(intval($insertData['wage']) == -1){
  3236. $insertData['wage_cn'] = '面议';
  3237. }else{
  3238. $insertData['wage_cn'] = $jobsInfo['wage']?get_category($jobsInfo['wage']):'';
  3239. }
  3240. $insertData['ygxs'] = $jobsInfo['ygxs']?$jobsInfo['ygxs']:'';
  3241. $insertData['syq'] = $jobsInfo['syq']?$jobsInfo['syq']:'';
  3242. $insertData['syqxz_min'] = $jobsInfo['syqxz_min']?$jobsInfo['syqxz_min']:'';
  3243. $insertData['techlevel'] = $jobsInfo['techlevel']?$jobsInfo['techlevel']:'';
  3244. $insertData['district_cn'] = get_district_cn($jobsInfo['district']);
  3245. if ($jobsInfo['tag'][0]) {
  3246. $insertData['tag_cn'] = get_tag_cn(implode(',', $jobsInfo['tag']));
  3247. } else {
  3248. $insertData['tag_cn']='';
  3249. }
  3250. switch ($jobsInfo['sex']) {
  3251. case 1:
  3252. $insertData['sex_cn'] = '男';
  3253. break;
  3254. case 2:
  3255. $insertData['sex_cn'] = '女';
  3256. break;
  3257. case 0:
  3258. $insertData['sex_cn'] = '不限';
  3259. break;
  3260. }
  3261. try{
  3262. if(!$type1){
  3263. $insertData['type'] = 1;
  3264. if (!$jobfair_jobid = $this->jobfairJobRepository->create($insertData)) {
  3265. throw new \Exception('转入招聘会职位库失败!');
  3266. }
  3267. if ($insertArr) {
  3268. $insertArr['pid'] = $jobfair_jobid->id;
  3269. $this->jobfairJobsContactRepository->create($insertArr);
  3270. }
  3271. }
  3272. if(!$type2){
  3273. $insertData['type'] = 2;
  3274. if (!$jobfairout_jobid = $this->jobfairJobRepository->create($insertData)) {
  3275. throw new \Exception('转入招聘会职位库失败!');
  3276. }
  3277. if ($insertArr) {
  3278. $insertArr['pid'] = $jobfairout_jobid->id;
  3279. $this->jobfairJobsContactRepository->create($insertArr);
  3280. }
  3281. }
  3282. DB::commit();
  3283. return response()->json(['status'=>1,'msg'=>"成功转入招聘会职位库!",'data' => '']);
  3284. }catch (Exception $e) {
  3285. DB::rollback();
  3286. return response()->json(['status'=>1,'msg'=>$e->getMessage(),'data' => '']);
  3287. }
  3288. }
  3289. public function isOwn($ids,$user)
  3290. {
  3291. $ids = is_array($ids)?$ids:explode(',',$ids);
  3292. $putJobs = $this->jobsRepository->getPluck(['company_id'=>$user->id],'id')->toArray();
  3293. if(array_diff($ids,$putJobs))
  3294. {
  3295. throw new ResponseException('抱歉,您只能操作自己的招聘会职位!');
  3296. }
  3297. }
  3298. }