DecStock.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. return false;
  38. $limitValue = 18000 * NumConfig::NUM_VALUE;
  39. $decValue = 3000 * NumConfig::NUM_VALUE;
  40. $list = DB::table(TableName::QPPlatformDB() . 'RoomStockStatic')
  41. ->where('GameID', 4020)
  42. ->where('Stock', '>=', $limitValue)
  43. ->get();
  44. if ($list->isNotEmpty()) {
  45. foreach ($list as $value) {
  46. DB::table(TableName::QPPlatformDB() . 'RoomStockStatic')
  47. ->where('ID', $value->ID)
  48. ->decrement('Stock', $decValue);
  49. }
  50. }
  51. }
  52. }