Example #1
0
 private function _handleData($order_info, $data, $uid, $gid)
 {
     $res = [];
     foreach ($data as $k => $v) {
         $order = new OrderList();
         //如果此信息已经存在,则更新
         if ($order_info['id']) {
             $order->id = $order_info['id'];
             $order->where('id', $order_info['id'])->update(['order_status' => $v['entrust_status'], 'order_time' => $v['entrust_date'], 'order_amount' => $v['entrust_amount'], 'order_price' => $v['entrust_price'], 'status_name' => $v['status_name'], 'business_amount' => $v['business_amount'], 'business_price' => $v['business_price']]);
         } else {
             $order->uid = $uid;
             $order->gid = $gid;
             $order->order_id = $v['entrust_no'];
             $order->stock_code = $v['stock_code'];
             $order->stock_name = $v['stock_name'];
             $order->order_price = $v['entrust_price'];
             $order->order_amount = $v['entrust_amount'];
             $order->order_status = $v['entrust_status'];
             $order->order_time = $v['entrust_date'];
             $order->buyorsell = $v['entrust_bs'];
             $order->status_name = $v['status_name'];
             $order->business_amount = $v['business_amount'];
             $order->business_price = $v['business_price'];
             $order->save();
             $res[] = $order->id;
         }
         break;
     }
     return $res;
 }
Example #2
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $redis = app('DbRedis');
     $calculate_queue_key = 'calculate_entrust_no';
     $order_list = new OrderList();
     $trade_data = [];
     while ($entrust_no = $redis->lPop($calculate_queue_key)) {
         $data = $order_list->where('order_id', $entrust_no)->first()->toArray();
         if ($data) {
             $trade_data = $this->_handleTradeData($entrust_no, $trade_data, $data);
         }
     }
     if (is_array($trade_data) && !empty($trade_data)) {
         foreach ($trade_data as $k => $v) {
             $this->_tradeDataInsertDb($v);
         }
     }
     $this->info('task finished...');
 }