leftjoin('ims_system_coupon_user_receive as r','u.id','=','r.system_coupon_user_id') ->where([ ['r.user_id','=',$user_id], ['r.receive_type','=',4], ['u.active_type','=',2], ]) ->select('r.id') ->first(); return $res; } public function getActiveInfo() { $time = time(); $res = Db::table('ims_system_coupon_user') ->where([ ['status','=',1], ['active_type','=',2], ['start_time','<=',$time], ['end_time','>',$time], ]) ->whereRaw('inventory > inventory_use') ->get(); return $res; } }