小说推广数据系统

JiaShuHistoryOrderDeal.php 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. namespace App\Console\Commands;
  3. use App\Models\VpOrder;
  4. use App\Models\VpOrderTest;
  5. use Illuminate\Console\Command;
  6. class JiaShuHistoryOrderDeal extends Command
  7. {
  8. protected $signature = 'JiaShuHistoryOrderDeal';
  9. protected $description = '嘉书历史订单处理';
  10. protected $start_id = 0;
  11. protected $limit = 1000;
  12. protected $channelList = array(
  13. '70327' => 'wx35a5e4175affaf71',
  14. '70085' => 'wx23630ed2f44c2f5e',
  15. '70337' => 'wx9610dca9398d58bc',
  16. '70104' => 'wxf6ac30e692cac6c8',
  17. '70326' => 'wx0d5ab4fa74e7924b',
  18. '70324' => 'wx03ae62e1695f04ff',
  19. '70109' => 'wx7fe3aebf2e55afdf',
  20. '70335' => 'wx4a7aec1334bda92c',
  21. '70336' => 'wxb560dbff83c78e6f',
  22. '70118' => 'wx74c4e96321ec757a',
  23. '70068' => 'wxef07de73d69c4adc',
  24. );
  25. public function handle()
  26. {
  27. \DB::connection()->disableQueryLog();
  28. $this->info(date('m-d H:i:s') . ' 开始整理');
  29. $platformId = 2;
  30. do{
  31. $this->info('本次查询的起始ID:'.$this->start_id);
  32. $list = VpOrderTest::where('id', '>', $this->start_id)->orderBy('id')->limit($this->limit)->get();
  33. $count = $list->count();
  34. $this->info('本次获取的数据条数'.$count);
  35. $this->start_id = $list->max('id');
  36. foreach ($list as $order) {
  37. $orderId = $order->order_id;
  38. $channel = $order->channel;
  39. $appId = isset($this->channelList[$channel]) ? $this->channelList[$channel] : '';
  40. $insertData = [
  41. 'pay_money' => $order->pay_money * 10000,
  42. 'user_id' => $order->user_id,
  43. 'platform_created_at' => $order->platform_created_at,
  44. 'platform_updated_at' => $order->platform_updated_at,
  45. 'pay_status' => $order->pay_status,
  46. 'openid' => $order->openid,
  47. 'user_register_time' => $order->mp_user_register_time,
  48. 'mp_user_register_time' => $order->mp_user_register_time,
  49. 'playlet_id' => $order->playlet_id,
  50. 'playlet_name' => $order->playlet_name,
  51. 'channel' => $order->channel,
  52. 'app_id' => $appId,
  53. ];
  54. VpOrder::updateOrCreate(
  55. ['platform_id' => $platformId, 'order_id' => (string)$orderId], $insertData
  56. );
  57. }
  58. } while($count == $this->limit);
  59. $this->info(date('m-d H:i:s') . ' 整理结束');
  60. }
  61. }