MatchingPublishCommand.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace App\Console\Commands\pair;
  3. use App\Models\Fpdx\ActivityModel;
  4. use Illuminate\Console\Command;
  5. class MatchingPublishCommand extends Command
  6. {
  7. /**
  8. * The name and signature of the console command.
  9. *
  10. * @var string
  11. */
  12. protected $signature = 'pair:publish';
  13. /**
  14. * The console command description.
  15. *
  16. * @var string
  17. */
  18. protected $description = '匹配公布';
  19. private $stage_id;
  20. /**
  21. * Create a new command instance.
  22. *
  23. * @return void
  24. */
  25. public function __construct()
  26. {
  27. parent::__construct();
  28. }
  29. /**
  30. * Execute the console command.
  31. *
  32. * @return mixed
  33. */
  34. public function handle()
  35. {
  36. $this->stage_id = ActivityModel::where('signend_time', '<=', time())
  37. ->where('close_time', '>=', time())->value('stage_id');
  38. \DB::table('kdgx_partner_charge_pair')->where('stage_id', $this->stage_id)
  39. ->whereNotNull('assoc_id')->whereBetween('state', [100, 199])->increment('state', 300);
  40. \DB::table('kdgx_partner_charge_pair')->where('stage_id', $this->stage_id)
  41. ->whereNull('assoc_id')->whereBetween('state', [100, 199])->increment('state', 200);
  42. \DB::table('kdgx_partner_charge_pair')->where('stage_id', $this->stage_id)
  43. ->whereNull('assoc_id')->whereBetween('state', [0, 99])->increment('state', 900);
  44. $pairs = \DB::table('kdgx_partner_charge_pair')
  45. ->where('stage_id', $this->stage_id)->whereNull('assoc_id')->pluck('id');
  46. \DB::table('kdgx_fpdx_deed')->where('type', 1)->whereIn('ack', $pairs)->update(['state' => -1]);
  47. $pairs = \DB::table('kdgx_partner_charge_pair')
  48. ->where('stage_id', $this->stage_id)->whereNotNull('assoc_id')->pluck('id');
  49. \DB::table('kdgx_fpdx_deed')->where('type', 1)->where('state', 1)->whereIn('ack', $pairs)->update([
  50. 'state' => 2,
  51. ]);
  52. }
  53. }