DecStock.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace App\Console\Commands;
  3. use App\Facade\TableName;
  4. use App\Http\helper\NumConfig;
  5. use Illuminate\Console\Command;
  6. use Illuminate\Support\Facades\DB;
  7. class DecStock extends Command
  8. {
  9. /**
  10. * The name and signature of the console command.
  11. *
  12. * @var string
  13. */
  14. protected $signature = 'dec_stock';
  15. /**
  16. * The console command description.
  17. *
  18. * @var string
  19. */
  20. protected $description = '减少crash库存';
  21. /**
  22. * Create a new command instance.
  23. *
  24. * @return void
  25. */
  26. public function __construct()
  27. {
  28. parent::__construct();
  29. }
  30. /**
  31. * Execute the console command.
  32. *
  33. * @return mixed
  34. */
  35. public function handle()
  36. {
  37. $limitValue = 18000 * NumConfig::NUM_VALUE;
  38. $decValue = 3000 * NumConfig::NUM_VALUE;
  39. $list = DB::table(TableName::QPPlatformDB() . 'RoomStockStatic')
  40. ->where('GameID', 4020)
  41. ->where('Stock', '>=', $limitValue)
  42. ->get();
  43. if ($list->isNotEmpty()) {
  44. foreach ($list as $value) {
  45. DB::table(TableName::QPPlatformDB() . 'RoomStockStatic')
  46. ->where('ID', $value->ID)
  47. ->decrement('Stock', $decValue);
  48. }
  49. }
  50. }
  51. }