where(['equipment_del'=>0]) ->leftJoin('user','user_id','=','user_intelligence_equipment.equipment_user_id') ->leftJoin('intelligence_products','product_id','=','user_intelligence_equipment.equipment_intelligence_id') ->when($equipment_user_id != '', function ($query) use ($equipment_user_id){ $query->where('equipment_user_id', $equipment_user_id); }) ->when($equipment_class != '', function ($query) use ($equipment_class){ $query->where('equipment_class', $equipment_class); }) ->when($equipment_name != '', function ($query) use ($equipment_name){ $query->where('equipment_name', 'like', '%'.$equipment_name.'%'); }) ->when($equipment_tripartite_sn != '', function ($query) use ($equipment_tripartite_sn){ $query->where('equipment_tripartite_sn',$equipment_tripartite_sn); }) ->when($equipment_create_time != '', function ($query) use ($equipment_create_time){ $start = strtotime($equipment_create_time); $end = $start+24*60*60; $query->whereBetween('equipment_create_time',[$start,$end]); }) ->forPage($page, $limit) ->orderBy('equipment_create_time','DESC') ->get(); $count = static::select() ->where(['equipment_del'=>0]) ->when($equipment_user_id != '', function ($query) use ($equipment_user_id){ $query->where('equipment_user_id', $equipment_user_id); }) ->when($equipment_class != '', function ($query) use ($equipment_class){ $query->where('equipment_class', $equipment_class); }) ->when($equipment_name != '', function ($query) use ($equipment_name){ $query->where('equipment_name', 'like', '%'.$equipment_name.'%'); }) ->when($equipment_tripartite_sn != '', function ($query) use ($equipment_tripartite_sn){ $query->where('equipment_tripartite_sn',$equipment_tripartite_sn); }) ->when($equipment_create_time != '', function ($query) use ($equipment_create_time){ $start = strtotime($equipment_create_time); $end = $start+24*60*60; $query->whereBetween('equipment_create_time',[$start,$end]); }) ->count(); return [$list,$count]; } /** * Notes:会员智能设备数据详情 * @return int * User: ZQ * Date: 2022/9/23 */ public static function equipmentInfor(array $where) { return static::where($where) ->leftJoin('user','user_id','=','user_intelligence_equipment.equipment_user_id') ->leftJoin('intelligence_products','product_id','=','user_intelligence_equipment.equipment_intelligence_id') ->first(['user_intelligence_equipment.*','user.user_nickname','intelligence_products.product_name','user.user_phone']); } /** * Notes:会员智能设备数据插入 * @return int * User: ZQ * Date: 2022/9/19 */ public static function equipmentInsert($data) { $id = static::insertGetId($data); return $id; } }