123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- namespace App\Console\Commands;
- use App\Models\VpOrder;
- use App\Models\VpOrderTest;
- use Illuminate\Console\Command;
- class JiaShuHistoryOrderDeal extends Command
- {
- protected $signature = 'JiaShuHistoryOrderDeal';
- protected $description = '嘉书历史订单处理';
- protected $start_id = 0;
- protected $limit = 1000;
- protected $channelList = array(
- '70327' => 'wx35a5e4175affaf71',
- '70085' => 'wx23630ed2f44c2f5e',
- '70337' => 'wx9610dca9398d58bc',
- '70104' => 'wxf6ac30e692cac6c8',
- '70326' => 'wx0d5ab4fa74e7924b',
- '70324' => 'wx03ae62e1695f04ff',
- '70109' => 'wx7fe3aebf2e55afdf',
- '70335' => 'wx4a7aec1334bda92c',
- '70336' => 'wxb560dbff83c78e6f',
- '70118' => 'wx74c4e96321ec757a',
- '70068' => 'wxef07de73d69c4adc',
- );
- public function handle()
- {
- \DB::connection()->disableQueryLog();
- $this->info(date('m-d H:i:s') . ' 开始整理');
- $platformId = 2;
- do{
- $this->info('本次查询的起始ID:'.$this->start_id);
- $list = VpOrderTest::where('id', '>', $this->start_id)->orderBy('id')->limit($this->limit)->get();
- $count = $list->count();
- $this->info('本次获取的数据条数'.$count);
- $this->start_id = $list->max('id');
- foreach ($list as $order) {
- $orderId = $order->order_id;
- $channel = $order->channel;
- $appId = isset($this->channelList[$channel]) ? $this->channelList[$channel] : '';
- $insertData = [
- 'pay_money' => $order->pay_money * 10000,
- 'user_id' => $order->user_id,
- 'platform_created_at' => $order->platform_created_at,
- 'platform_updated_at' => $order->platform_updated_at,
- 'pay_status' => $order->pay_status,
- 'openid' => $order->openid,
- 'user_register_time' => $order->mp_user_register_time,
- 'mp_user_register_time' => $order->mp_user_register_time,
- 'playlet_id' => $order->playlet_id,
- 'playlet_name' => $order->playlet_name,
- 'channel' => $order->channel,
- 'app_id' => $appId,
- ];
- VpOrder::updateOrCreate(
- ['platform_id' => $platformId, 'order_id' => (string)$orderId], $insertData
- );
- }
- } while($count == $this->limit);
- $this->info(date('m-d H:i:s') . ' 整理结束');
- }
- }
|