当前位置: 首页>>代码示例>>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;未经允许,请勿转载。