Geen omschrijving

SyncSkuToRedis.php 877B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace App\Console\Commands;
  3. use Illuminate\Console\Command;
  4. use DB;
  5. use App\OrderGoodsSkus;
  6. use App\GoodsSkus;
  7. use App\Order;
  8. class SyncSkuToRedis extends Command {
  9. protected $signature = 'SyncSkuToRedis';
  10. /**
  11. * The console command description.
  12. *
  13. * @var string
  14. */
  15. protected $description = '同步订单到卖家云';
  16. public function handle()
  17. {
  18. $this->SyncSkuToRedis();
  19. }
  20. public function SyncSkuToRedis(){
  21. $order_ids = Order::where('warehouse', 3)->where('is_del', 0)->whereNull('orderCode')->lists('id');
  22. $res = OrderGoodsSkus::select(DB::raw('sum(num) as num , sku_id'))->whereIn('order_id', $order_ids)->where('mj_status', 0)->where('is_del', 0)->groupBy('sku_id')->get();
  23. $res = json_decode(json_encode($res), true);
  24. Order::diffSkuToRedis('', $res);
  25. }
  26. }