1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?php
- namespace app\admin\model;
- use support\Db;
- use support\Model;
- /**
- * 绿色蔬菜
- * Class Order
- * @package app\admin\model
- */
- class LifeFarmOrder extends Model
- {
- /**
- *
- * The table associated with the model.
- *
- * @var string
- */
- protected $table = 'life_farm_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,string $keywords)
- {
- $list = static::select('*')
- ->when($keywords != '', function ($query) use ($keywords){
- $query->where('order_sn', 'like', '%' . $keywords . '%');
- })
- ->with(['User','Shop'])
- ->orderBy('order_create_time','DESC')
- ->forPage($page, $limit)
- ->get()->toArray();
- $count = static::when($keywords != '', function ($query) use ($keywords){
- $query->where('order_sn', 'like', '%' . $keywords . '%');
- })->count();
- return [$list, $count];
- }
- //关联店铺
- 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 getOrderCreateTimeAttribute($value)
- {
- return date('Y-m-d H:i:s', $value);
- }
- public function getOrderDeliverTimeAttribute($value)
- {
- return date('Y-m-d H:i:s', $value);
- }
- public function getOrderPayTimeAttribute($value)
- {
- return date('Y-m-d H:i:s', $value);
- }
- }
|