Jobfair.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. namespace App\Jobs\Cron;
  3. use App\Services\Jobfair\JobfairService;
  4. use App\Services\Jobfairout\JobfairoutService;
  5. use Illuminate\Bus\Queueable;
  6. use Illuminate\Queue\SerializesModels;
  7. use Illuminate\Queue\InteractsWithQueue;
  8. use Illuminate\Contracts\Queue\ShouldQueue;
  9. use Illuminate\Foundation\Bus\Dispatchable;
  10. use App\Models\Jobfair\Jobfair as JobF;
  11. use App\Models\Jobfairout\Jobfairout;
  12. use App\Models\Jobfair\JobfairCompany;
  13. use App\Models\MembersPoint;
  14. use Illuminate\Support\Facades\Log;
  15. use App\Repositories\MemberHandselRepository;
  16. class Jobfair implements ShouldQueue
  17. {
  18. use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
  19. const CREATE_LIST = 'create';
  20. const UPDATE_LIST = 'update';
  21. /**
  22. * Create a new job instance.
  23. *
  24. * @return void
  25. */
  26. public function __construct()
  27. {
  28. }
  29. /**
  30. * Execute the job.
  31. *
  32. * @return void
  33. */
  34. public function handle(JobfairService $jobfairService,JobfairoutService $jobfairoutService,MemberHandselRepository $memberHandselRepository)
  35. {
  36. $id = $jobfairService->getJobfairOpen();
  37. if ($id) {
  38. $res = JobF::whereIn('id', $id)->update(['predetermined_status'=>2]);
  39. if (!$res) {
  40. Log::error('jobfairs failed to update.', ['date' =>$id]);
  41. }
  42. }
  43. foreach ($id as $value)
  44. {
  45. $is_commonweal = JobF::where('id',$value)->value('is_commonweal');
  46. if($is_commonweal != 3){
  47. $nosign_point = JobF::where('id',$value)->value('nosign_point');
  48. if($nosign_point){
  49. $list = JobfairCompany::where(['type'=>0,'jobfair_id'=>$value])->get();
  50. foreach ($list as $val)
  51. {
  52. $points = MembersPoint::where(['utype'=>1,'uid'=>$val->company_id])->value('points');
  53. if($points > $nosign_point){
  54. MembersPoint::where(['utype'=>1,'uid'=>$val->company_id])->decrement('points',$nosign_point);
  55. $handsel['uid'] = $val->company_id;
  56. $handsel['utype'] = 1;
  57. $handsel['htype'] = 'jobfair_late';
  58. $handsel['htype_cn'] = '招聘会未签到';
  59. $handsel['operate'] = 2;
  60. $handsel['points'] = $nosign_point;
  61. $memberHandselRepository->addNew($handsel);
  62. }else{
  63. MembersPoint::where(['utype'=>1,'uid'=>$val->company_id])->update(['points'=>0]);
  64. }
  65. }
  66. }
  67. }
  68. }
  69. $id = $jobfairoutService->getJobfairOpen();
  70. if ($id) {
  71. $res = Jobfairout::whereIn('id', $id)->update(['predetermined_status'=>2]);
  72. if (!$res) {
  73. Log::error('jobfairout failed to update.', ['date' =>$id]);
  74. }
  75. }
  76. foreach ($id as $value)
  77. {
  78. $is_commonweal = Jobfairout::where('id',$value)->value('is_commonweal');
  79. if($is_commonweal != 3){
  80. $nosign_point = Jobfairout::where('id',$value)->value('nosign_point');
  81. if($nosign_point){
  82. $list = JobfairCompany::where(['type'=>0,'jobfair_id'=>$value])->get();
  83. foreach ($list as $val)
  84. {
  85. $points = MembersPoint::where(['utype'=>1,'uid'=>$val->company_id])->value('points');
  86. if($points > $nosign_point){
  87. MembersPoint::where(['utype'=>1,'uid'=>$val->company_id])->decrement('points',$nosign_point);
  88. $handsel['uid'] = $val->company_id;
  89. $handsel['utype'] = 1;
  90. $handsel['htype'] = 'jobfair_late';
  91. $handsel['htype_cn'] = '赴外招聘会未签到';
  92. $handsel['operate'] = 2;
  93. $handsel['points'] = $nosign_point;
  94. $memberHandselRepository->addNew($handsel);
  95. }else{
  96. MembersPoint::where(['utype'=>1,'uid'=>$val->company_id])->update(['points'=>0]);
  97. }
  98. }
  99. }
  100. }
  101. }
  102. }
  103. }