當前位置: 首頁>>代碼示例>>PHP>>正文


PHP OrderDetail::where方法代碼示例

本文整理匯總了PHP中OrderDetail::where方法的典型用法代碼示例。如果您正苦於以下問題:PHP OrderDetail::where方法的具體用法?PHP OrderDetail::where怎麽用?PHP OrderDetail::where使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在OrderDetail的用法示例。


在下文中一共展示了OrderDetail::where方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $days_to_wait = Config::get('store.days_to_close');
     //\DB::enableQueryLog();
     $this->info("Checks If there are orders to be closed ({$days_to_wait} Days Old)");
     //Checks all closed orders that has not been rated nor mail has been sent and where updated 5 days ago
     //and the mails has not been sent yet
     $orders = Order::where('status', 'sent')->where('updated_at', '<', Carbon::now()->subDays($days_to_wait))->get();
     //$this->info(print_r(\DB::getQueryLog()));
     $this->info("Orders That need to be closed: " . $orders->count());
     foreach ($orders as $order) {
         $this->info("Order: " . $order->id . ' Needs to be closed');
         $buyer = User::find($order->user_id);
         if ($buyer) {
             $email = $buyer->email;
             $mail_subject = trans('email.cron_emails.order_closed_for_time');
             $data = ['email_message' => $mail_subject, 'email' => $email, 'subject' => $mail_subject, 'order_id' => $order->id];
             Mail::queue('emails.cron.close_order', $data, function ($message) use($data) {
                 $message->to($data['email'])->subject($data['subject']);
             });
             $order->status = 'closed';
             $order->end_date = DB::raw('NOW()');
             $seller = User::findOrFail($order->seller_id);
             if ($seller) {
                 $order_content = OrderDetail::where('order_id', $order->id)->get();
                 $total_points = 0;
                 foreach ($order_content as $order_detail) {
                     $total_points += $order_detail->quantity * $order_detail->price;
                     $order_detail->status = 0;
                     $order_detail->delivery_date = DB::raw('NOW()');
                     $order_detail->save();
                     if ($order_detail->product->type != 'item') {
                         switch ($order_detail->product->type) {
                             case 'key':
                                 $virtualProductsId = VirtualProductOrder::select('virtual_product_id')->where('order_id', $order->id)->get()->toArray();
                                 VirtualProduct::where('product_id', $order_detail->product_id)->whereIn('id', $virtualProductsId)->update(['status' => 'closed']);
                                 break;
                         }
                     }
                 }
                 $seller->modifyPoints($total_points, 8, $order->id);
             }
             $order->save();
         }
     }
 }
開發者ID:masterpowers,項目名稱:antVel,代碼行數:51,代碼來源:CloseOrdersByTime.php


注:本文中的OrderDetail::where方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。