| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 | 
							- <?php
 
- namespace app\admin\model;
 
- use support\Db;
 
- use support\Model;
 
- /**
 
-  * 悦活影院订单
 
-  * Class Users
 
-  * @package app\admin\model
 
-  */
 
- class CinemaOrder extends Model
 
- {
 
-     /**
 
-      *
 
-      * The table associated with the model.
 
-      *
 
-      * @var string
 
-      */
 
-     protected $table = 'life_cinema_order';
 
-     public $timestamps = false;
 
-     /**
 
-      * Notes:获取订单列表
 
-      * @param string $keywords
 
-      * @param int $page
 
-      * @param int $limit
 
-      * @return array
 
-      * User: ZQ
 
-      * Date: 2022/10/13
 
-      */
 
-     public static function getOrderList(int $page, int $limit,$keywords)
 
-     {
 
-         $list = static::select('*')
 
-             ->with(['user'])
 
-             ->with(['detail'])
 
-             ->when($keywords != '', function ($query) use ($keywords){
 
-                 $query->where('order_sn', 'like', '%' . $keywords . '%');
 
-             })
 
-             ->orderBy('order_create_time','DESC')
 
-             ->forPage($page, $limit)
 
-             ->get();
 
-         $count = static::when($keywords != '', function ($query) use ($keywords){
 
-             $query->where('order_sn', 'like', '%' . $keywords . '%');
 
-         })->count();
 
-         return [$list, $count];
 
-     }
 
-     public function Attr(){
 
-         return $this->hasMany(MedicalCareProductAttr::class,'attr_product_id','product_id')->where(['attr_is_delete'=>0]);
 
-     }
 
-     //关联店铺
 
-     public function Shop(){
 
-         return $this->belongsTo(MerchantShop::class,'order_shop_id','shop_id');
 
-     }
 
-     //获取用户信息
 
-    public function User(){
 
-         return $this->belongsTo(User::class,'order_user_id','user_id');
 
-    }
 
-     //获取订单详情
 
-     public function Detail(){
 
-         return $this->hasMany(CinemaOrderDetail::class,'detail_order_id','order_id')
 
-             ->leftJoin('life_cinema','cinema_id','=','life_cinema_order_detail.detail_goods_id')
 
-             ->select(['life_cinema_order_detail.*','life_cinema.cinema_name']);
 
-     }
 
- }
 
 
  |